您好,登錄后才能下訂單哦!
需求:
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的自定義宏變量來隱藏相關的敏感信息。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。