luni, 2 aprilie 2018

Add External SMTP Server for Nagios Notifications

On Centos 6/7

yum install mailx

locate commands.cfg

/usr/local/nagios/etc/objects/commands.cfg

Edit

vi /usr/local/nagios/etc/objects/commands.cfg

and change notify-host-by-email and notify-service-by-email into this:

# '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" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
        }

# '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$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
        }

Niciun comentariu:

Trimiteți un comentariu