[Top][All Lists]

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

monit validate (exit status)

From: Paul
Subject: monit validate (exit status)
Date: Fri, 26 Apr 2013 15:27:59 +1200

Hi there,

I recently added a call to "monit validate" to one of my shell scripts
and noticed I got an unexpected (or non-intuitive, at least) exit
status; in particular when everything is already running
("successfully validated", in a sense) monit validate exits with a
status of 1.

Checking the source code I see this is indeed what's happening; the
validate() function returns the number of errors encountered; from
validate.c (in monit-5.5):

    int validate() {
            int errors = 0;
            return errors;

and if there are no errors then the program exits with a non-zero
status (which conventionally indicates an error: EXIT_FAILURE is
typically defined as 1); from monit.c:

    } else if (IS(action, "validate")) {
            if (! validate())
    } else {

This seems to be the only place the return value of validate() is
used. So, is there any rationale for this? Or should it be considered
a bug? (i.e., should validate return a "true" value if it succeeded;
or should the logic in the monit.c snippet above be reversed so it
exits with a status of 1 if there are errors?)

Any insight/update would be appreciated,


reply via email to

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