Running a command when Nagios config changes

Paul M. Dubuc work at paul.dubuc.org
Thu Jul 15 16:59:53 CEST 2010


Ryan C Ash wrote:
>
>
>
> Paul M. Dubuc wrote
>>
>> I would like to have some way of running a command only when Nagios is
>> started, or is restarted from the "Process Commands" menu, or any time
>> Nagios reloads its configuration files.  Is there a way to do this?  I
>> thought about writing it as a localhost service plugin that simply does
>> nothing if
>>
>> $LASTSERVICECHECK$>  $PROCESSSTARTTIME$
>>
>> but that doesn't seem optimal.  It this the best solution?  It would be
>> nice if I could write it as an event handler, but events are only for
>> host or service state changes.  This is a Nagios process state change.
>
> We run on redhat linux and I use a common init script in
> /etc/rc.d/init.d/<nagios>.  That would be an easy place to add that
> additional script.  Currently it maintains our pnp4nagios, nsca
> listener, ndoutils, etc.

Thanks for your response.

What I really need is something that will run my script anytime Nagios reads 
its config files (possible configuration change) so this is only a partial 
solution.  Executing the "Restart the Nagios process" process command from the 
Process Info screen doesn't create a new Nagios process (it has the same PID 
after the restart), but it does cause Nagios to reload the configuration and 
resets the $PROCESSSTARTTIME$ macro value.  The localhost plugin I describe 
above does the job, but I wouldn't be able to guarantee that it would run 
promptly after the restart event and there seems to be no way to have it just 
run once instead of at intervals.  This isn't a problem for my current use so 
I can keep doing it this way.

It would be nice for Nagios to have a process restart (or config changed) 
event for which one cold write an event handler script.


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list