Hello,
I’m currently playing around with the collection mode for HTTP, to query some JSON Data. The JSON-Data includes boolean values which I want to use insight a count function for filtering elements on a selection. But it seems, that in this case, the boolean value is still something like ‘JSON::PP::Boolean=SCALAR(0x56146594f0d0)’ which I can not use in the filter for the count function.
JSON is like that:
{        "bindingName": "zway",        "creationTime": 1694179518,        "creatorId": 1,        "customIcons": {},        "deviceType": "switchMultilevel",        "firmware": "5.1",        "h": 128847420,        "hasHistory": false,        "id": "ZWayVDev_xxxx",        "location": 3,        "locationName": "xxxxx",        "manufacturer": "Fibaro",        "metrics": {          "icon": "blinds",          "isFailed": false,          "title": "xxxxx",          "level": 99        },}
I want to count all devices, which are in failed state (metrics.isFailed = true), but I’m not able to get it work:
{
          "type": "count",
          "src": "%(http.tables.devicesRequestEntries)",
          "filter": "%(src.isFailed)",
          "save": "%(failedCount)"
 },
Additionally, I want to output those devices. Therefore I’ve defined the corresponding selection_loop and now I need to format the output. I’ve tried:
"formatting": {
        "display_ok": "true",
        "printf_msg": "Device %s is in status %i",
        "printf_var": [
          "%(devicesRequestEntries.title)",
          "%(devicesRequestEntries.isFailed)"
        ]
      },
which leads to many error messages, as type JSON::PP::Boolean=SCALAR(0x56146594f0d0) is neither an integer nor a string. And I need to set the critical clause in the loop too, which get’s me back to the first thing.
What am I missing? I think it’s just a layer-8 problem, but I need help to get it solved.
And of course: I’ve already read
And I’ve checked github to make sure to have the latest patches for the collection mode. And yes, the patch of https://github.com/centreon/centreon-plugins/pull/3749 is already included.
