I have written my own check plugin that passively checks a device (the plugin runs on cron due to the nature of the device).
I run the script, and pass expected thresholds to set the status_code
to 0
to indicate all is good. When I do this, the Icinga2 API returns normally and updates the host output in Icingaweb2.
Status successfully updated for 96.5.193.179. Payload:
{ "type": "Host", "filter": "host.name==\"96.5.193.179\"", "exit_status": 0, "plugin_output":"OK - Total of 16 APs is equal to expected number of APs (16). Model: SZ104 Serial: 222038000092", "pretty": true }
However, when I pass in bogus information to trigger a CRITICAL status_code
2
, I get a 500 error returned from the API:
{'results': [{'code': 400.0, 'status': "Invalid 'exit_status' for Host 96.5.193.179."}]}
Status not updated! API returned HTTP 500 for 96.5.193.179. Payload:
{ "type": "Host", "filter": "host.name==\"96.5.193.179\"", "exit_status": 2, "plugin_output":"CRITICAL - Total of 16 APs not equal to expected number of APs (15). Model: SZ104 Serial: 222038000092", "pretty": true }
I then check Icingaweb2 and the host status information is still stuck on OK.
Any idea what’s going on here? I am passing in the same parameters and the payloads looks the same, except for the exit_status and the plugin_output.
I am using Python 3.8. It’s worth noting that I am passing in an integer and using its str method to concatenate it to the payload string. If I do not use the str(exit_status)
then I get a TypeError.
Per the documentation https://icinga.com/docs/icinga-2/latest/doc/12-icinga2-api/#process-check-result
2 should be a valid exit_status