excluding alert for specific condition

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

excluding alert for specific condition

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: excluding alert for specific condition

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: excluding alert for specific condition

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: excluding alert for specific condition

Post 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.
Former Nagios employee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: excluding alert for specific condition

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vinothsethuram
Posts: 147
Joined: Thu Nov 07, 2013 11:44 am

Re: excluding alert for specific condition

Post 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": ""
}
]
}
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: excluding alert for specific condition

Post 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.
Former Nagios employee
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: excluding alert for specific condition

Post 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
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked