Page 3 of 3

Re: Adding contacts and contact groups

Posted: Tue Oct 08, 2019 11:55 am
by madhurima12
But if I run a simple echo hello | mailx [email protected] in the terminal, it does send the email. That must mean postfix is running.

Re: Adding contacts and contact groups

Posted: Tue Oct 08, 2019 12:02 pm
by scottwilkerson
ok, notice you said mailx that is not part of the command you are having nagios use...

Run (from inside the container)

Code: Select all

which mailx
then replace /usr/bin/mail in your commands

restart nagios

But also, are you running that from inside the container?

This is a bit out of our scope as we don't manage containers here....

Re: Adding contacts and contact groups

Posted: Tue Oct 08, 2019 12:07 pm
by madhurima12
Yes, the terminal runs in the container itself.
Yeah I understand that and that is part of the reason why it is so hard to setup a simple contact group cause I cannot find any reference material anywhere. The best bet was to ask you guys.
On running which mailx, the path is /usr/bin/mailx
Where do I have to replace this ?

Re: Adding contacts and contact groups

Posted: Tue Oct 08, 2019 12:35 pm
by scottwilkerson

Code: Select all

# '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$ **" $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$ **" $CONTACTEMAIL$
}