LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 07-20-2010, 05:03 AM   #1
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Rep: Reputation: 15
send email notifications in nagios


Hello.

i wanna send email notifications when the servers' services gone down. i have installed nagios successfully in ubuntu 9.10.

in the contacts.cfg, i added this :

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_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 myemail@hotmail.com
}

for the contacts_group in contacts.cfg, i add this :

define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}


for the windows.cfg, i added this:

define host{
use generic-host
host_name qauser-863c2d42
alias qauser-863c2d42
address 172.20.130.71

check_command check-host-alive
max_check_attempts 10

notification_interval 120
notification_period 24x7
notification_options d,u,r
contact_groups admins
notifications_enabled 1
}

in commands.cfg, i changed the /bin/mail to the following:

# '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/mail -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$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

}


i have installed postfix too..

what else am i missing? i cant receive email in my email inbox even though the services of the windows server which i'm monitoring are down...

p/s: i have googled for countless of times..it seems i'm on the right track, but what doesn't it work?

please help, thanks lots.
 
Old 07-20-2010, 07:34 AM   #2
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Hi Wel-come to LQ,

Just install postfix server and set it as satellite mail system and point it to your exchange or SMTP server. This info it will ask during initial installation.

run following command if you want to re-configure postfix
Code:
dpkg-reconfigure postfix
HTH
 
Old 07-20-2010, 08:48 AM   #3
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
How to point it to the SMTP server? i think i got installed smtp in one windows server which i'm currently monitoring.. so i just point to that ip address?

thanks
 
Old 07-20-2010, 08:59 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
How to point it to the SMTP server? i think i got installed smtp in one windows server which i'm currently monitoring.. so i just point to that ip address?
At postfix installation time it asked for relay host. give your smtp server name here.

or you can manual edit your postfix configuration.

Code:
vi /etc/postfix/main.cf

relayhost = smtp.example.com  <=(your smtp server name)
In above example your nagios server use smtp.example.com server to sendmail.
 
Old 07-20-2010, 10:08 AM   #5
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Can ask a stupid question? sorry i'm a noob.

hmm how to check the smtp server name in windows xp sp2? =X

i tried this:

telnet servername portnumber

but can't

Last edited by LayTech; 07-20-2010 at 10:14 AM.
 
Old 07-20-2010, 10:40 AM   #6
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Quote:
i tried this:

telnet servername portnumber

but can't
Are you able to connect on port 25?

for mail server name try below command on linux

Code:
dig example.com MX <= replace example.com with your domain name
It will display mail server entry like

Code:
example.com. 14400 IN MX 0 smtp.example.com
for windows
Code:
open command prompt
c:\>nslookup
>set type=mx <= set query type
>example.com <= enter your domain name
look below link
http://www.tech-recipes.com/rx/381/s...or_open_relay/
 
Old 07-20-2010, 07:55 PM   #7
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sem007 View Post
Are you able to connect on port 25?
Hi,

i got this error when i typed "telnet servername portnumber"

telnet: could not resolve servername/portnumber: Servname not supported for ai_socktype

Hmm okay. i installed smtp server in my ubuntu platform (the one running nagios)

when i typed in "dig server.com MX" i got the following :

Quote:
$ dig server.com MX

; <<>> DiG 9.6.1-P1 <<>> server.com MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63379
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;server.com. IN MX

;; ANSWER SECTION:
server.com. 5 IN MX 0 smtp.secureserver.net.
server.com. 5 IN MX 10 mailstore1.secureserver.net.

;; Query time: 37 msec
;; SERVER: 192.168.142.2#53(192.168.142.2)
;; WHEN: Tue Jul 20 19:02:25 2010
;; MSG SIZE rcvd: 92
And when i tried "telnet 216.69.186.201", i got this error ?

Quote:
name@ubuntu:~$ telnet 216.69.186.201
Trying 216.69.186.201...
telnet: Unable to connect to remote host: Connection refused
layleng@ubuntu:~$ nslookup
> set type=mx
> server.com
Server: 192.168.142.2
Address: 192.168.142.2#53

Non-authoritative answer:
server.com mail exchanger = 0 smtp.secureserver.net.
server.com mail exchanger = 10 mailstore1.secureserver.net.

Authoritative answers can be found from:
smtp.secureserver.net internet address = 216.69.186.201
mailstore1.secureserver.net internet address = 216.69.186.201
> telnet 216.69.186.201 25
Server: 192.168.142.2
Address: 192.168.142.2#53

** server can't find telnet: SERVFAIL

Last edited by LayTech; 07-20-2010 at 09:20 PM.
 
Old 07-21-2010, 03:31 AM   #8
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
Hi,

use server name instead of IP Address.
Code:
telnet smtp.secureserver.net 25
add smtp.secureserver.net in your postfix configuration file (main.cf)

relayhost = smtp.secureserver.net

restart postfix service
/etc/init.d/postfix restart

and send test mail on one emailID.
mail -s "test mail" -v test@emailID

also check log file for error
tail -f /var/log/mail

Let me know if it gives any error.

HTH
 
Old 07-23-2010, 07:08 AM   #9
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Hi HTH,

Hmm, sorry i didn't mention earlier that i did not have a 'proper' (don't know if that is the correct word to use) stmp server. I did install this stmp server online : http://www.softstack.com/freesmtp.html but not sure if it can really be used? Cause my email doesn't get send. My teacher said that stmp server i've installed is not the real/correct server? I don't get, :X

And, i've installed postfix in my ubuntu server.

Anymore things i have to add on or am i missing anything?

Thanks

[Add On]:
The stmp server name..i got it on one of my windows xp server, is it ok? Or should i be using the server name of the ubuntu server which had the nagios installed? Sorry, i know i'm noob :x

And thanks again.

Last edited by LayTech; 07-23-2010 at 08:27 AM.
 
Old 07-23-2010, 09:03 AM   #10
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sem007 View Post
Hi,

use server name instead of IP Address.
Code:
telnet smtp.secureserver.net 25
add smtp.secureserver.net in your postfix configuration file (main.cf)

relayhost = smtp.secureserver.net

restart postfix service
/etc/init.d/postfix restart

and send test mail on one emailID.
mail -s "test mail" -v test@emailID

also check log file for error
tail -f /var/log/mail

Let me know if it gives any error.

HTH
The 'smtp.secureserver.net' you gave as an example is made up of hostname and domain name respectively right? (smtp = hostname; 'secureserver.net = domain name) A stupid question to ask, how to get the domain name? The domain name of which server? Any windows server which i'm currently monitoring or the ubuntu server which had the nagios installed?
 
Old 07-24-2010, 06:34 AM   #11
LayTech
Member
 
Registered: Jul 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Hmm, sorry but could someone help me out? x_x sorry.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] help required with nagios email notifications NewtoUbuntu8.1 Linux - Newbie 13 10-13-2011 03:10 PM
Nagios email notifications don't get sent, need to configure mailx, how? mitchell7man Linux - Server 3 01-26-2010 01:53 PM
[SOLVED] Nagios issues command but wont send email Mistro Linux - Newbie 9 12-30-2009 04:03 PM
[SOLVED] Nagios and Postfix Email Notifications cazter2 Linux - Networking 18 11-19-2009 02:31 PM
Nagios Email notifications jackie001 Linux - Newbie 3 11-14-2008 10:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration