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. |
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 |
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 |
Quote:
or you can manual edit your postfix configuration. Code:
vi /etc/postfix/main.cf |
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 |
Quote:
for mail server name try below command on linux Code:
dig example.com MX <= replace example.com with your domain name Code:
example.com. 14400 IN MX 0 smtp.example.com Code:
open command prompt http://www.tech-recipes.com/rx/381/s...or_open_relay/ |
Quote:
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:
Quote:
|
Hi,
use server name instead of IP Address. Code:
telnet smtp.secureserver.net 25 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 |
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. |
Quote:
|
Hmm, sorry but could someone help me out? x_x sorry.
|
All times are GMT -5. The time now is 02:46 PM. |