xWyatt / check_rest_api

Nagios Core plugin to check output from a RESTful JSON API
GNU General Public License v3.0
10 stars 5 forks source link

Please give me more examples for key #20

Open DonForigua opened 2 years ago

DonForigua commented 2 years ago

Greetings

I have a json exit:

"memory": [
  {
    "availableBytes": 59728,
    "type": "physical",
    "totalBytes": 842048

How can check availableBytes for example

xWyatt commented 2 years ago

I haven't tested this, but for the example of

{ 
  "memory": [
    {
      "availableBytes": 59728,
      "type": "physical",
      "totalBytes": 842048
     }
  ]
}

Try the option -K memory[0].availableBytes

DonForigua commented 2 years ago

Grettings i get this error

malloc(): invalid next size (unsorted) Aborted

jhaltrecht-rev commented 1 year ago

@xWyatt I am facing a similar issue, but for objects.
Let's say in the above example that memory was not an array, but just an object.

{ "memory": { "availableBytes": 59728, "type": "physical", "totalBytes": 842048 }

}

"-K memory.availableBytes" does not work and "-K memory,availableBytes" also fails. What can I do to access the inner key? Adding to my API path does not narrow the search.

To confirm, there is no way to pull a string value or convert the string to an int during execution?