check_rest_api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

check_rest_api

Post by mindspring »

Hi There,

I am using the plugin below but not sure if it's the correct one to be using for my needs.
https://exchange.nagios.org/directory/P ... -API/visit

Basically what I want to do is an API call to a url using GET, it returns a Json result with the output below when I use PostMAN.

Code: Select all

{
    "ok": true,
    "result": {
        "url": "",
        "has_custom_certificate": false,
        "pending_update_count": 0
    }
}
I want to be able to validate the output of the fields using this plugin, but it doesn't seem to be working like that.

The command I was hoping would give me an "OK"

Code: Select all

./check_rest_api -H  hostname/getWebhookInfo -K has_custom_certificate false 

Gives me an error saying:
UNKNOWN - JSON key 'has_custom_certificate' not found!

Is there something i am doing wrong or is this maybe the incorrect plugin to use for my purposes?
Thanks
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_rest_api

Post by ssax »

I'm pretty sure you can do this with Configure > Config Wizards > JSON wizard.

Run this from an SSH session and see if it works for you:

Code: Select all

php /usr/local/nagios/libexec/check_json.php -u 'https://hostname/getWebhookInfo' -k 'result.has_custom_certificate' -s 'false' -r 0 -n 2
I'm looking at the plugin now as an alternative, I will post an update shortly.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_rest_api

Post by ssax »

I'm pretty sure you can do this with Configure > Config Wizards > JSON wizard.

Run this from an SSH session and see if it works for you:

Code: Select all

php /usr/local/nagios/libexec/check_json.php -u 'https://hostname/getWebhookInfo' -k 'result.has_custom_certificate' -s 'false' -r 0 -n 2
EDIT: I don't think the plugin you found will work because the help section says the key needs to be a number:

Code: Select all

  -K, --key jsonKey
    Optional; a comma delimited list of JSON keys to check. The value of this key must be a number
     If not provided, check_rest_api will check the HTTP status code. Anything < 400 will return OK,
     Anthing >=400 and < 500 will return WARNING, and >= 500 will return CRITICAL.
Locked