Hunter
2013年3月15日 星期五
2010年7月15日 星期四
Linux-關閉開機時自動FSCK
vi /etc/fstab
/dev/disk/by-id/scsi-36001438005df72450000800000070000-part1 /Log01_Archive ext3 acl,user_xattr 1 0
將最後一位數字改為0
2010年7月14日 星期三
Nagios to Mail to SMS Script
#!/bin/bash
#cat > /tmp/nagiosalert.tmp
#kill minicom process
cd ~
#Add mobile phone NO.
phone=(0123456789 09123456789)
#Nagios alert messages
SOURCE_IP=$(cat /tmp/nagiosalert.tmp |grep Address |cut -d: -f 2)
SOURCE_IP=`sed -n '/Address/s/Address://p' /tmp/nagiosalert.tmp`
DIP=`sed -n '/Address/s/Address://p' /tmp/nagiosalert.tmp`
SOURCE_USER_NAME="Nagios"
SOURCE_HOST_NAME=`sed -n '/Host/s/Host://p' /tmp/nagiosalert.tmp`
DTSTR=`date`
ET=$(date -d "$DTSTR" +%F~%T~24~+0800)
DEVICE_EVT_TIME=$(date -d "$DTSTR" +%s)000
#MESSAGE="Device=$SOURCE_HOST_NAME,IP Address=$SOURCE_IP.Device Down"
MESSAGE="Alert Messages!!Host is $SOURCE_HOST_NAME,IP Address is $SOURCE_IP.Host Down or Unreachable!!"
#check sms.txt , if sms.txt exit,the script sleep 30 second, if sms.txt not exit , the will keep going..
while [ -e /tmp/sms.txt ]
do
sleep 30
done
#send sms messages, each messages will delay 5 second!
echo $MESSAGE > /tmp/sms.txt
for ((i=0; i<${#phone[@]}; i++)); do
echo -en "AT+CMGF=1\r" > /dev/ttys0
echo -en "AT+CMGS=\"${phone[$i]}\"\r" > /dev/ttyS0
echo -en "$MESSAGE \032" > /dev/ttyS0
sleep 5
done
rm -rf /tmp/sms.txt
exit
Backup Cacti and Nagios
#!/bin/sh
date=`date +%Y-%m-%d`
#backup cacti
tar -czvf /backup/"$date".cacti.tar.gz /srv/www/htdocs/cacti
yes | mysqldump -uroot -pnovellTW -l --add-drop-table cacti > /backup/"$date".mysql.cacti
#backup nagios
tar -czvf /backup/"$date".nagios-cfg.tar.gz /etc/nagios
tar -czvf /backup/"$date".nagios-web.tar.gz /usr/share/nagios
#yes | mysqldump -uroot -pnovellTW -l --add-drop-table nagios > /backup/"$date".mysql.nagios
關閉FSCK
tune2fs -l /dev/sda1
...
Mount count: 2
Maximum mount count: 25
...
To turn off this check set the maximum count to 0 with the '-c' option.
# tune2fs -c 0 /dev/sda1
If you do not want to completely disable the file system checking, you can also increase the maximum count.
# tune2fs -c 100 /dev/sda1
####
tune2fs -c 0 -i 0d /dev/xxxx
Iptable redirector
iptables -t nat -A PREROUTING -p udp --destination-port 514 -j REDIRECT --to-ports 1514