Hi,
My eventual goal is to have an email sent out to all admins whenever nagios is restarted. Yes, they asked for this.
There are some complicated ways of doing this with custom plugin scripts but I was looking for an easy way.
I am using Nagios Core 3.2.1+squeeze1 on Debian 6.0. This is the debian-stable-blessed version of nagios for Debian 6.0.
My attempt has been either an active (not passive) host or service check that uses /bin/true as its command and has initial_state d (if host) or initial_state w (if service) set, with notification_options as d,r or w,r.
It never works. It appears as if nagios completely ignores initial_state. The cgi shows "pending", then OK. I cannot find a way to force the initial state to anything except PENDING.
I have search this forum and the web and I see references to a similar problem with passive checks, but I am using active checks.
I have tried changing retain_status_information and retain_nonstatus_information but these variables dont help. I have many other host and service checks that work fine, but dont rely on initial_state.
Has anybody else seen this? Any ideas? Is upgrading nagios (or using a more complicated check) my only remaining options?
Cannot get initial_state to work for active checks
-
TNZroadkill
- Posts: 2
- Joined: Wed May 08, 2013 8:55 pm
- Location: New Zealand
-
TNZroadkill
- Posts: 2
- Joined: Wed May 08, 2013 8:55 pm
- Location: New Zealand
Re: Cannot get initial_state to work for active checks
OK, I have solved my own problem I think.
Reading the fine print, nagios has soft and hard state types, and will not notify on state transitions in or out of a soft state. Initial_state sets a soft state, and I don't see any way to force initial_state to set a hard state. So no notifications result from a transition out of the initial_state.
However, there is a different way to detect the transition: use an event_handler. This works fine.
So I create a service check called nagios_startup, set initial_state=w, set check_command to something that always returns OK, retain_status_information=0, and set event_handler to something that emails the admins to tell them that nagios has (re)started.
Incidentally, I did find use_pending_states in cgi.cfg, but it doesn't seem to impact soft/hard state types or state transitions, so it doesn't matter here.
Cheers.
Reading the fine print, nagios has soft and hard state types, and will not notify on state transitions in or out of a soft state. Initial_state sets a soft state, and I don't see any way to force initial_state to set a hard state. So no notifications result from a transition out of the initial_state.
However, there is a different way to detect the transition: use an event_handler. This works fine.
So I create a service check called nagios_startup, set initial_state=w, set check_command to something that always returns OK, retain_status_information=0, and set event_handler to something that emails the admins to tell them that nagios has (re)started.
Incidentally, I did find use_pending_states in cgi.cfg, but it doesn't seem to impact soft/hard state types or state transitions, so it doesn't matter here.
Cheers.
Re: Cannot get initial_state to work for active checks
here here.
event handlers are a good solution for this.
event handlers are a good solution for this.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.