Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried to set up my nagios install to check the availability of a SMTP service outside its backup hours. Unfortunately, it seems to be ignoring this configuration:

# a timeperiod to check only outside of zimbra's backup hour
# (combining the first with the second timeperiod)
define timeperiod {
    timeperiod_name     zimbra-backups
    alias               When zimbra is being backed up
    sunday              04:00-05:00
    monday              04:00-05:00
    tuesday             04:00-05:00
    wednesday           04:00-05:00
    thursday            04:00-05:00
    friday              04:00-05:00
    saturday            04:00-05:00
}
define timeperiod {
    timeperiod_name     always-except-zimbra-backups
    alias               24x7 except backup time
        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
    exclude             zimbra-backups
}

Which, then, is used with a new host:

define host {
    host_name               mailserver-except-backups
    alias                   mail server (outside backup hours)
    address                 yaddayadda
    notification_options        d,u,r,f
    use                     my-default-host
    check_period            always-except-zimbra-backups
    }
define service {
    host_name                   mailserver-except-backups
    service_description         SMTP service
    check_command               check_smtp!-t 30
    use                         my-default-service
    check_interval              2
    retry_interval              1
    }

I can't see what's wrong.. any clue? Here is one of the notification e-mail

***** Nagios *****

Notification Type: PROBLEM

Service: SMTP service
Host: mail server (outside backup hours)
Address: yaddayadda
State: CRITICAL

Date/Time: Sat Apr 27 04:03:16 CEST 2013

Additional Info:

Connection refused

Nagios is Core 3.3.1 running on a OpenBSD 5.2.

share|improve this question

3 Answers 3

up vote 1 down vote accepted
+100

Host checks and service checks are almost entirely unrelated, except for an implicit dependency of the service on its associated host.

You have configured the host check for your custom time period, but the service check is using whichever check_period is defined in the template it's using. Add a check_period to your service definition to fix this.

Alternatively, you could use your custom time period as a notification_period for the service, if you just want to suppress notifications during the backup.

Also, not that exclusions might be broken in 3.3.x, as noted in this line from the Nagios version history under 3.2.0:

Known issue: Service checks that are defined with timeperiods that contain "exclude" directives are incorrectly re-scheduled. Don't use these for now - we'll get this fixed for 3.4

... so you might want to upgrade to 3.4.x or 3.5.0 (latest as of this writing).

share|improve this answer
    
This actually seems to have worked. I'll give it another day to make sure, since mail was sent once a day. Stay tuned ;) –  lorenzog May 2 '13 at 14:42

I cannot test it right now but I think check_period for the service is inherited from my-default-service and overrides check_period from host definition.

And I also think it is better to suppress only notifications in that interval.

share|improve this answer
    
Well suppressing notifications is not what I want, as other services might require me to receive alerts. I just don't want the SMTP service to be checked in that timeframe. –  lorenzog Apr 29 '13 at 10:44
    
I mean suppressing notifications only for SMTP service using notification_period. –  Laurentiu Roescu Apr 29 '13 at 10:55

Maybe you should just alter the notification_period . You will still get a warning on your nagios frontend but no notifications will be triggered, during these hours.

share|improve this answer
    
As I already stated in another answer, this is not an acceptable solution. –  lorenzog May 2 '13 at 14:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.