nagios_自定义宏变量隐藏发送邮件账号的敏感信息

需求:

创新互联建站2013年开创至今,先为太仓等服务建站,太仓等地企业,进行企业商务咨询服务。为太仓企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

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的自定义宏变量来隐藏相关的敏感信息。

nagios_自定义宏变量隐藏发送邮件账号的敏感信息


分享题目:nagios_自定义宏变量隐藏发送邮件账号的敏感信息
分享链接:http://hbruida.cn/article/gdiodh.html