Running a command when Nagios config changes

Eric Cables ecables at gmail.com
Fri Jul 16 01:56:36 CEST 2010


Why not use SEC (http://simple-evcorr.sourceforge.net/), or something
similar, to watch the nagios.log file and match on a regexp pattern.  When
that pattern is seen, run the script of your choice.  I assume that anytime
the Nagios process is restarted a log will be generated there.

-- Eric Cables


On Thu, Jul 15, 2010 at 7:59 AM, Paul M. Dubuc <work at paul.dubuc.org> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20100715/ed0818c7/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
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
-------------- next part --------------
_______________________________________________
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