CentOS 6.3x86_64编译安装Nagios:
nagios 默认发邮件配置更改为
复制代码代码如下:
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/bin/mutt -F "/usr/local/nagios/etc/objects/muttrc" -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } 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/bin/mutt -F "/usr/local/nagios/etc/objects/muttrc" -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ }
查看ngaios.log
复制代码代码如下:
echo "message" | mutt -F /usr/local/nagios/etc/objects/muttrc -s "Test abc $(data +%s)" admin@i-david.org
邮件发送正常。
备注:
这两个目录都给nagios用户能读写权限即可 是nagios这个用户,后台执行mutt,发送邮件有问题 验证理由 在nagios用户下crontab -e echo OK | mutt -s "Test" admin@i-david.org 未收到东西 定时任务已经执行,有log验证。 (责任编辑:IT) |