nagios微信报警配置

自作多情 提交于 2020-03-19 12:54:15

==nagios微信报警系统添加流程==
1.编写微信报警脚本
2.编辑/usr/local/nagios/etc/objects/templates.cfg
添加报警源:
define service {
service_description   generic-zzcbj
name    generic-zzcbj
contacts    zzcbj
check_period    24x7
notification_period    24x7
max_check_attempts    1
check_interval    3
retry_interval    1
notification_interval    5
notification_options    w,u,c,r,f
first_notification_delay    0
register    0
active_checks_enabled    1
passive_checks_enabled    1
notifications_enabled    1
}
3.编辑/usr/local/nagios/etc/objects/contacts.cfg
添加报警选项:
define contact {
contact_name    zzcbj
alias    zzcbj
email   mail@example.com
pager    admin
host_notification_period    24x7
service_notification_period    24x7
host_notification_options    d,u,r,f,s
service_notification_options    w,u,c,r,f,s
register    1
host_notification_commands    sendEmail,wei_baojing
service_notification_commands    sendEmail,wei_baojing
}
4.编辑/usr/local/nagios/etc/objects/commands.cfg
添加报警命令:
define command {
command_name    sendEmail
command_line    $USER1$/sendEmail/sendEmail.pl -f "security@intellicredit.cn" -t $CONTACTEMAIL$ -s smtp.mxhichina.com:80 -u "** $HOSTNAME$—— $HOSTNAME$
$HOSTSTATE$ **" -xu security@intellicredit.cn -xp 'Z2h0o1g6n0z4h2i9cheng@' -m "***** New_NAGIOS Notification *****\n\nNotification type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHOSTNAME: $HOSTALIAS$\nIP:$HOSTNAME$\nSTATUS:$SERVICESTATE$\n\nTime: $LONGDATETIME$\n\nSERVICEOUTPUT:\n\n$SERVICEOUTPUT$"}

备注:command_line只有一行

define command {
command_name wei_baojing
command_line $USER1$/wei_baojing.py "通知类型: $NOTIFICATIONTYPE$<br><br>服务: $SERVICEDESC$<br>主机: $HOSTALIAS$<br>IP地址: $HOSTNAME$<br>状态: $SERVICESTATE$<br><br>日期时间: $LONGDATETIME$ <br><br>附加信息:<br><br>$SERVICEOUTPUT$"}

备注:command_line只有一行

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!