Workhours & off_workhours 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
jmituzas
Posts: 2
Joined: Fri Aug 12, 2011 12:25 pm

Workhours & off_workhours notifications

Post by jmituzas »

I am having a problem with this hope someone can either send me a link to some kind of documentation or tell me how I can do what I need to do?

Ok I am fine with being notified during work hours every hour or so, but off work hours I only need to be notified every 6 hours after already had received the first notification. I have tried several things and can't get it to work write either keeps notifying me every hour or get a config error on restarting nagios.

Heres a couple of things I have tried:

First I had tried creating to notification periods:

# 'workhours' timeperiod definition
define timeperiod{
timeperiod_name workhours
alias Normal Work Hours
monday 08:00-18:00
tuesday 08:00-18:00
wednesday 08:00-18:00
thursday 08:00-18:00
friday 08:00-18:00
}

# 'off workhours' timeperiod definition
define timeperiod{
timeperiod_name off_workhours
alias Off Work Hours
monday 18:01-07:59
tuesday 18:01-07:59
wednesday 18:01-07:59
thursday 18:01-07:59
friday 18:01-07:59
friday 00:00-24:00
saturday 00:00-24:00
}

and have made 2 templates:

define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

define host{
name linux-server_off; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period off_workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}


have created 2 different service and host checks:

define host{
use linux-server ; Name of host template to use
host_name localhost
alias fan
address 127.0.0.1
}

define service{
use l_server-service ; Name of service template to use
host_name localhost
service_description Root Partition
servicegroups check_drive-space
check_command check_local_disk!20%!10%!/
}

define host{
use linux-server_off ; Name of host template to use
host_name localhost
alias fan
address 127.0.0.1
}

define service{
use l_server-service_off ; Name of service template to use
host_name localhost
service_description Root Partition
servicegroups check_drive-space
check_command check_local_disk!20%!10%!/
}


this has resulted in a config error, guessing because they have the same ip address.

Then I found this in Nagios 3 Enterprise Network Monitoring book I had purchased as well as on the net:

define serviceescalation{
hostgroup_name linux-servers
service_description *
first_notification 1
last_notification 2
notification_interval 360
contact_groups admins
}


this didn't change anything still notified about the same problem every hour.

How can I accomplish being notified 1 time then again every 6 hours during off work hours?

been trying numerous things all week and am at a loss...

Please help...
Thanks in advance,
Joe
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Workhours & off_workhours notifications

Post by mguthrie »

Not actually sure how to do what you're looking for, the best I can send you is the Core docs:

http://nagios.sourceforge.net/docs/3_0/ ... tions.html
http://nagios.sourceforge.net/docs/3_0/escalations.html
jmituzas
Posts: 2
Joined: Fri Aug 12, 2011 12:25 pm

Re: Workhours & off_workhours notifications

Post by jmituzas »

Well since I couldn't get it to do what I wanted... I wrote this up which helps out a bit.
Instead of being notified 24 times about the same thing in one day without being able to distinguish one problem from an other without opening them all up.
Subject in my gmail account looks like:
**Problem Service Alert:...
(so all I see is)
**Problem Service Alert:...
**Problem Service Alert:...
**Problem Service Alert:...
**Problem Service Alert:...
**Problem Service Alert:...
**Problem Service Alert:... (24x for one problem over a weekend)

This was an easy fix:

# 'notify' timeperiod definition
define timeperiod{
timeperiod_name notify
alias notify
sunday 00:01-00:15,08:00-08:15,16:00-16:15
monday 00:01-00:15,08:00-08:15,16:00-16:15
tuesday 00:01-00:15,08:00-08:15,16:00-16:15
wednesday 00:01-00:15,08:00-08:15,16:00-16:15
thursday 00:01-00:15,08:00-08:15,16:00-16:15
friday 00:01-00:15,08:00-08:15,16:00-16:15
saturday 00:01-00:15,08:00-08:15,16:00-16:15
}
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Workhours & off_workhours notifications

Post by mguthrie »

Cool, thanks for posting the solution!
Fionaandme
Posts: 1
Joined: Sat Oct 01, 2011 1:57 am

Re: Workhours & off_workhours notifications

Post by Fionaandme »

thank you for information, i am determined not to give up
Locked