Im running Nagios 3.0.5. Everything seems to work as it is supposed to work except notifications by email
im trying to emulate a network problem to get nagios sending me notifications, but he doesn’t.
my configs are correct. i doublechecked them many times
here is what nagios logs say:
nagios.debug
[1228097276.246451] [032.0] [pid=28538] Notification viability test failed. No notification will be sent out.
[1228097286.213921] [032.0] [pid=28538] ** Service Notification Attempt ** Host: ‘******’, Service: ‘FastEthernet0/2’, Type: 0, Options: 0, Current State: 0, Last Notification: Thu Jan 1 03:00:00 1970
when i try to Send custom service notification from web interface it works just fine
[1228097761.077984] [032.2] [pid=28538] Raw notification command: /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$
[1228097761.078084] [032.2] [pid=28538] Processed notification command: /usr/bin/printf “%b” " Nagios ***\n\nNotification Type: RECOVERY\nHost: NAS\nState: UP\nAddress: 1.1.1.1\nInfo: PING OK - Packet loss = 0%, RTA = 6.53 ms\n\nDate/Time: Mon Dec 1 05:16:01 MSK 2008\n" | /usr/bin/mail -s " RECOVERY Host Alert: NAS is UP *" @.
Does this happen with all notifications or just email notifications (perhaps you have sms notifications)?
Have you enabled notifications in nagios.cfg?
Have you checked the path to mail program that is set in commands.cfg? Try to issue those commands in terminal and see what you get as a response?
I have only email notifications. The path to mail program is correct. And notificanions are enabled in cgi.cfg
They are even sent to my email address when I issue command “Send custom service notification” from web interface.
Could you post here any of your host/service definitions for which you expect notifications. And if you’re using templates, post the template definitions also.
Post the contact and contactgroup definitions also, so we could examine all in a one-go.
i meant nagios.cfg and thanks a lot for helping me :))
here is an excerpt taken from my templates.cfg
Generic contact definition template - This is NOT a real contact, just a templ
define contact{
name generic-contact ; The name of th
service_notification_period 24x7 ; service notifi
host_notification_period 24x7 ; host notificat
service_notification_options w,u,c,r,f,s ; send notificat
host_notification_options d,u,r,f,s ; send notificat
service_notification_commands notify-service-by-email ; send service n
host_notification_commands notify-host-by-email ; send host noti
register 0 ; DONT REGISTER
}
define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JU
}
define host{
name generic-switch ; The name of this host template
use generic-host ; Inherit default values from th
event_handler_enabled 1 ;
notifications_enabled 1 ;
check_period 24x7 ; By default, switches are monit
check_interval 1 ; Switches are checked every 5 m
retry_interval 1 ; Schedule host check retries at
max_check_attempts 5 ; Check each switch 10 times (ma
check_command check-host-alive ; Default command to che
notification_period 24x7 ; Send notifications at any time
notification_interval 2 ; Resend notifications every 30
notification_options d,r,u,f,s ; Only send notifications for sp
contact_groups admins ; Notifications get sent to the
register 0 ; DONT REGISTER THIS - ITS JUST
}
switch.cfg
define host{
use generic-switch
host_name SLT1
alias Catalys 2960
address 192.168.5.3
hostgroups switches
parents SPC2
contact_groups admins
}
contacts.cfg
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact tem
service_notification_commands notify-service-by-email ;
host_notification_commands notify-host-by-email ;
alias Nagios Admin ; Full name of user
email my email is here ; <<***** CHANGE THIS TO YOUR EMAIL ADDRE
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
nagios is installed on freebsd box and Im trying to use ipfw to emulate network problem. Nagios shows that the problem exists that interface is down but it doesnt send any notifications by email.
on the other hand yesterday when I was off work we had a real problem with one of our ISP, and two ports on the swtich( its definion I posted above ) actually went down and today I have my mailbox full of nagios messages. but still not sure if it works correctly because there should not be diffrenece between actual problem and ipfw denial rule.
one more question arise.
I have a router which have two interfaces
Gig0/1 192.168.1.1
Gig0/2 192.168.2.1
switch.cfg
define host{
use generic-router
host_name NAS
address 192.168.1.1
etc.
}
and i have check_ping
and check_ifoperstatus
for two interfaces
this way eveything works allright
but when I try to add this line to the config
address 192.168.1.1, 192.168.1.2
check_ifoperstatus stops working.
is there any way i can ping both interfaces on a router?
Every example you’ve provided that hadn’t send notifications is a service problem. Pls, post service definition and service template you’re not getting notifications for. Maybe notification options for those services are not defined properly, or some other variable in it.
Another thing. I see you have flapping detection enabled. Are you sure the services/hosts for which you’re trying to get notification aren’t in flapping state? If they are, then notifications are suppressed.
For your second question. You can’t specify two IP addresses for one host definition. One host definition = one IP address. The same thing for services, although you can have service template, but still you have to define service twice, for each of the hosts. With two separate host definitions you can monitor both interfaces.
If you reach that router just through one IP address, then it is enough for you to define one host only with that IP, and then define two check_ping services for that host, and each of those would monitor it’s IP address. If you’re reaching the router through both IP addresses then you can make two host definitions as mentioned above or write a script that would check both IPs, and if first fails, and second is ok, make a Warning alert, if both are down, nake a Critical.
Combination on how you will achieve this depends on how your network is configured and what exactly are you trying to monitor.
define service{
name generic-service ; The ‘name’ of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service ‘freshness’
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 2 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 2m ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}
service definition
define service{
use generic-service ; Inherit values from a template
host_name NAS ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 1 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
Monitor uptime via SNMP
define service{
use generic-service ; Inherit values from a template
host_name NAS
service_description Gigabit 0/1 to Vlan 10
check_command check_ifoperstatus!*****!1
}
define service{
use generic-service ; Inherit values from a template
host_name NAS
service_description Gigabit 0/2 to Vlan 20 Radius
check_command check_ifoperstatus!*********!3
}
for instnace for check_ifoperstatus nagios only sends notification when according to nagios interface is in state down
but i want it to notify me as soon as interface starting to change its status.
same with check_ping
flapping is turned off somewhere in nagios.cfg