2010年春节回家首日游

我已经到了阆中了,时间太晚了,
5点灰机到达绵阳南郊机场,取行李墨迹20分钟
然后飞速打车去了平政汽车站,的哥开家50,没有还价,只有一个要求:最快的速度把俺送到平政汽车站,
果然,体验了一把的士时速。5:55到达汽车站,赶上最后一班6:00回南部的车。
21:30到达52队汽车站,等了一会儿,表弟开着车过来接我,半个小时从南部到阆中,
到了酒店20:10的样子,放下包,出去扫街找吃的,时间比较晚
随便找了一个路边小店,吃了一份七星猪脚+加一份炸酱面,
打包的七星猪脚:
七星猪脚
炸酱面:
炸酱面
七星猪脚残骸:
七星猪脚残骸
吃光了七星猪脚的空碗:


我KAO,那叫一个好吃,忍不住堂吃两份份,外加一份打包,
三份: 七星猪脚+炸酱面, 一共36块钱,nnd,那叫一个实惠啊
话说这个酒店真不赖,可以上网,有线的,
趁着机会把手机的蓝牙和笔记本蓝牙配好
回家了也有网上。哇嘎嘎,赶紧睡觉,明天还要忙呢

Del.icio.us :

两个ssh相关的ruby脚本

自从上次存储上面发现一个异常后,禁用不带密码的key。
而且关掉了sudo的nopasswd选项,
这下苦了我们自己,面对成百上千的服务器,需要拷贝个文件啊
或者root权限做个事情啊,那绝对是恶梦。为了拯救自己于恶梦,
利用NET::SSH,写了两个小脚本:

  1. 一个是scp.rb用来拷贝文件的,用法很简单:
    scp.rb hostA:/tmp/afile ./ 或者
    scp.rb afiel hostA:/tmp/afile
  2. 另外一个叫ssh_sudo.rb,看名字就知道,ssh来sudo的,比如:
    ssh_sudo.rb hostA cat /etc/shadow 会在HostA上面执行 cat /etc/shadow

