monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error reading pid from file


From: Guillaume François
Subject: Re: Error reading pid from file
Date: Tue, 22 Sep 2020 12:26:57 +0200

Hello,

The correct syntax is "check program" (https://mmonit.com/monit/documentation/monit.html#Program)
Also it is not recommended to specify an unique value in the cron _expression_ for the minute field.
In your case, best is to trigger the check every 120 cycles (1 hours -> 60 minutes -> 1 cycle every 30 sec -> every 120 cycles)

It summarize to:

check program ping.sh with path "/path/to/ping.sh"
     every 120 cycles
     if status != 0 then alert
 

Regards.


Le mar. 22 sept. 2020 à 01:06, Ron Eggler <ron.eggler@ecoation.com> a écrit :
Hi All,

I'm new here and also new to Monit.
I wrote a script that I would like to have invoked once an hour by monit.

I have added the following to my /etc/monit/monitrc:

cat /etc/monit/monitrc
set daemon 30
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
       basedir /var/lib/monit/events # set the base directory where
events will be stored
       slots 100                     # optionally limit the queue size

check ping.sh
     with path "/path/to/ping.sh"
     every "44 * * * *"
     #if status != 0 then alert


and I got the following in /var/log/monit.log:

[UTC Sep 21 22:25:38] info     : Starting Monit 5.16 daemon
[UTC Sep 21 22:25:38] info     : '056e2c2' Monit 5.16 started
[UTC Sep 21 22:44:09] error    : Error reading pid from file
'/path/to/ping.sh'
[UTC Sep 21 22:44:09] error    : 'ping.sh' process is not running
[UTC Sep 21 22:44:09] info     : 'ping.sh' trying to restart

while:

ls -l /path/to/ping.sh
-rwxrwxr-x 1 root root 1045 Sep 21 20:08 /path/to/ping.sh

and inside the script, the pid is stored in /var/run/ping.pid:

#!/bin/bash
pidfile="/var/run/ping.pid"
# Get the pid of the currently running script
ps ax | grep $0 | grep $SHELL | awk '{print $1}'>$pidfile


the pid file is deleted on the bottom of the script with:

rm $pidfile


why is there an error: "Error reading pid from file '/path/to/ping.sh'"?


Thank you, Ron




--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d(+) s++:- a C++$ ULC(+)>+++$ !P--- L+>$ !E---? W+++$ !N* !o-- K--? w(+) !O---? !M- !V--? PS+? !PE Y+ PGP++>+++ !t-- !5 !X- R(+)>++* tv-? b(-) DI !D- G(+)>+ e+++ h--() r->$ y?*
------END GEEK CODE BLOCK------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]