最新消息:

nagios短信报警

Linux admin 2浏览

今天我才知道在LINUX平台下还有不同的飞信呢!我今天就遇到了,在看http://gzmaster.blog.51cto.com/299556/79944这篇文章Nagios短信报警功能通过飞信实现

原想可以轻松搞定,可是当我看了/usr/local/sms/sms -f 138* -p * -t $1 -m “$2”
哈哈.我傻眼了,我的飞信可不是这样的/usr/local/sms/fetion 而且用法一点都不一样.什么原因呢?不知道,反正不能照抄了,我想有不少朋友也在用我这个飞信的版本,今天拿出来供大家一起学习!

官网地址:http://www.it-adv.net/
下载包地址 LINUX X86/32(REDHAT ES4X32):支持库 最新程序fetion20080522004-linrh4.tar.gz

其中支持库和安装包内容如下:
libraryrh4x32.tar.gz
fetion20080522004-linrh4.tar.gz

tar zxvf libraryrh4x32.tar.gz

libACE-5.6.5.so
libACE_SSL-5.6.5.so
libcrypto.so.0.9.7a
libssl.so.0.9.7a

把支持库复制到/usr/lib/目录下,并作软链接如下:
cp libso /usr/lib/
ln -s /usr/lib/libcrypto.so.0.9.7a /usr/lib/libcrypto.so.4
ln -s /usr/lib/libssl.so.0.9.7a /usr/lib/libssl.so.4

设定lib库配置文件

vi /etc/ld.so.conf

增加一条

/usr/lib/

保存退出后,执行

ldconfig

完成之后测试,安装是否成功;执行

cd install

./fetion -h

Usage:
fetion -h
-h: help
fetion -u mobile -p pwd [-b batchfile] [-EN] [-d]
fetion -u mobile -p pwd [-b batchfile] [-EN] [-d]
-u: Fetion user account(only supports mobile phone No.)
-p: Account password
-b: Batch file name
-d: Debug on and write logs to [mobile]-debug.log
-EN: English

这下看到我的与这位老兄的不同了吧!这也就出现了,我应该如何解决将我的内容发出去????还好有个-b功能.
我们在命令行下试下吧!
vi send.sh
sms xxxxx “Web is down”
./fetion -u xxxx -p xxxx -b send.sh
“正常.” Good!

现在要把它加到nagios里,在commands.conf中定义.

host-notify-by-sms

define command {
command_name host-notify-by-sms
command_line /usr/local/sms/report.sh xxxxxx(收短信的家伙) “Host $HOSTSTATE$ alert for $HOSTNAME$! on ‘$DATETIME$’ ” $CONTACTPAGER$
}

service notify by sms

define command {
command_name service-notify-by-sms
command_line /usr/local/sms/report.sh xxxxxxx(收短信的家伙) “‘$HOSTADDRESS$’ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$” $CONTACTPAGER$
}

大家来看我的report.sh

!/bin/bash

tel=$1
content=$2
echo “sms $tel $content”>/usr/local/sms/batch.sh
echo “quit”>>/usr/local/sms/batch.sh
/soft/sms/fetion -u xxxxxx(发送短信的家伙) -p 061128 -b /usr/local/sms/batch.sh
切记,切记…../usr/local/sms的权限要与web这家伙的权限一样,也就是chow -R nagios:nagios /usr/local/sms
这样在调用我那个batch.sh才能正常,否则会出现Time out的,就是失败啦!
[总结]
不是看了谁的文章都是适合自己的,只有动手去试,才知道合不合适.大家还可以看
http://gzmaster.blog.51cto.com/299556/77135 这篇文章的飞信安装,估计就对应了这篇文章了
http://gzmaster.blog.51cto.com/299556/79944 我没有测试,大家可以试试!做个广告,等下回再写一篇用”用手机控制Linux的文章”哈哈,以前玩过……相关日志Linux ar 命令
Could not open device at /dev/ipmi0
rndc-confgen 没有反应
/dev/random 与 /dev/urandom
使用 ldd 加载动态库

最后编辑: selboo 编辑于2012/03/22 09:56

转载请注明:爱开源 » nagios短信报警