So, after I upgraded Monit to 5.35.2, I rebooted the system five times—four reboots were successful. I could see that the process was up and monitored by Monit.

On the fifth reboot, Monit stopped monitoring the process (due to five restarts in five cycles) even though the process was up and running.


It’s a Buildroot-based system running on a Microchip SAM9X60 (ARM926EJ-S, ARMv5TE). Kernel 6.1.22 from linux4microchip-2023.04.

I will send all logs to the email you mentioned.

Cheers

Kacper


W dniu 22.10.2025 o 13:59, [email protected] pisze:
Please can you provide more details?

You upgraded monit to 5.35.2, then rebooted the server 6 times and the problem persists? (~5 boots success, after ~6th error after first cycle despite the "if 5 restarts within 5 cycles then unmonitor" settings?)

What platform it exactly is? (linux or BSD version?)

Please can you add the process PID to the "screen process started successfully" log message?

Please can you send full monit log to [email protected]?

Best regards,
Martin



On 22. 10. 2025, at 13:35, Kacper Kłys DMCS <[email protected]> wrote:

Hi Martin,

no changes for 5.35.0 and 5.35.2

Kacper


W dniu 22.10.2025 o 13:05, [email protected] pisze:
Hi Kacper,

it looks like a problem which was fixed in monit 5.35.0: The pidfile may contain a PID from the previous system boot, which belongs to a thread of different process after reboot.

Please can you upgrade monit? (5.35.2 recommended)

Best regards,
Martin



On 22. 10. 2025, at 10:54, [email protected] wrote:

Hi guys,
I have a problem with the monit daemon on my ARM system. Once every 5-6 times when I'm restarting the whole system, it happens that the screen process controlled by monit fails to start. I do not understand why. In monit logs or in system logs, there is no helpful information. Additionally, when monit claims that the process fails (and unmonitors it), I can see the proper screen process with a correct pid file available on the system. When I manually press "start service" in monit web gui, the correct process is found by monit. My monit version is 5.34.3.

I also do not understand how fast monit claims that the process fails to start and unmonitors it (in monit logs look like it takes 1-2 sec while timeout in monitrc for this process is 10 seconds).

*monitrc file:*
set daemon 20
set onreboot start
set log /var/log/monit.log

check process screenprocess with pidfile /var/run/screenprocess.pid
    if not exist then start
    start program = "/etc/init.d/screenprocess start" with timeout 10 seconds     stop program = "/etc/init.d/screenprocess stop" with timeout 10 seconds
    if 5 restarts within 5 cycles then unmonitor

*screenprocess init.d script:*

#!/bin/sh

PIDFILE=/var/run/screenprocess.pid
SCREEN_PATH=/tmp/screen

case "$1" in
  start)
    logger -t screenprocess "Starting ioc"
    echo "Starting ioc"
    if [ -f "$PIDFILE" ]; then
      logger -t screenprocess "Screen process is already running."
      echo "Screen process is already running."
      exit 1
    fi
    # create dir for screen socket files
    mkdir -p $SCREEN_PATH
    chmod 700 $SCREEN_PATH
    export SCREENDIR=$SCREEN_PATH
    # set stack limit
    ulimit -s 1024
    # run screen
    screen -c /etc/screenprocesslogs.conf -dmSL screenprocess ./start.cmd && sleep 1
    # get pid of screen
    screen -ls | grep -oE "[0-9]+\.screenprocess" | sed -e "s/\..*$//g" | tail -n 1 > $PIDFILE
    if [ -f "$PIDFILE" ]; then
      NUM_PIDS=$(grep -E '^[0-9]+$' "$PIDFILE" | wc -l)
      # check if only one screen session is active
      if [ $NUM_PIDS -eq 1 ]; then
        logger -t screenprocess "Screen process started successfully."
        echo "Screen process started successfully."
      else
        logger -t screenprocess "Failed to start Screen process. Multiple PIDs or none detected"         echo "Failed to start Screen process. Multiple PIDs or none detected"
        exit 1
      fi
    else
      logger -t screenprocess "Failed to start Screen process. PID file $PIDFILE not created"       echo "Failed to start Screen process. PID file $PIDFILE not created"
      exit 1
    fi
    ;;

*Logs from monit:*
[2025-10-22T08:27:22+0000] debug    : pidfile '/var/run/screenprocess.pid' does not exist [2025-10-22T08:27:22+0000] error    : 'screenprocess' process is not running [2025-10-22T08:27:22+0000] debug    : ------------------------------------------------------------------------------- [2025-10-22T08:27:22+0000] debug    : ------------------------------------------------------------------------------- [2025-10-22T08:27:22+0000] debug    : pidfile '/var/run/screenprocess.pid' does not exist [2025-10-22T08:27:22+0000] info     : 'screenprocess' start: '/etc/init.d/screenprocess start'
[2025-10-22T08:27:22+0000] info     : 'mgmt' start on user request
[2025-10-22T08:27:22+0000] info     : 'screenprocess' start on user request [2025-10-22T08:27:22+0000] info     : Monit daemon with PID 251 awakened
[2025-10-22T08:27:23+0000] debug    : Starting screen process
screen process started successfully.
[2025-10-22T08:27:24+0000] error    : 'screenprocess' service restarted 5 times within 5 cycles(s) - unmonitor

I'd be grateful for any tips on what can be wrong.

Cheers

Kacper




Reply via email to