monit-general
[Top][All Lists]
Advanced

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

Monit and exit status code


From: Nedim Hadzimahmutovic
Subject: Monit and exit status code
Date: Thu, 12 Sep 2013 10:02:27 +0200

In the documentation it is stated that "Monit will raise an alert if the exit value of myscript is different from 0.  By convention, 0 means the program exited normally."



I want to check with you what am I missing since my Monit is raising an alert when the exit status of a script is 0.




I have two Monit checks:



# cat /etc/monit/conf.d/web/monit.web.1

check program not_eq_0_web_server_response with path /root/web_status.sh
    if status != 0 then alert

# cat /etc/monit/conf.d/web/monit.web.2

check program is_eq_0_web_server_response with path /root/web_status.sh
    if status == 0 then alert
   

The bash script:


# cat /root/web_status.sh

#!/bin/bash
TP=`curl -sL "http://example.com/ping"`
if [ $TP -eq 0 ];then
   exit 0
else
   exit 1
fi


When I manually execute

# curl -sL "http://example.com/ping"

the response is 0, and the exit status of the bash script is 0, as you can see below"


# sh /root/web_status.sh
# echo $?
0

This is the alert I get from Monit:


Status failed Service is_eq_0_web_server_response

    Date:        Thu, 12 Sep 2013 09:48:15
    Action:      alert
    Host:        localhost
    Description: status failed (0) for /root/web_status.sh. Error: no output to stderr..

Your faithful employee,
Monit




Status succeeded Service not_eq_0_webserverresponse

    Date:        Thu, 12 Sep 2013 09:29:44
    Action:      alert
    Host:        localhost
    Description: status succeeded

Your faithful employee,
Monit


reply via email to

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