4

Is there a way to check the result of a script with monit? For example a script returns 0 means ok, but 1 means failed. The idea is to call the script from monit on the local machine directly and interpret the result and send emails.

For example a script could do some hardware check.

My workaround is to call the script with cron and write the result to a file and check the file with monit.

0

Your work-around is the recommended way to do it with monit from what I've read.

| improve this answer | |
10

Program status testing does exactly what you want. Use it to check the status command of a script.

For example:

check program hwtest with path /usr/local/bin/hwtest.sh
with timeout 500 seconds
if status = 1 then alert
if status = 3 for 5 cycles then exec "/usr/local/bin/emergency.sh"
| improve this answer | |
  • I get a bad file descriptor error when I do this. Do you know what could cause this? – jeteon Aug 4 '16 at 12:35
  • @jeteon you may need to do something like: "/bin/bash -c '/path/to/your/hwtest.sh'" – cherouvim Jul 5 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.