Host vs Service notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
whopkins
Posts: 2
Joined: Thu May 24, 2012 1:36 pm

Host vs Service notifications

Post by whopkins »

Hello,

I am trying to troubleshoot an issue I am having with nagios core (3.2.3, CentOS/RPMforge package).
I define a host, and inherit a host template. The host template has a contact group associated.
I define a service on this host, and manually add a contact to it (no service template).

When this service changes state, both the contact associated with the service, and the contact group associated with the host are notified. I was under the impression that contacts attached to hosts would only be notified for host results.
The contacts in question have both host and service notifications enabled. I know I could solve this by creating a team-hostsonly and team-svcsonly split of the contact group, but that seems like overkill.

Thanks,

William
whopkins
Posts: 2
Joined: Thu May 24, 2012 1:36 pm

Re: Host vs Service notifications

Post by whopkins »

I have determined that this bug is due to having a contact group in the host template, but only a contact in the service definition. If I add a contact group (even if it's simply a group containing the original contact) to the service, notifications go to the contact defined there but not the contact defined in the host template. This is the desired behavior.


The takeaway: use contact groups everywhere.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Host vs Service notifications

Post by agriffin »

Glad you got things figured out.
coberas
Posts: 1
Joined: Mon Jun 04, 2012 8:23 am

Re: Host vs Service notifications

Post by coberas »

My problem look similarly but is a bit different.

I've got group users (with one user) in my contact.cfg:
define contact{
contact_name testuser
use generic-contact
alias testuser
email [email protected]
host_notifications_enabled 1
host_notification_period 24x7
host_notification_options d,u,r
host_notification_commands notify-host-by-email
service_notifications_enabled 1
service_notification_period 24x7
service_notification_options w,u,c,r
service_notification_commands notify-service-by-email
}


define contactgroup{
contactgroup_name test-admin
alias Nagios Administrators
members nagiosadmin, testuser
}
In my switch.cfg i've got a few switch like that one:
define host{
use generic-switch
host_name mwg
alias ProCurve Switch 2626 (J4900B)
address 10.7.7.11
parents MWG_switch
hostgroups switches
initial_state o
event_handler_enabled 1
flap_detection_enabled 1
flap_detection_options o,d,u
contact_groups test-admin
notification_options d,u,r,f,s
notifications_enabled 1
stalking_options o,d,u
icon_image switch40.png
icon_image_alt Switch
vrml_image switch40.png
statusmap_image switch40.gd2
}
and some services to be checking but for example i want to check if connection look's ok by ping service:
define service{
use generic-service,srv-pnp
host_name mwg
service_description PING
check_command check_ping!200.0,20%!600.0,60%
contact_groups test-admin
}



Service is checking and if i pull out cable i saw (in terminal and www interface ) then ping service is changing to the red color and isn't pinging but i don't recive notification by service. Only thing what i get to my mail box is a notification from default command to check if routers are "alive" (sending by notify-host-by-email):

# Define a template for switches that we can reuse
define host{
name generic-switch ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, switches are monitored round the clock
check_interval 5 ; Switches are checked every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 2 ; Check each switch 10 times (max)
check_command check-host-alive ; Default command to check if routers are "alive"
notification_period 24x7 ; Send notifications at any time
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r,u,s ; Only send notifications for specific host states
# contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
So i've check if i can send custom service notification from www interface and is working. The same is when i try send custom host notification everything is working.
But i've more then one service to monitoring my lan network and i need automatic notification from services.
So mabe someone can tell me where i make mistake ?



I'm sorry form my english...
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Host vs Service notifications

Post by jsmurphy »

If I understand what you are saying correctly then this is desired behaviour, if a host goes down it will automatically silence all services attached to that host. This is part of the parenting structure built in to Nagios to prevent alert storms.
Locked