飞信机器人在linux系统管理中的应用
今天逛www.bsdlover.cn 看到一篇关于飞信机器人的文章
飞信机器人官方网站:
http://www.it-adv.net/
闲话少叙,开始飞信之旅。
OS: CentOS5 (x86_64)
1 下载
http://www.it-adv.net/index.php?action=downloads
wget http://www.it-adv.net/fetion/library32.rar
wget http://www.it-adv.net/fetion/download/fetion20080910048-linux.tar.gz
2 添加必须的库
解压 unrar e library32.rar /usr/lib/
ldconfig -v | grep ACE |
应该有如下显示:
libACE.so.5.4.7 -> libACE.so.5.4.7
libACE_SSL.so.5.4.7 -> libACE_SSL.so.5.4.7
3 tar xvzf fetion20080910048-linux.tar.gz
mv install /usr/local/fetion
cd /usr/local/fetion ; ./fetion -u 手机号 -p 密码
安装完成
联合其他脚本
目标:我要检测磁盘情况,防止有些磁盘被占满。当然了,quota可以做到。
假设我没作quota
我写的脚本
/srv/check_disk.sh
#!/bin/bash
#
#
# Check the Harddisk usesage and warnings
# Author: xfsuper@gmail.com
# Date: 2008/11/5
#
# Warninglimit is 2G default
# lowlimit is 1G default
warninglimit=2000000
lowlimit=1000000
filesystems=`df -h | awk ‘{print $1}’ |grep /dev`
for fs in $filesystems
do
size=`df -k $fs |grep $fs |awk ‘{ print $4; }’`
if [ $size -lt $lowlimit ]; then
size=$((size/(1024*1024)))
echo “URGENT: Low disk space for $fs in $HOSTNAME,Now it is $size G only” >/tmp/disk_check
echo “sms 158XXXX3553 URGENT: Low disk space for $fs in $HOSTNAME,Now it is $size G only” > /tmp/send_urg
echo “exit” » /tmp/send_urg
####### send settings
mail -s “URGENT: Low disk space for $fs in $HOSTNAME,Now it is $size G only” -c xfsuper@gmail.com xfsuper@gmail.com.com < /tmp/disk_check
/usr/local/fetion/fetion -u 158XXXX3553 -b /tmp/send_urg -p XXXXX
break
fi
if [ $size -lt $warninglimit ]; then
size=$((size/(1024*1024)))
echo “Warning: Low disk space for $fs in $HOSTNAME,Now it is $size G only” > /tmp/disk_check_warn
echo “sms 158XXXX3553 Warning: Low disk space for $fs in $HOSTNAME,Now it is $size G only” > /tmp/send_warn
echo “exit” » /tmp/send_warn
mail -s “Warning: Low disk space for $fs in $HOSTNAME,Now it is $size G only” -c xfsuper@gmail.com xfsuper@gmail.com.com < /tmp/disk_check_warn
/usr/local/fetion/fetion -u 158XXXX3553 -b /tmp/send_warn -p XXXXX
fi
done