nagios_自定义宏变量隐藏发送邮件账号的敏感信息-创新互联
需求:
成都创新互联公司专注于三门峡企业网站建设,响应式网站设计,购物商城网站建设。三门峡网站建设公司,为三门峡等地区提供建站服务。全流程按需规划网站,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务Nagios在邮件告警的时候使用sendemail来发送邮件。
默认web管理界面下Configuration --> Object Type: Commands -->
notify-host-by-email notify-service-by-email 会显示 发送邮件账户的登录密码
通过:nagios的宏变量来隐藏掉显示出来的密码(自定义宏变量)
vi /usr/local/nagios/etc/resource.cfg
加上
$USER2$=nmelot@163.com $USER3$=123456a
vi /usr/local/nagios/etc/objects/commands.cfg
修改$USER2$和$USER3$部分:
# '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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ 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/sendEmail -f XXX@163.com -t "XX@qq.com,XX@qq.com,XX@qq.com,XXX@qq.com,XX@qq.com, XX@qq.com,XXX@qq.com,XX@qq.com" -s smtp.163.com -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -xu $USER2$ -xp $USER3$ }
# '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$" | /usr/bin/sendEmail -f XXX@163.com -t "XX@qq.com,XX@qq.com,XX@qq.com,XX@qq.com,XX@qq.com,XX@qq.com,XX@qq.com,XX4@qq.com" -s smtp.163.com -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVI CEDESC$ is $SERVICESTATE$ **" -xu $USER2$ -xp $USER3$ # 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$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAI
L$
}
效果如下:红色箭头黑色部分本显示了发送邮件账号的账号以及密码,现在可以通过上述通过nagios的自定义宏变量来隐藏相关的敏感信息。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前题目:nagios_自定义宏变量隐藏发送邮件账号的敏感信息-创新互联
文章起源:http://azwzsj.com/article/jipoh.html