LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 11-13-2008, 05:12 AM   #1
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Rep: Reputation: 0
Nagios Email notifications


Hi experts,
I have set up Nagios 3 monitoring some machines and their services. I am now trying to set up email notifications.
I have installed the following on the linux box:
eSMTP- run
procmail
I can send emails with the following line:
echo "test" | /usr/bin/esmtp - C ~/esmtprc me@outsideemailaddress - f me@internalemailaddress
This sends me an email from our mail server. However when i try:
mailx -s tacos myemail@email.com
this just hangs.

The commands.cfg files contains:
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotificatio$... | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host...
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotificatio$... | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host
}


Can i make modifications to these commands to use esmtp and not mailx or any suggestions to getting mailx working with eSMTP.
Also how can you force nagios to send email notifications for testing.

Thanks for any advice
 
Old 11-13-2008, 07:51 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
Sure you can modify notify-host/service-by-email command_line entry.
Code:
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotificatio$... |  /usr/bin/esmtp -C /full/path/to/nagios/esmtprc_file - f nagios@yourdomain.com
I don't have eSMTP server installed, so I don't recall right now the option to subject. Check eSMTP man page and add it to the end of command, just after -f nagios@yourdomain.com and use the same subject string from original mailx.

Don't forget to restart your nagios after that.
 
Old 11-13-2008, 01:54 PM   #3
williebens
Member
 
Registered: Jan 2008
Posts: 88

Rep: Reputation: 16
Hello jackie001:

If you get this to work, please let me know. I am stuck in getting nagios to send notifications.

Thanks.
 
Old 11-14-2008, 10:58 AM   #4
jackie001
LQ Newbie
 
Registered: Nov 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the response.
For esmtp there is no sytax to use a subject line so i has to leave out -s and the following lines.
I checked the syntax at the command line and it works! thanks so much. The file now reads:

# '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/esmtp -C /etc/esmtprc $CONTACTEMAIL$ -f nagios@dpd.ie -X /tmp/esmtp.log
}

# '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$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/esmtp -C /etc/esmtprc $CONTACTEMAIL$ -f nagios@dpd.ie -X /tmp/esmtp.log
}




However i still dont recieve emails! The mistake must lie in the config files. Ive been over and over these files maybe you could have a quick look it might be a simple mistake. everything compiles correctly and the web interface is working perfectly.
The windows.cfg contains the following, all of the host , hostgroup and service definitions are basically the same. Should i also add lines to the host definition like notifications_enabled 1 etc.Is it enough fro it to be in the services definition and the contacts.cfg file


define host{
use windows-pcs ; Inherit default values from a template
host_name invoicepc ; The name we're giving to this host
alias invoicingpc ; A longer name associated with the host
address x.x.x.x ; IP address of the host
}
define hostgroup{
hostgroup_name windows-pcs ; The name of the hostgroup
alias Windows PCs ; Long name of the group
members invoicepc
}
define service{
use generic-service
hostgroup_name windows-pcs
service_description Uptime
check_command check_nt!UPTIME
contact_groups admins
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 1440
notification_period 24x7
}

The contacts.cfg file reads:
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7
service_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email x@email.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios notifications for a host problem cmx08 Linux - Software 1 07-20-2011 07:35 AM
nagios & SMS notifications. mastrboy Linux - Software 4 03-21-2010 09:44 AM
Nagios e-Mail notifications netmaster3620 Linux - Newbie 1 07-01-2008 07:33 PM
Nagios notifications nuganen Linux - Newbie 1 06-20-2008 02:13 PM
E-mail notifications not working with nagios hondo Linux - Server 3 10-28-2007 12:42 PM


All times are GMT -5. The time now is 03:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration