Monit leaves zombie (defunct) processes when using "check program"

Issue #825 new
Former user created an issue

Example config to reproduce the issue:

Monit rule:

check program cpu_temp with path "/usr/local/etc/monit/scripts/cpu_temp.sh"
    if status > 70 then alert
    if status < 15 then alert

Script cpu_temp.sh:

#!/bin/sh
RET=`sensors -Au 2> /dev/null | sed -n 's/_input//p' | sed 's/.\+:\s\+\([0-9]\+\).\+/\1/' | sort -n | tail -1`
exit $RET

This results in zombie (defunct) process every monitoring cycle:

$ ps aux | grep Z
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      4515  0.0  0.0      0     0 ?        Zs   20:38   0:00 [cpu_temp.sh] <defunct>

The problem seem to persist with any script.

Monit installed on Ubuntu Server 18.04.2 LTS from repositories.

Monit package version: 5.25.1-1build1

I am willing to debug this issue if anyone can provide directions.

Comments (5)

  1. Lutz Mader

    Hello,
    this is not a bug, but confuse me sometimes too,
    see https://mmonit.com/monit/documentation/monit.html

    The asynchronous nature of the program check allows for non-blocking behaviour in the current Monit design, but it comes with a side-effect: when the program has finished executing and is waiting for Monit to collect the result, it becomes a so-called "zombie" process. A zombie process does not consume any system resources (only the PID remains in use) and it is under Monit's control and the zombie process is removed from the system as soon as Monit collects the exit status. This means that every "check program" will be associated with either a running process or a temporary zombie. This unwanted zombie side-effect will be removed in a later release of Monit.

    With regards,
    Lutz

  2. Former user Account Deleted

    Thank you for clarification, @Lutz Mader . I was alerted by the default Ubuntu MOTD showing warning about presence of zombie processes.

    Good to hear there are plans to address this issue.

  3. Lutz Mader

    Hello Oleg

    Good to hear there are plans to address this issue.

    The unwanted zombies are available as long as I use monit and this is a easy and safe way so start additional programs or scripts and get the reponse back to monit.

    With regards,
    Lutz

  4. Former user Account Deleted

    I understand that. My point was that even if Monit handles zombie processes safely, in general, presence of zombie processes may indicate a problem and/or resource leak, which is why some monitoring system warns user about zombie processes. So it would be nice to have no zombie processes in the system at all.

  5. Lutz Mader

    Hello Oleg,
    you are right, zombie processes are bad in general, but not all the time. Thanks for your explanation.

    With regards,
    Lutz

  6. Log in to comment