Monit Verifier returns "no output"

I want to try to control a postfix queue using monit. I gave an example from Stackoverflow people. My monit version is the latest

This is Monit version 5.10.

In /etc/monit.d I have postfixlocal with

 check program postfixcola with path "/usr/local/bin/postfixcola.sh" #if status != 0 then alert if status > 1 then alert 

and then in /usr/local/bin/ I have postfixcola.sh with

 #!/bin/sh QUEUE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'` exit $QUEUE 

But Monit complains about script output every time. I did a test, setup and echo before exit , and at the time of the test, it returned 1 (because the postfix queue was 1)

But the error remains: [CET Dec 9 11:10:07] error : 'postfixcola' '/usr/local/bin/postfixcola.sh' failed with exit status (2) -- no output

I really don’t know what the problem is, any thoughts?

+6
source share
1 answer

In a bash script, you should echo the message to / dev / stderr:

 #!/bin/bash QUEUE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'` if [ $QUEUE -ne 0 ] ; then echo "Queue length > $QUEUE" > /dev/stderr fi exit $QUEUE 
0
source

Source: https://habr.com/ru/post/979317/


All Articles