Nagios报警利器SendEmail

  • A+
所属分类:Zabbix 监控

下载安装:

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

tar zxf sendEmail-v1.56.tar.gz

cd sendEmail-v1.56/

cp sendEmail /usr/local/bin 

chmod 0755 /usr/local/bin/sendEmail

chown nagios:nagios /usr/local/bin/sendEmail

使用测试1:

/usr/local/bin/sendEmail -f liuyalei126@126.com -t lyl@chzh.cn -s smtp.126.com -u "nagios test" -m "neirong" -xu liuyalei126@126.com -xp liuyalei123456

使用测试2:

/usr/local/bin/sendEmail -f nagios@localhost.localdomain -t lyl@chzh.cn -u "nagios test" -m nagios-test

参数解释:

-f 表示发送者的邮箱
-t 表示接收者的邮箱
-s 表示SMTP服务器的域名或者ip
-u 表示邮件的主题
-xu 表示SMTP验证的用户名
-xp 表示SMTP验证的密码(注意,这个密码貌似有限制,例如我用d!5neyland就不能被正确识别)
-m 表示邮件的内容
-cc 表示抄送
-bcc 表示暗抄送

这个跟我们的nagios发件方式类似,下面我们来改nagios的发件方式

# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f liuyalei126@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu liuyalei126@126.com -xp liuyalei12345678

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f liuyalei126@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu liuyalei126@126.com -xp liuyalei12345678

YaLei

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: