Nagios father, script son ??

Scot Jenkins scotjenkins at gmail.com
Fri Nov 18 18:47:32 CET 2005


On 11/18/05, enrico fanti <e.fanti at pointercom.it> wrote:
> Hi to all
>
> I have this problem
>
> Nagios executes a script.
>
> This script have to restart the Nagios process in this way:
>
> /etc/init.d/nagios stop
> /etc/init.d/sendmail restart
> /etc/init.d/named
> /etc/init.d/nagios start
>
> The problem is that when the script execute this sequence, it executes only:
>
> /etc/init.d/nagios stop
> /etc/init.d/sendmail stop
>
> It seems that the father Nagios execute the son script, but this script dies when the father dies (Nagios).
>

So named and sendmail are not started at all when your script runs?

It's possible you have a bad init script for sendmail.  Typically a
"restart" option simply runs "$0 stop; $0 start".  If the "stop"
option is not coded properly, it will kill off the init script you're
trying to run.  Here's an example:

...
stop)
        # bad grep!
        kill -9 `ps -ef |grep sendmail |awk '{print $2}'`
        ;;

...


The grep command will find and match the init script
(/etc/init.d/sendmail) and kill it too.  Better ways to do this
include:

a) Typically on startup processes will write their PID to a file under
/var/run.  On my Debian system it is
/var/run/sendmail/mta/sendmail.pid.
Send a kill signal to the pid in this file:

    kill -9 `cat /var/run/sendmail/mta/sendmail.pid | head -1`

b) Ignore the "grep" command in the init script when grepping:

    kill -9 `ps -ef |grep sendmail |grep -v grep | awk '{print $2}'`


Hope that helps.
Scot


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
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