Can I update Nagios active service status using Rest API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
JosephH
Posts: 34
Joined: Fri Oct 12, 2018 10:04 am

Re: Can I update Nagios active service status using Rest API

Post by JosephH »

I have over 9000 services for different hosts and using the following command (actually converted to use httpClient) to update the status of all the services in a giving time interval.
curl -k -L -XPOST "https://X.X.X.X/nagiosxi/api/v1/system/ ... ikey=YYYYY" -d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost;SSH;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'

Note: I am looking at https://josef.codes/c-sharp-throttle-ht ... oncurrent/ and testing it out right now.

Thanks
Joseph
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Can I update Nagios active service status using Rest API

Post by ssax »

Good idea, that's likely what you'd need to do if you're writing it in C#. You could also use the parallel command to do something like that.

You may need to increase some apache settings as well:

https://ubiq.co/tech-blog/increase-apac ... er-second/
JosephH
Posts: 34
Joined: Fri Oct 12, 2018 10:04 am

Re: Can I update Nagios active service status using Rest API

Post by JosephH »

Hi ssax,

What we have tried and still make the update/reset service status not as fast as we hoped. This make me wondering is it possible to combine multiple service status reset into one post request, this will reduce the http connections and database connections.

for example, instead of using the following command to update/reset one service check status,
curl -k -L -XPOST "https://X.X.X.X/nagiosxi/api/v1/system/ ... ikey=YYYYY" -d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost;SSH;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'

can we send something like the below for multiple service checks status?
curl -k -L -XPOST "https://X.X.X.X/nagiosxi/api/v1/system/ ... ikey=YYYYY"
-d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost;SSH;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'
-d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost1;SSH1;1;SSH Warning - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'
-d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost2;SSH2;2;SSH Critical - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'
-d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost3;SSH3;0;SSH OK - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'
-d 'cmd=PROCESS_SERVICE_CHECK_RESULT;localhost4;SSH4;3;SSH Unknown - OpenSSH_7.3 (protocol 2.0) | time=0.006961s;;;0.100000;11.000000'

Thanks
Joseph
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Can I update Nagios active service status using Rest API

Post by ssax »

It's not currently possible to do multiple POSTs with curl over the same connection.

I'm not a C# guy but I found this:

https://makolyte.com/csharp-how-to-make ... ttpclient/
Locked