excluding alert for specific condition
-
vinothsethuram
- Posts: 147
- Joined: Thu Nov 07, 2013 11:44 am
excluding alert for specific condition
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
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.
"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
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
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
Re: excluding alert for specific condition
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.
"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
Request
check_http -H xyz.abcd.com -u 'https://xyz.abcd.com?param=1¶m2=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": ""
}
]
}
check_http -H xyz.abcd.com -u 'https://xyz.abcd.com?param=1¶m2=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
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
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¶m2=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.