Can we read http_check response and use it for -c/-w?

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
amolbhople
Posts: 1
Joined: Tue Jul 25, 2017 2:19 pm

Can we read http_check response and use it for -c/-w?

Post by amolbhople »

Hello There,
Could you please help me in following..

I am using check_http to get to know if the server is up or not.

Code: Select all

check_command                   check_http_url!/admin/v1/systemHealth/registeredModules/pulse!8080 -r \"isAlive\":\"false\" --invert-regex -l

This above code is working fine and I am getting emails if it is down.

But there are multiple services I want to monitor and I have following JSON data to monitor it.
Monitor1 and 2 has different alert and critical threshold values.
Can I use these values from HTTP response to decide the nagios critical or warning level.? Any help appreciated.
I was looking at this link https://support.nagios.com/forum/viewto ... =6&t=38108 but it is not returning any values. It throws error codes for the string matched.

How can I use the response data to decide the critical and warning values?

Code: Select all

{
  "MONITOR1": {
    "Obj1": [
      {
        "id": "1",
        "monitor": "MONITOR1",
        "key": "Service Response Time",
        "value": 654,
        "dateTime": "2017-07-24T22:00:45.503+0000",
        "alertThresholdValue": 10000,
        "criticalThresholdValue": 20000,
        "serverName": "serverName1",
        "isAlive": true
      }
    ]
  },
  "MONITOR2": {
    "Obj2": [
      {
        "id": "2",
        "monitor": "MONITOR2",
        "key": "Service Response Time",
        "value": 6000,
        "dateTime": "2017-07-24T22:00:45.503+0000",
        "alertThresholdValue": 2500,
        "criticalThresholdValue": 3000,
        "serverName": "serverName2",
        "isAlive": true
      }
    ]
  }
}
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Can we read http_check response and use it for -c/-w?

Post by mcapra »

check_http doesn't contain any specific logic for parsing particular markups or data other than plain text. You could probably craft a clever enough regular expression to accomplish what you're trying to do, but man it would be ugly.

If the entire response is just a JSON object, this plugin might be useful:
https://exchange.nagios.org/directory/P ... 29/details
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Can we read http_check response and use it for -c/-w?

Post by dwhitfield »

Thanks @mcapra! OP, let us know if you have any additional questions.
Locked