naemon / naemon-core

Networks, Applications and Event Monitor
http://www.naemon.io/
GNU General Public License v2.0
153 stars 63 forks source link

External command parse errors #398

Open dt770pro opened 2 years ago

dt770pro commented 2 years ago

Using passive checks from numerous different systems via NRDP REST API using XML.

I frequently see one of two external command parse errors when receiving an "OK" check result following a fault state of "CRITICAL".

Two examples being:

[2022-10-22 12:58:59] Warning: External command parse error [1666439939] [1666439939] PROCESS_HOST_CHECK_RESULT;HOST_A;0;HOST_A_IS_OK (Unknown command '[1666439939] PROCESS_HOST_CHECK_RESULT')

[2022-10-22 12:58:59] Warning: External command parse error PROCESS_HOST_CHECK_RESULT;HOST_B;0;HOST_B_IS_OK (Commands must begin with a timestamp inside square brackets)

This seems to imply an issue related to the format of the received command, which we have verified as being sent correctly by the remote host, possibly related to the timestamp and its square brackets.

sni commented 2 years ago

How do you submit the passive results to naemon? The fifo command file may have issues if several processes/threads try to write simultaneously. Better choices would be using the query handler api or write spool files into the check results folder or livestatus (which internally uses the query api). All alternative handle parallel writes much better.

dt770pro commented 2 years ago

Thank you for the quick response.

They are submitted via HTTP GET - and yes we frequently have up to 100 arriving virtually simultaneously.

I've had a quick look and I'm not sure how I would go about moving to using the Query Handler API or Livestatus API. Should I follow the guide here https://docs.checkmk.com/latest/en/web_api_references.html ?

sni commented 2 years ago

the question was more how this NRDP submits its results to naemon.

dt770pro commented 2 years ago

Sorry I'm a Linux beginner.. I'm not sure what you mean...

We have third party applications that do an HTTP GET on "fail" state and another on "ok". Simply:

GET /nrdp/?cmd=submitcmd&token=XXXXXXXXXX&command=PROCESS_HOST_CHECK_RESULT;HOST_A;1;Host_A_Fail\r\nHTTP/1.1\r\nHOST: fqdn.domain.local\r\n\r\n

I hope I am making sense!

sni commented 2 years ago

i am sorry, but nrdp is not affiliated with this project. You could try to open an issue there.

dt770pro commented 2 years ago

Ok understood. However, could you point me in the direction of achieving the same using the Livestatus API instead of NRDP?

sni commented 2 years ago

Naemon itself does not offer a rest api. This can be done by 3rd party tools. Naemon offers the APIs mentioned above:

So you are using a 3rd party tool already which is then probably using one of the above APIs. I further assume it uses the deprecated command file api which had known shortcomings like this.

I suggest you get in contact with the nrdp people to see if it can connect to naemon in a different way.

dt770pro commented 2 years ago

Ok, thank you.

Is the Thruk REST API a suitable alternative?

sni commented 2 years ago

Sure, that'll work too.