Set Notification Period for Hosts Services

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.
mastermindg
Posts: 5
Joined: Fri Mar 04, 2016 9:27 am

Set Notification Period for Hosts Services

Post by mastermindg »

I have a particular host that has daily downtime. I want to disable notification during this period. I have a timeperiod setup for this purpose and I've assigned it to the host:

Code: Select all

define host {
  use server
  address 192.168.1.34
  host_name myserver
  hostgroups linux,database
  notification_period downtime
}
However, I'm still getting alerts for this hosts' services during the downtime window. How can I suppress all notifications for this host during time period downtime?
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Set Notification Period for Hosts Services

Post by bwallace »

To further assist, we'll need to see your 'timeperiods.cfg' file. Could you post that so we can take a look?

It is found under:
/usr/local/nagios/etc/objects
Be sure to check out the Knowledgebase for helpful articles and solutions!
mastermindg
Posts: 5
Joined: Fri Mar 04, 2016 9:27 am

Re: Set Notification Period for Hosts Services

Post by mastermindg »

I set downtime to 02:00-03:00 so that I can test this. Once I get the notifications to stop coming I'll change it to the correct time.

Code: Select all

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
}

define timeperiod {
  timeperiod_name downtime
  alias           Downtime
  sunday          02:00-03:00
  monday          02:00-03:00
  tuesday         02:00-03:00
  wednesday       02:00-03:00
  thursday        02:00-03:00
  friday          02:00-03:00
  saturday        02:00-03:00
}
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Set Notification Period for Hosts Services

Post by rkennedy »

Let us know how your test goes.

Also - can you post your contact definition as well?
Former Nagios Employee
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Set Notification Period for Hosts Services

Post by bwallace »

You could use what you have in conjunction with the 'exclude' directive but that has been unstable. So I would instead opt for method #1, outlined here in this article:
http://www.thegeekstuff.com/2013/09/nagios-timeperiod/
Be sure to check out the Knowledgebase for helpful articles and solutions!
mastermindg
Posts: 5
Joined: Fri Mar 04, 2016 9:27 am

Re: Set Notification Period for Hosts Services

Post by mastermindg »

So the test isn't going well...I'm still getting alerts. I've seen all of the articles on setting timeframes and exclusions but they all deal directly with services. How do I disable notifications for ALL services for a host? My host has quite a few basic services that are are shared with other servers.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Set Notification Period for Hosts Services

Post by Box293 »

In the Nagios Core web interface, click the Host.
Under Host Commands click "Disable notifications for all services on this host"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mastermindg
Posts: 5
Joined: Fri Mar 04, 2016 9:27 am

Re: Set Notification Period for Hosts Services

Post by mastermindg »

Box293: Manually selecting "Disable notifications for all services on this host" everyday for eternity is really not a good option for me unless you are volunteering.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Set Notification Period for Hosts Services

Post by Box293 »

A service cannot inherit the time period from a host because the documentation states that the "check_period" directive is required.

Because you have shared services, you are running into this problem.

You could:

1) Create dedicated services for this specific host that have a specific check_period defined.

2) Create a cron job that daily schedules the downtime for the host and it's services (run it at 00:05 every day perhaps).
This can be done from the cli.
Following the documentation from:
https://old.nagios.org/developerinfo/ex ... ndlist.php
https://old.nagios.org/developerinfo/ex ... and_id=118
https://old.nagios.org/developerinfo/ex ... and_id=122

We need a command for the host and another command for all of the host's services.
We need three time values in epoch format (the time we are submitting the command, the start time, the end time).

These two commands will do what I have explained for the host "centos01" from 15:00 to 16:00.

Code: Select all

now_epoch=$(eval date +%s); start_epoch=$(date +'%F 15:00:00' | xargs -0 date +%s -d); end_epoch=$(date +'%F 16:00:00' | xargs -0 date +%s -d); printf "[$now_epoch] SCHEDULE_HOST_DOWNTIME;centos01;$start_epoch;$end_epoch;1;0;;nagiosadmin;Daily Donwtime\n" > /usr/local/nagios/var/rw/nagios.cmd

now_epoch=$(eval date +%s); start_epoch=$(date +'%F 15:00:00' | xargs -0 date +%s -d); end_epoch=$(date +'%F 16:00:00' | xargs -0 date +%s -d); printf "[$now_epoch] SCHEDULE_HOST_SVC_DOWNTIME;centos01;$start_epoch;$end_epoch;1;0;;nagiosadmin;Daily Donwtime\n" > /usr/local/nagios/var/rw/nagios.cmd
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
mastermindg
Posts: 5
Joined: Fri Mar 04, 2016 9:27 am

Re: Set Notification Period for Hosts Services

Post by mastermindg »

I ended up creating custom services for the host. However, this seems like a counter-intuitive way to go about doing what needs to be done here. Is there no way to override the default behavior and have services inherit a hosts notification settings?
Locked