顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2012年12月21日 星期五

活用fping監控大量機器的狀態

由於需要管理手中機器的存活狀態,找到了fping這個方便的指令來做這件事情,把需要監控的機器IP寫在一份.txt檔案中,格式如下:

100.65.206.219
100.65.206.220
100.65.206.221
100.65.206.222
100.65.206.223

接著執行這行指令,我在後面加上了

grep unreachable
是因為我只需要知道掛掉的機器是哪些,其中 -r 這個參數是retry的次數, -t 是timeout的長度(in millisec)。
# -r: retry count
# -t: timeout interval (in millisec)
sudo fping -f ip.txt -r 2 -t 50 | grep unreachable
當然,fping不只如此,他還可以指定要掃描的起始IP跟結束IP,或者是指定子網路遮罩。
fping -g 100.65.206.219 100.65.206.223
fping -g 100.65.206.0/24

2012年12月19日 星期三

開機時mount Samba drive

修改/etc/fstab,加入下面的描述,其中_netdev是非常重要的設定,它會等到網路功能開啟之後,才將這個Samba drive mount上去
//${SAMBA_IP}/${SAMBA_FOLDER}  ${PATH_TO_MNT}    cifs    guest,_netdev   0 0

2012年7月26日 星期四

加入ssh login速度

只要把UseDNS關掉,登入速度就可以馬上變快!
sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
service sshd restart
Reference: UNIX&LINUX

2011年5月24日 星期二

How to disable filesystem cache

#To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
#To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
#To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches

#REMEMBER sync
sync
Reference: Linux Questions

2011年4月12日 星期二

Power on/off/cycle using ipmi

ipmitool -U admin -P admin -H 12.200.81.42 chassis power [on|off|cycle]
Reference: George

2011年3月10日 星期四

#!/bin/sh
# Author: Norman
ARRAY=( Frank   1.2.3.4 \
        Norman  1.2.3.5 )
SYSTEM=`uname -s`
LOG=/tmp/wn_ntpdate.log.$$
i=0
while [ $i -lt 3 ] ; do
        NAME=${ARRAY[$i]}
        IP=${ARRAY[$i+1]}
        echo -n $NAME $IP ' '
        case $SYSTEM in
        Linux)
                ping -c 1 $IP 1> $LOG 2>&1
                ;;
        CYGWIN*)
                ping $IP 64 1 1> $LOG 2>&1
                ;;
        *)
                exit 1
                ;;
        esac
        if [ $? -eq 0 ] ; then
                case $SYSTEM in
                CYGWIN*)
                        grep "100.0% packet loss" $LOG 1> /dev/null 2>&1
                        if [ $? -eq 0 ]; then
                                echo failed
                        else
                                echo ok
                                scp wn_ntpdate.sh wn_ntpdate.cron test@$IP:/home/test/workspace
                                echo "Executing ntpdate command..."
                                ssh test@$IP 'sudo sh /home/test/workspace/wn_ntpdate.sh'
                                ssh test@$IP 'sudo rm -f /home/test/workspace/wn_ntpdate.sh'
                                ssh test@$IP 'sudo mv /home/test/workspace/wn_ntpdate.cron /etc/cron.hourly'
                                echo "#####" [$NAME:$IP] RS Test Environment \(Worker Nodes\) ntpdate Sucess "#####"
                                echo ""
                        fi
                        ;;
                Linux)
                        echo ok
                        scp -q wn_ntpdate.sh wn_ntpdate.cron test@$IP:/home/test/workspace
                        echo "Executing ntpdate command..."
                        ssh test@$IP 'sudo sh /home/test/workspace/wn_ntpdate.sh'
                        ssh test@$IP 'sudo rm -f /home/test/workspace/wn_ntpdate.sh'
                        ssh test@$IP 'sudo mv /home/test/workspace/wn_ntpdate.cron /etc/cron.hourly'
                        echo "#####" [$NAME:$IP] RS Test Environment \(Worker Nodes\) ntpdate Sucess "#####"
                        echo ""
                        ;;
                *)
                        exit 1
                        ;;
                esac
        else
                echo failed.
                echo ""
        fi
        ((i++))
        ((i++))
done
#rm -f $LOG
exit
Reference: Norman

2011年1月5日 星期三

Turn off firewall and SELinux on Centos 5.5

# disable selinux
setenforce 0

# disable firewall
/etc/init.d/iptables stop