Page 1 of 1

excluding alert for specific condition

Posted: Fri Jan 10, 2014 11:34 am
by vinothsethuram
I'm using check_http plugin to monitor my apis. I want to stop sending alert/recovery emails for specific known failure. If I get cookie_error string in response I do not want to send warning/recovery emails. Please help

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 11:49 am
by abrist
You may need to create a wrapper script to check the status output of check_http and not alert on the cookie error.

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 12:51 pm
by vinothsethuram
Alert conditions would have specified in check_http. Then how come we modify alert condition by writing wrapper class without editing check_http?

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 12:57 pm
by tmcdonald
Because writing a wrapper is a lot faster and easier, frankly. check_http is written in C, whereas a wrapper can be in whatever language you are comfortable in. Also if you modify check_http then an other check that uses it also has that modification. This may or may not cause an issue, but it is still a good idea to keep the core plugins as they are.

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 12:58 pm
by abrist
Can you give me an example of the command and the status response from the cli? You may have to use a wrapper as you need to alter the return status code based on the content of the returned status string.

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 1:51 pm
by vinothsethuram
Request

check_http -H xyz.abcd.com -u 'https://xyz.abcd.com?param=1&param2=3' -T 'application/json' -v


Response

STATUS: HTTP/1.1 401 Unauthorized
**** HEADER ****
Content-Language: en-US
Content-Type: application/xml
Date: Fri, 10 Jan 2014 18:44:42 GMT
Content-Length: 239
Connection: Close
**** CONTENT ****
{
"errors": [
{
"errorCode": "12345",
"errorKey": "INVALID_COOKIE",
"errorMessage": "12345: An invalid cookie occured"
"errorParameters": ""
}
]
}

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 2:36 pm
by tmcdonald
So yea, in this case you simply write a script to call check_http with those parameters, grep the output for the string, and modify the exit code appropriately.

Re: excluding alert for specific condition

Posted: Fri Jan 10, 2014 2:40 pm
by sreinhardt
Just an example, not something you should put in production, however a script to wrap this could look like:

Code: Select all

#!/bin/bash

result=$(check_http -H xyz.abcd.com -u 'https://xyz.abcd.com?param=1&param2=3' -T 'application/json' -v)

if [[ $(echo $result | grep -i "401 Unauthorized") ]] && [[ $(echo $result | grep -i "12345: An invalid cookie occured") ]]; then
        echo "OK - Known error 12345 was recieved."
        exit 0
else
        echo "$result"
        exit $?
fi