<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/1.0.2">
</HEAD>
<BODY>
This is OK I presume,
<BR>

<BR>
But how should I take care of nagios notification, if I set  a service into nagios, and like to notify persons in charge of this service ?
<BR>
Into the script we just checks the nagios running state.
<BR>
Any idea ?
<BR>

<BR>
Le sam 16/11/2002 à 10:30, Scott a écrit :
    <BLOCKQUOTE>
<PRE><FONT COLOR="#737373"><FONT SIZE="3"><I>Just to make an appendment to this, I noticed I had it in a test state</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>while writing it... here is the actual working copy.. sorry about that</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>folks.. enjoy</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>#!/usr/bin/perl</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>open PIDFILE, ("/path/to/nagios/var/nagios.lock");</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>$pid = <PIDFILE>;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>close PIDFILE;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>@nag_stat = `ps -ax |grep -e $pid`;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>if (@nag_stat[0]) {</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>        print "nagios running\n";</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>} else {</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>        system('printf "Nagios not running: replace this with external</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>command\n"');</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>}</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Scott said:</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> I think you could just check the pid file for a number and run it</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> against a ps -ax greping the pid, then notify if it doesnt exist..</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> sounds fairly simple and probably a good idea too... Nothing worse then</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> a network outage to find out that nagios isnt monitoring the network</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> anyway...</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> #!/usr/bin/perl</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> open PIDFILE, ("/path/to/nagios/var/nagios.lock");</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> $pid = <PIDFILE>;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> close PIDFILE;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> @nag_stat = `ps -ax |grep -e $pid`;</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> if (!@nag_stat[0]) {</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>         print "nagios running\n";</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> } else {</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>         system('printf "Nagios not running: replace this with external</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> command\n</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> "');</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> }</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> Somthing like this from cron would work nicely for that.. crude, yes,</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> works, yes also.. somebody probably has better perl skills than myself</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> that could ake this better but it would do what you are asking for</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> though.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> Pascal Miquet said:</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> Is there some stuff to check that nagios is still alive, and may be</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> send an email.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> Doing this is tricky with nagios, I know.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> But I wonder, how admins could be informed that nagios is in a</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> blocking state or is not active.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> Personaly, I think that a shell schedule by the anacron in an  hourly</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> mode shoud be a good way, and then send Email and sms.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> But the semantic question is how could we fetch the nagios settings to</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> issue notifications ?</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> Any good idea, or link is welcome.</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>>> Pascal Miquet</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> -------------------------------------------------------</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> This sf.net email is sponsored by: To learn the basics of securing  your</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> web site with SSL, click here to get a FREE TRIAL of a Thawte  Server</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> Certificate: http://www.gothawte.com/rd524.html</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> _______________________________________________</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> Nagios-users mailing list</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> Nagios-users@lists.sourceforge.net</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>> https://lists.sourceforge.net/lists/listinfo/nagios-users</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I></FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>-------------------------------------------------------</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>This sf.net email is sponsored by: To learn the basics of securing </FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>your web site with SSL, click here to get a FREE TRIAL of a Thawte </FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Server Certificate: http://www.gothawte.com/rd524.html</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>_______________________________________________</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Nagios-users mailing list</FONT></FONT></I>
<FONT COLOR="#737373"><FONT SIZE="3"><I>Nagios-users@lists.sourceforge.net</FONT></FONT></I></PRE>
    </BLOCKQUOTE>
<A HREF="https://lists.sourceforge.net/lists/listinfo/nagios-users"><FONT SIZE="3"><I>https://lists.sourceforge.net/lists/listinfo/nagios-users</FONT></I></A>
    <BLOCKQUOTE>
<PRE></PRE>
    </BLOCKQUOTE>
</BODY>
</HTML>