Demand:
Nagios uses SendEmail to send messages when the message is alerted.
The default Web management interface is under configuration---Object type:commands--
Notify-host-by-email Notify-service-by-email will display the login password of the sending email account
By: Nagios macro variable to hide the displayed password (custom macro variable)
Vi/usr/local/nagios/etc/resource.cfg
Plus
[Email protected] $USER 3$=123456a
Vi/usr/local/nagios/etc/objects/commands.cfg
Modify the $user2$ and $user3$ sections:
# ' Notify-host-by-email ' command definitiondefine 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 [email protected] -t "[email protected],[ email protected],[email protected],[email protected],[email protected],[email Protected],[email protected],[email protected] " -s smtp.163.com -u " ** $ notificationtype$ host alert: $HOSTNAME $ is $HOSTSTATE $ ** " -xu $USER 2 $ -xp $USER 3$ }
# ' 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 [email protected] -t "[email protected],[email protected], [email protected],[email protected],[email protected],[email protected],[email Protected],[email protected] " -s smtp.163.com -u " ** $NOTIFICATIONTYPE $ Service Alert: $HOSTALIAS $/$SERVICEDESC $ is $SERVICESTATE $ ** " -xu $ user2$ -xp $USER 3$# 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$
}
The effect is as follows: The red Arrow Black section shows the account number and password of the sending email account, which can now be used to hide sensitive information through Nagios's custom macro variables.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/B2/wKiom1ZAcIjAykwyAAI5uYmMuRI911.png "title=" QQ picture 20151109180748.png "alt=" Wkiom1zacijaykwyaai5uymmuri911.png "/>
This article from "Rusty Old Gun _ Technology blog" blog, reproduced please contact the author!
NAGIOS_ Custom Macro variables hide sensitive information for sending mail accounts