LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Help: use monit to monitor a process doesn't work (https://www.linuxquestions.org/questions/linux-general-1/help-use-monit-to-monitor-a-process-doesnt-work-4175505608/)

5883 05-20-2014 05:30 PM

Help: use monit to monitor a process doesn't work
 
Hi, sometimes my dhclient process could die without clue, don't know where the log file is.

so i want to use monit to restart dhclient.
This is what i added to /etc/monit/monitrc.
For testing, i'm called echo initially, when eth0's pid file is gone.

check process dhclient with pidfile /var/run/sendsigs.omit.d/network-manager.dhclient-eth0.pid
start program = "/bin/echo dhclient died, do something ..."


but nothing happened after 2 mins (i set in monitrc to check it every 2 mins)

Any suggestions ?

Habitual 05-21-2014 09:01 AM

Something like this?

Code:

#!/bin/bash

if pgrep dhcpcd > /dev/null ; or pidof dhcpcd
then
    exit 0
else
    do something
    exit 1
fi
#EOF



All times are GMT -5. The time now is 03:01 AM.