Hello all -
I have a question regarding nagios notifications. At this point, I have everything working with nagios that I want to so far and want to start sending notifications via e-mail. I am new to nagios as well as Linux system admin so please don't shun me if I ask a newbie sort of question. If so, just point me in the right direction.
Ok here goes. . . I am getting the notifications using the default mail command script for hosts and services. Those notifications are going to the "nagios-admin" user on the localhost. Here is the snippet of minimal.cfg file that I am using that defines the contact_groups, host-groups, e-mail address etc..
This defines a timeperiod where all times are valid for checks,
notifications, etc. The classic "24x7" support nightmare.
alias 24 Hours A Day, 7 Days A Week
This is a sample service notification command that can be used to send email
notifications (about service alerts) to contacts.
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$OUTPUT$" | /bin/mail -s " $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
This is a sample host notification command that can be used to send email
notifications (about host alerts) to contacts.
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $OUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$
In this simple config file, a single contact will receive all alerts.
This assumes that you have an account (or email alias) called
"nagios-admin" on the local host.
alias Nagios Admin
We only have one contact in this simple configuration file, so there is
no need to create more than one contact group.
alias Nagios Administrators
We only have one host in our simple config file, so there is no need to
create more than one hostgroup.
alias Test Servers
Anyway, with that configution, I am getting mail to the nagios-admin on the localhost.
I want to be able to get mail to an external e-mail address so I've made some simple changes to the configuration file that I've posted using that e-mail address. I don't get anything.
So, I've tried to e-mail my external address using the following command.
printf "%b" "Testing" | mail -s "Testing" email@example.com
I received the mail message.
I tried this as the root user as well as the nagios user and it worked both ways.
My question is, if this command works from the command line, and I can get the mail to my external address using that command, why am I not getting the notifications to this address when I switch the e-mail address in the minimal.cfg file?
It seems that there is a problem with the config file.
Please advise. All suggestions are greatly appreciated. : )