No "last output" on program

Issue #1049 resolved
KPFA created an issue

Running: Ubuntu 20.04.5 LTS (focal) with Monit v 5.26.0
We have a MONIT script: archive_mon:

check program list-files with path "/bin/bash -c /usr/local/bin/archive_mon.sh" TIMEOUT 15 SECONDS
if status > 0 then alert

The archive_mon.sh script looks like this:

#!/bin/bash
STATUS=$(/usr/bin/find /var/www/archives.kpfa.org/htdocs/data/`/usr/bin/date +"%Y"` -type f -size -10M -exec /usr/bin/ls -lh {} \; | /usr/bin/wc -l;)
echo $STATUS > /dev/stderr
if [ $STATUS != 0 ] ; then
   exit 1
fi

It’s purpose is to search a directory for files under 10M, and if found set the exit status to 1, however no alerts are triggered or sent when the condition should be met. Tested by putting files under 10M in the dir and running the script.
Test the program:

# /bin/bash -c /usr/local/bin/archive_mon.sh
302
# echo $?
1

Tried: Restarting and reloaded Monit.

Here’s the output of the monit status output:

System 'kpfa-archives'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  load average                 [0.38] [0.51] [0.71]
  cpu                          0.9%us 0.0%sy 0.0%wa
  memory usage                 16 EB [54854356992.0%]
  swap usage                   0 B [0.0%]
  uptime                       73d 23h 39m
  boot time                    Sat, 16 Jul 2022 09:49:33
  data collected               Wed, 28 Sep 2022 09:27:30

I would expect the monit status to show last output and an alert to be set. However, neither of those actions happen.

Any thoughts? Thanks!

Additionally, the memory used is at 16EB, which is incorrect. I assume this is because we run ZFS on Linux and has since been fixed in a more recent version of Monit.

Comments (3)

  1. Tildeslash repo owner

    The ‘last output’ will be visible under check program list-file. the kpfa-archives is different service type ('check system', not ‘check program’). If you don’t see the list-files service in monit status, it probably wasn’t included in the monit configuration (check the “include” statement settings or put the configuration directly to monit’s main configuration file.

    Regarding the 16EB problem, please upgrade monit.

  2. KPFA reporter

    Thank you for your kind and accurate response.

    I can see the error was the location of the monit script, not any issue with Monit.

  3. Log in to comment