Registering host & services with curl

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dockeronlineee
Posts: 1
Joined: Wed Jan 22, 2020 1:48 pm

Registering host & services with curl

Post by dockeronlineee »

I want to automatically register host and some base services witu curl commands after server install.
I can register host, uptime seems to be OK, everything went smooth - no problem there.
But, when i try to add service to this host i can't get the right data.
So, curl command is as follows:

Code: Select all

curl -XPOST "http://192.168.0.58/nagiosxi/api/v1/config/service?apikey=APIKEYGOESHERE&pretty=1" -d 'host_name=worker1&address=192.168.0.33&service_description=Memory Usage&check_interval=5&retry_interval=3&check_command=check_local_mem\!30\!20&check_interval=5&retry_interval=1&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1'
hostname: worker1 - correct
address: 192.168.0.33 - correct
nagiosxi address: 192.168.0.58 - corrent.
After i apply command i get:

Code: Select all

"success": "Added worker1 :: Memory Usage to the system. Config applied, Nagios Core was restarted."
So, host worker1 memory data from command line:

Code: Select all

              total        used        free      shared  buff/cache   available
Mem:           1.9G        163M        984M 
What nagios reports:

Code: Select all

Memory Usage	Ok	7m 3s	1/2	2020-01-22 20:58:08	OK - 2876 / 3789 MB (75%) Free Memory, Used: 755 MB, Shared: 136 MB, Buffers + Cached: 711 MB
And what nagios reports for localhost (nagiosxi itself):

Code: Select all

Memory Usage	Ok	42d 23h 44m 35s	1/4	2020-01-22 20:56:54	OK - 2890 / 3789 MB (76%) Free Memory, Used: 741 MB, Shared: 136 MB, Buffers + Cached: 711 MB
Basically the same.
Under host management i can see:

Code: Select all

Host Name *
worker1
Alias
worker1
Address *
192.168.0.33
snmpd is installed and service is running on host

So, the questions are:
Is something wrong with curl command and/or why nagios reports itself data for another node?
Can't communicate with worker1 and that's why reports itself data?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Registering host & services with curl

Post by scottwilkerson »

You are setting the check_command to

Code: Select all

check_local_mem!30!20
I would suggest setting up a server using a Wizard and inspect what you want the check_command line to be.

I would assume that check_local_mem command only checks the command on the local system (i.e. not remove like SNMP)
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked