监控配置—对通知的配置
当服务出现问题时,通过email进行通知
1、 配置发送邮件使用的命令
编辑/usr/local/nagios/etc/objects/commands.cfg
默认的输出宏$HOSTOUTPUT$和$SERVICEOUTPUT$只会输出第一行信息, 我们使用$LONGHOSTOUTPUT$和$LONGSERVICEOUTPUT$输出完整信息.
为了能接受到格式化良好, 且中文无乱码的超文本邮件, 可以对sendEmail设置 "-o message-content-type=html -omessage-charset=utf8" 选项.
#'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$LONGHOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/bin/mutt -s "** $NOTIFICATIONTYPE$ HostAlert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' commanddefinition
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\nAdditionalInfo:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /usr/bin/mutt -s "**$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" $CONTACTEMAIL$
}
...
nagiosIan监控页面乱码解决:修改监控主机中/usr/local/apache2/conf最后一行增加
AddDefaultCharset utf-8
修改/usr/local/nagios/etc/cgi.cfg
escape_html_tags=0
使用以下命令重启apache
# /usr/local/apache2/bin/apachectlrestart