Notifications sent out when they shouldn't be

I’m trying to set up two types of notifications, namely emails and sms messages using gnokii.

I want the emails to go 24x7, but the sms only to go out of work hours.

The problem is, no matter what I try nagios sends out sms messages 24x7.

I have tried commenting out the notification_period in the hosts.cfg and services.cfg file.

A subset of my config files is below (addresses and names changed). Can anyone see what I’ve missed?


hosts.cfg

‘host1’ host definition

define host{
use generic-host ; Name of host template to use

    host_name               host1
    parents                 main_switch
    alias                   host1 definition
    address                 aaa.bbb.ccc.ddd
    check_command           check-host-alive
    max_check_attempts      10
    notification_interval   0
    notification_period    24x7
    notification_options    d,u,r
    }

services.cfg

define service{
use generic-service ; Name of service template to use

    host_name                       host1
    service_description             PING
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              3
    normal_check_interval           5
    retry_check_interval            1
    contact_groups                  server-admins
    notification_interval           120
    notification_period            24x7
    notification_options            c,r
    check_command                   check_ping!250.0,33%!2000.0,80%
    }

hostgroups.cfg

'server-admins group definition

define hostgroup{
hostgroup_name server-admins
alias Servers
members host1,host2
}

contactgroups.cfg

‘server-admins’ contact group definition

define contactgroup{
contactgroup_name server-admins
alias Server Administrators
members bob,bobbysms
}

contacts.cfg

‘bob’’ contact definition

define contact{
contact_name bob
alias bob
service_notification_period 24x7
host_notification_period 24x7
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
}

‘bobbysms’ contact definition

define contact{
contact_name bobsms
alias bob
service_notification_period ournonworkhours
host_notification_period ournonworkhours
service_notification_options c,r
host_notification_options d,r
service_notification_commands notify-by-gnokii-queue
host_notification_commands host-notify-by-gnokii-queue
pager 123456789
}


timeperiods.cfg

‘24x7’ timeperiod definition

define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}

‘ournonworkhours’ timeperiod definition

define timeperiod{
timeperiod_name ournonworkhours
alias Our Non-Work Hours inc. NZ holidays
december 25 - january 5 00:00-24:00 ; Christmas
february 6 00:00-24:00 ; Waitangi day 2009
april 10 00:00-24:00 ; Good Friday 2009
april 13 00:00-24:00 ; Easter Monday 2009
april 25 00:00-24:00 ; ANZAC day 2009
june 1 00:00-24:00 ; Queens Birthday 2009
october 26 00:00-24:00 ; Labour Day 2009
january 26 00:00-24:00 ; Auckland Ann. 2009
january 19 00:00-24:00 ; Wellington Ann. 2009
november 14 00:00-24:00 ; Canterbury Ann. 2008
sunday 00:00-24:00
monday 00:00-08:00,17:00-24:00
tuesday 00:00-08:00,17:00-24:00
wednesday 00:00-08:00,17:00-24:00
thursday 00:00-08:00,17:00-24:00
friday 00:00-08:00,17:00-24:00
saturday 00:00-24:00
}

Noshferatu had the same problem here, but unfortunately didn’t post his solution.

meulie.net/portal_plugins/fo … .php?10997

Anyone have any ideas?

You have specifed wrong contactname in contactgroup definititon. It should be bobsms instead of bobbysms

Sorry, that’s just my changing the names from the real ones. In my actual config they are correct and it still sends sms’s during work hours.

Have you tried splitting your contact_groups into 2? I know, it’s much more ‘elegant’ the way you have it set up here, and I can’t dee any reason why it isn’t working as it should, but perhaps it’s time to consider that this might be a bug or a problem with the timeperiod inheritence logic and maybe it’ll just never work like this. :shock:

If you try maybe setting up a server-admins-email and server-admins-sms group, then putting your bob contacts in each goup as appropriate and assign both contact_groups to your hosts and services, at least you’ll know whether or not your timeperiods are AOK or not. If everything then fires off as it should, you know it’s nagios that’s hosed, not your config.

HTH

/S

I suppose you have reloaded nagios on every configuration change… but you haven’t mentioned that, so…

Albin: Yes, even tried rebooting the box.

Strides: I don’t see how this would help. All of the appropriate contacts (emails and sms) are going to the correct people, so I believe it is not a contact problem. Also, the admins (eg bob) need to get emails and sms so I don’t see how I can split them up. If I’ve missed something in your idea, please let me know. At this point I need all the help I can get.

It is just ignoring my custom time period for sms messages, the 24x7 for emails works fine.

I can’t be the only person trying to do something like this. Has anybody got this actually working?

If not, how do I go about logging a bug?

[blockquote]Strides: I don’t see how this would help. All of the appropriate contacts (emails and sms) are going to the correct people, so I believe it is not a contact problem. Also, the admins (eg bob) need to get emails and sms so I don’t see how I can split them up. If I’ve missed something in your idea, please let me know. At this point I need all the help I can get.[/blockquote]

Yeah, look, I never said it *shouldn’t *work how you have set it up, but clearly it doesn’t, and that’s why I think it might be a bug. What I am suggesting is another way to achieve it, as follows…

You have your mail-recieving contacts called bobmail, fredmail and joemail or whatever. Configure them with their email addresses, 24x7 notification options, your notify-by-email notify commands and so on. Make bobmail, fredmail and joemail members of a contact group called mailalerts or something.
You have your sms-recieving contacts called bobsms, fredsms and joesms or whatever, Configure them with their pager numbers, ournonworkhours notification options, your notify-by-gnokii-queue notify commands, etc etc. Make bobsms, fredsms and joesms members of a contact group called smsalerts or something.
Put **contact_groups mailalerts,smsalerts **in your host and service definitions.
Job done. Oh, actually restart nagios first, then it’s job done.

So, you get a service go down and it’ll trigger notifications to both the mail and sms contact groups, and because for instance bob has a bobmail set contact set up in the mail group, he’ll get a mail 24x7. Plus, as he is also in the sms group as bobsms, if it’s out of hours he’ll get the added bonus of a text message. Should be what you are looking to achieve, right?

Lastly, try and keep your object names and aliases unique if you can… for instances, both your aliases for your bob related contacts are bob, and server-admins is both a hostgroup name and a contactgroup name… I’m not saying that would break anything, and I’m not saying it wouldn’t either, but I would think that it is best to try and not confuse poor old nagios any more than neccessary :frowning:

This certainly works for me right and also has worked for other users in this forum, so if it works for you whereas the previous configuration didn’t, then you’ve found your bug. Where you’d log that though, I’ve no idea, sorry… mebey Albin someone else can chip in on that front.

Best of luck, let us know how it goes.

/S

OK, I’ve set it up like you suggested Strides.

Will report back when some notifications have occurred.

OK, I triggered a notification by unplugging something.

Nagios dutifully sent notifications by sms and email.

I guess I’ve found a bug. To whom should I report this?

nagios.org/support/mailinglists.php
look for nagios-devel

Sent an email to the nagios-devel list.

Hopefully they can sort it.