linux上nagios3 短信+邮件报警
2010-10-14 17:53
525 查看
前提
已经架设好nagios,并且配置成功,能用邮件报警
我架设的是3.2.3版本,3.2.3版本的配置文件跟以前版本的位置不太一样,需要配置的大部分是在object目录下的文件。
邮件报警其实很简单,启动本机的sendmail服务,在联系人里将自己的邮件添加上就可以
再来说说短信报警,短信报警我使用的是 飞信机器人 http://www.it-adv.net/ ,可以直接用命令行发短信
一。 下载飞信机器人 解压到/usr/local/sms/目录 ,并在此目录编写一脚本duanxin.sh
#!/bin/sh LD_LIBRARY_PATH=/usr/local/sms /usr/local/sms/fetion --mobile=135xxxx2225 --pwd=xxxxxxxx --to=$1 --msg-gb=$2
此脚本的作用是将收短信人的手机号和短信作为参数,具体飞信机器人的命令参数,查看文档。
写好脚本后测试下,如果能受到短信,说明配置成功。
二。飞信机器人配置好后,开始配置nagios,配置文件位置在/usr/local/nagios/etc/object下
首先配置command.cfg
在mail报警代码下边新添加
#mobile define command { command_name host-notify-by-sms command_line /usr/local/sms/duanxin.sh 15012345678 "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$' " $CONTACTPAGER$ } define command { command_name service-notify-by-sms command_line /usr/local/sms/duanxin.sh 15012345678 "$HOSTNAME$/$HOSTADDRESS$/$SERVICEDESC$/$SERVICESTATE$" }
其中15012345678 是收短信的手机号吗, 第二个参数可以自己随便定制, 但是不要有空格存在,空格可以用/代替
这样command.cfg就配置好了
接着再配置 templates.cfg
找到 define contact {。。。} 在默认的“notify-service-by-email ” 和notify-host-by-email 前面 添加command里面配置的 command_name
define contact{ name generic-contact ; The name of this contact template service_notification_period 24x7 ; service notifications can be sent anytime host_notification_period 24x7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands service-notify-by-sms,notify-service-by-email ; send service notifications via email host_notification_commands notify-host-by-sms,notify-host-by-email ; send host notifications via email register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! }
这样就配置完成,重启nagios,有问题就可以收到短信了。
相关文章推荐
- 利用nagios,snmp,监听处理linux下的特定进程和端口,以及邮件短信报警功能 推荐
- nagios部署+短信和邮件报警
- Nagios邮件报警、短信报警配置
- 用escalations.cfg来限制 nagios 邮件 短信 报警发送次数
- Nagios飞信linux系统免费短信报警配置
- 利用Nagios 实现监控Linux/Windows及短信报警的总结
- linux mail 使用外部smtp服务器实现nagios邮件报警
- Nagios飞信linux系统免费短信报警配置
- nagios搭建和邮件短信报警设置
- Nagios飞信linux系统免费短信报警配置
- nagios服务器搭建实现对Linux和windows主机监控及短信报警
- Nagios飞信linux系统免费短信报警配置
- Nagios飞信linux系统免费短信报警配置
- nagios-3种报警方式–声音–email/邮件—短信
- nagios添加139邮件短信通知报警
- 利用Nagios 实现监控Linux/Windows及短信报警的总结
- yum搭建nagios监控linux&&window及邮件报警
- 网络监控软件Nagios, Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报
- nagios 整合 ganglia 设置邮件、短信报警
- nagios 使用 sendEmail 发送报警邮件