1.使用SMTP发送邮件
objects/commands.cfg中有邮件提醒命令的设置
如要通过SMTP发送邮件,可以使用sendEmail:
http://caspian.dotconf.net/menu/Software/SendEmail/
安装
wgethttp://caspian.dotconf.net/menu/...
dEmail-v1.55.tar.gz
tar zxvf sendEmail-v1.55.tar.gz
mv sendEmail-v1.55/sendEmail /usr/local/bin/
发送邮件的示例:
sendEmail -fnagios@test.com-tadmin@test.com-s
smtp.test.com -u "test" -xunagios@test.com-xp
password -m "test."
vi objects/commands.cfg
把notify-host-by-email和notify-service-by-email的邮件发送部分改为:
1./usr/local/bin/sendEmail
-fnagios@test.com -t $CONTACTEMAIL$ -s smtp.test.com -u"$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" -xu nagios@test.com -xppassword
复制代码
2.发送MSN提醒
这里有个perl写的程序:
http://blog.chinaunix.net/u/24312/showart_1076329.html
yum install perl-XML-Simple
yum install perl-Hash-Merge
perl -MCPAN -e 'install Net::MSN'
cd msn
修改一下hello.pl的$handle和$password
chmod +x hello.pl
把发送者和接收者互相加为好友,然后发个测试信息试试:
./hello.pladmin@test.comhello
第一次运行时发现这样的错误提示:
could not find ParserDetails.ini in/usr/lib/perl5/vendor_perl/5.8.5/XML/SAX
在这里有相关说明:
http://perl-xml.sourceforge.net/faq/#parserdetails.ini
执行
perl -MXML::SAX -e"XML::SAX->add_parser(q(XML::SAX:urePerl))->save_parsers()"
mkdir /usr/local/nagios/lib
mv lib /usr/local/nagios/lib/msn
chown -R nagios:nagios /usr/local/nagios/lib
vi msn_send.pl
#!/usr/bin/perl
use lib "/usr/local/nagios/lib/msn";
my $handle = 'nagios@live.cn';
my $password = 'password';
chown nagios:nagios msn_send.pl
chmod +x msn_send.pl
mv msn_send.pl /usr/local/nagios/libexec/
添加MSN提醒执行的命令:
vi /usr/local/nagios/etc/objects/commands.cfg
1.define
command{
2.
command_name notify-host-by-msn
3.
command_line /usr/local/nagios/libexec/msn_send.pl$CONTACTEMAIL$ "`/usr/bin/printf "%b" "***** Monitor*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n"`"
4.
}
5.define
command{
6.
command_name notify-service-by-msn
7.
command_line /usr/local/nagios/libexec/msn_send.pl$CONTACTEMAIL$ "`/usr/bin/printf "%b" "***** Monitor*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost:$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:$LONGDATETIME$\n\nAdditional
Info:\n\n$SERVICEOUTPUT$"`"
8.
}
复制代码
使用中发现,需要回复了才能终止进程,不然check就无法继续,而且是所有其它host和service的check都无法继续了。
作者说需要把接收报警的人加为好友,可是的确是加为好友了的。但据说是可以设置超时时间的。
如果有可以运行PHP的Web服务,用PHP发送MSN信息是个简单的办法:
http://www.fanatic.net.nz/2005/02/15/send-a-message-using-php/
安装
wgethttp://downloads.fanatic.net.nz/dev/php/sendMsg.zip
unzip sendMsg.zip
mv sendMsg /path/to/web/dir/msn
配置
默认的验证提交方式需要ssl支持,用curl的(需要在编译PHP时加上--with-curl):
vi sendMsg.php
require_once('msnpauth-1.1.3.php');
发送中文需要先用iconv将字符集转为UTF-8:
vi index.php
$sendMsg->sendMessage(iconv("GBK","UTF-8", $_POST['message']), 'Times New Roman', '008000');
同样需要把发送者和接收者互相加为好友。
可以先打开http://server/msn/index.php测试一下能否发送。如果没有问题,可以写一个脚本来执行MSN信息发送命令:
vi /usr/local/nagios/libexec/msn_send.sh
1.#!/bin/sh
2.wget
-O - -q--post-data="sender=nagios@live.cn&password=password&recipient=$1&message=$2"http://server/msn/index.php> /dev/null
复制代码
chmod +x /usr/local/nagios/libexec/msn_send.sh
再把前面设置的MSN提醒命令中的msn_send.pl改为msn_send.sh就可以使用了。
3.发送短信提醒
简单的,在www.139.com注册移动的邮箱,设置邮件短信提醒。这样就可以发送邮件的标题到注册的手机号码上。
还有利用飞信实现的:
http://www.it-adv.net/
依赖glibc-2.4。CentOS4/RHEL4,
Debian Etch不能使用。
安装所依赖的库:
tar zxvf lib.tar.gz
mv lib /usr/local/lib/fetion
echo "/usr/local/lib/fetion" >/etc/ld.so.conf.d/fetion-i386.conf
ldconfig
再安装飞信的命令行客户端:
tar zxvf fetion_linux_20080402.tar.gz -C/usr/local/bin/
vi /usr/local/bin/sms.sh
1.#!/bin/sh
2./usr/local/bin/sms
-f 159xxxxxxxx -ppassword -t $1 -m "$2"
复制代码
chmod +x/usr/local/bin/sms.sh
和添加MSN提醒命令一样添加短信提醒的命令就可以了。
Debian Etch可以升级到testing,glibc也就更新到2.4了。
sed-e 's|etch|testing|g'/etc/apt/sources.list > /etc/apt/sources.list~
mv /etc/apt/sources.list~/etc/apt/sources.list
apt-get update
apt-get dist-upgrade
作者:bluedata来源:http://blog.bluedata.org/nagios-notification-type/
分享到:
相关推荐
My Fetion 实现PC客户端通过FETION WEB URL 发送短信
一)使用说明 ...1. 利用socket模拟登录wap版飞信,并模拟发送飞信,好处是不会有验证码,也比较稳定。 (三)其他 1. wap飞信登录地址:http://f.10086.cn 2. 作者博客:http://blog.quanhz.com
最新版本(v1.2): http://code.google.com/p/php-fetion/downloads/detail?name=phpfetion_v1.2.0.zip (飞信类文件名改为了PHPFetion.php,使用的时候也可以随时修改为你需要的名字,类名也可以修改) 所有版本:...
飞信3.0修改版,窗口优化和加入了震动的功能,不错的软件!
fetion服务端(windows\linux)、PHP短信发送模块 (附:数据字典)
使用方式再贴一遍: //包含飞信类文件 require 'PHPFetion.php'; //实例化,参数为发送人手机号、飞信密码 $fetion = new PHPFetion('13500001111', '123123'); //接收人手机号、飞信内容 $fetion->send('...
final Fetion fetion = new Fetion("phone","password"); fetion.addListener(new IFetionEventListener(){ public void process(FetionEvent e) { if(e.getFirstLine()!=null && e.getFirstLine...
fetion mrp
基于PHP的Fetion 飞信发送类.zip
linux版fetion_for x64,可以发短信给手机
final Fetion fetion = new Fetion("phone","password"); fetion.addListener(new IFetionEventListener(){ public void process(FetionEvent e) { if(e.getFirstLine()!=null && e.getFirstLine().startsWith("M...
基于PHP的Fetion飞信发送类源码.zip
fetion(飞信) for linux
Fetion_3.4.3_ty.jar
移动公司通信软件 飞信 fetion_2008
FetionService 通过FETION实现定时发送天气预报的功能
php版fetion类,压缩包中有vs_fetion(socket版).class.php和vs_fetion.class.php两个文件,视实际情况使用,协议是一样的,只是使用的php扩展不同,一般来说vs_fetion.class.php的兼容性更好一些。
Fetion2011MayFetion2011May
用C++实现的简单飞信客户端,简单的SIP协议
Fetion2008Fetion2008Fetion2008Fetion2008Fetion2008Fetion2008Fetion2008Fetion2008Fetion2008