把ssh_sudo.rb中,15行换成:
15 channel.exec(”#{cmd}”) do | ch, success|
就成了普通版的ssh了。这两个可以解决我80%的问题了。剩下20%就根据情况,临阵定夺了

################## scp.rb #####################

#!/usr/local/bin/ruby
require ‘net/scp’
password=”real_password
username=‘real_name’
src=ARGV[0]
dst=ARGV[1]
if ARGV[0] =~ /:/
host,remote_path=ARGV[0].split(”:”)
else
host,remote_path=ARGV[1].split(”:”)
end
Net::SCP.start( host, username, :password => password) do | scp |
if ARGV[0] =~ /:/
scp.download!( remote_path, dst )
else
scp.upload!( src, remote_path )
end
end
################## end scp.rb #####################

######################## ssh_sudo.rb #######################

#!/usr/local/bin/ruby
require ‘net/ssh’
password=”real_password
username=‘real_name’
host=ARGV[0]
cmd=ARGV[1..ARGV.length-1].join(” “)

begin
#Net::SSH.start(host, username, :password=> password, :verbose => :debug ) do | session |
Net::SSH.start(host, username, :password=> password, :timeout=>3 ) do | session |
retry_count=0
session.open_channel do | channel|
channel.request_pty
channel.exec(”sudo #{cmd}”) do | ch, success|
#channel.exec(”echo ‘robert:$xxx.’ | sudo /usr/sbin/chpasswd -e”) do | ch, success|
abort “could not execute command” unless success
channel.on_data do | ch, data |
if data =~ /Password/
retry_count+=1
channel.send_data password+”\n”
else
puts data
end
end
channel.on_extended_data do |ch, type, data|
if data =~ /Password/
retry_count+=1
channel.send_data password+”\n”
end
end
channel.on_close do |ch|
puts “Error for #{host}” if retry_count > 1
end
end
end
end
rescue Exception
$stderr.print “Error: #{$!} on #{host}\n”
end
############# end of ssh_sudo.rb ###################

Del.icio.us : , , , ,

ramfs VS tmpfs

这两种基于内存的文件系统,都可以称为内存盘。只是稍微有些差别:
Mount options for ramfs
Ramfs is a memory based filesystem. Mount it and you have it. Unmount it and it is gone. Present since Linux 2.3.99pre4. There are no
mount options.


Mount options for tmpfs
The following parameters accept a suffix k, m or g for Ki, Mi, Gi (binary kilo, mega and giga) and can be changed on remount.

size=nbytes
Override default maximum size of the filesystem. The size is given in bytes, and rounded down to entire pages. The default is
half of the memory.

nr_blocks=
Set number of blocks.

nr_inodes=
Set number of inodes.

mode= Set initial permissions of the root directory.

从挂载选项中可以看出两者最大的差别: tmpfs有size限制,ramfs没有size限制,换句话说: tmpfs不会耗光内存,因为有大小限制:超过物理
内存的时候会使用swap;而ramfs则有可能耗光物理内存,把机器拖垮,但是好处是会动态增长,适用于无法预估所需内存大小而内存又肯定够用的
情况,比如smarty的template_c;

Del.icio.us : , , ,

Bugzilla书写经验

bugzilla是不错,但是没有WYSIWYG的编辑器,实在寒酸
好在bugzilla的帮助文档中有一个列表,罗列出可链接书写格式的参考。
其中用处最多的就两项,想起了28原则:

comment3 -> comment3

Bug 178148 -> Bug 178148

Issue Linkable References

Linkable References enable the user to automatically link to another issue or comment via signal words. When you enter a linkable reference in the Additional Comments text box, Bugzilla automatically creates a link to that reference in the posted comment. Refer to the following table for the list of linkable entries and their respective signal words.

Note: A word followed by a + sign indicates that multiple words are required. A comma separating words indicates that any of those words work as a signal to Bugzilla. The signal words are not case-sensitive.

Linkable Reference

Single Words (not case sensitive)

Netapp bug

netapp + bug

Netapp case, log or ticket

netapp + case, log, ticket

Netapp Part Number

netapp, newtwork app

Netapp Syslog translator

[A valid syslog output]

CJ Account

ac, cid

FedEx Tracking Number

fedex, tracking

UPS Tracking Number

[A valid UPS tracking number starting with 1Z]

F5 Solution Id

f5 + SOL

RFC

rfc,bcp,std

Cisco Bug Id

[A valid Cisco ID starting with CSC]

Cisco TAC Case

cisco, tac + case,ticket

Cisco RMA

rma

Cisco Error message decoder

[A valid Cisco error message number]

IEEE OUI lookup (mac addresses)

[A valid mac address]

Telnet Command

telnet

Javadocs

[A valid javadoc reference]

Virus Name

[A valid virus name beginning with W32]

Dell Service Tag

[A valid service tag number]

Seagate Part Number

[A valid part number starting with ST]

Mojo Adserver Placement Id

rotation, placement

Del.icio.us : ,

Too many levels of symbolic links

一台server上面碰到比较奇怪的问题,
执行很多命令的时候,老是提示:Too many levels of symbolic links
结果一番调查,实在不得要领,没有任何结果,后来安装ruby的时候
configure无法通过,报错:C compiler cannot create executables
这个问题的出现一般是gcc相关的包比如glibc、kernel-header、之类的包没有安装导致
但是这些包都确认安装过了,
在config.log中发现:

checking for gcc… gcc
checking for C compiler default output file name…
configure: error: C compiler cannot create executables
See `config.log’ for more details.

configure:2525: checking for C compiler default output file name
configure:2552: gcc conftest.c >&5
gcc: error trying to exec ‘as’: execvp: Too many levels of symbolic links

不是C compiler无法创建可执行文件,而是”Too many levels of symbolic links”这个老问题。
后来发现PATH设置有些异常,满屏幕的都是/usr/java/default/bin。 突然想起
这个服务器上面的java安装曾经出现过异常,在/etc/profile中出现了大量重复的
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH
在/usr/java下一查看才发现罪魁祸首所在:default这个死循环的软连接

12/24/09 18:43:39 [ /usr/java ]
—> root@saxxmnt02 (1.84)# ll
total 8
lrwxrwxrwx 1 root root 17 Mar 30 2009 default -> /usr/java/default
lrwxrwxrwx 1 root root 16 Mar 30 2009 latest -> /usr/java/latest
12/24/09 18:43:39 [ /usr/java ]

/u0/gavin/bin:/u0/gavin/local/bin:/usr/kerberos/bin:/usr/java/latest/bin:/usr/local/bin:/bin:/usr/bin:

删掉这个死连接,一切都恢复了。

Del.icio.us :