Page 1 of 1

Does nagios API will help to add multiple servers at a time

Posted: Mon Sep 02, 2019 7:55 am
by grayloglearn
Hi Team,

Does nagios API will help us to add the multiple servers at a time in nagios console.

EX: We have installed nagios agent in 50 servers.
I want to add those servers in nagiosXI at a time with default services. Does it possible how we can do this.
And what are best features we have using Nagios API and how we can use nagios API with different ways.

Re: Does nagios API will help to add multiple servers at a t

Posted: Tue Sep 03, 2019 8:07 am
by scottwilkerson
grayloglearn wrote:EX: We have installed nagios agent in 50 servers.
I want to add those servers in nagiosXI at a time with default services. Does it possible how we can do this.
In this case it would be easiest to run a wizard for one of the machines selecting all the services you want.

Then once that is setup, run the bulk host cloning wizard and you can add the other 49 by just adding a list of IPs and hostnames

Re: Does nagios API will help to add multiple servers at a t

Posted: Tue Sep 03, 2019 10:04 pm
by grayloglearn
I understand above suggestions, but we want to try with Nagios API Could you please help with commands and process. So that it will help us.

Re: Does nagios API will help to add multiple servers at a t

Posted: Wed Sep 04, 2019 6:35 am
by scottwilkerson
You would send the post requests see in
Help -> Config Reference -> POST config/host
and
Help -> Config Reference -> POST config/service

Documentation and examples are available in the Help section

Re: Does nagios API will help to add multiple servers at a t

Posted: Mon Sep 09, 2019 11:24 am
by grayloglearn
Hi team,

thanks for the replay, As you said we have tried to add the host which is working fine where as while we adding the service Ex: Drive we are not able to add.
curl -XPOST "http://XXXXXX.compute-1.amazonaws.com/n ... Y&pretty=1" -d "host_name=x.x.x.x8&service_description=Disk_Space Usage&check_command=check_nrpe!check_disk!-a '-w 20% -c 10% -p /'&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1"

-bash: !check_disk!-a: event not found

understand something is missing could not find it.

Re: Does nagios API will help to add multiple servers at a t

Posted: Mon Sep 09, 2019 11:40 am
by scottwilkerson
You need to escape the ! in the command with \!

Like so

Code: Select all

curl -XPOST "http://XXXXXX.compute-1.amazonaws.com/nagiosxi/api/v1/config/service?apikey=Um0fd3e3niAJkOERRbjqsHk7RQvOAI3Lk3ZQ5dSsPIrps5BjgT32AH8HtXrjFt4Y&pretty=1" -d "host_name=x.x.x.x8&service_description=Disk_Space Usage&check_command=check_nrpe\!check_disk\!-a '-w 20% -c 10% -p /'&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1"

Re: Does nagios API will help to add multiple servers at a t

Posted: Tue Sep 10, 2019 1:41 am
by grayloglearn
thanks its working fine.

If i want to add the multiples services(memory use, drive ...etc) for single host how to do it. Could you please provide the API please for multiple services on single host...

And if we want add the multiples host what would be the API. Could you please provide the API please.

Re: Does nagios API will help to add multiple servers at a t

Posted: Tue Sep 10, 2019 6:29 am
by scottwilkerson
grayloglearn wrote:thanks its working fine.

If i want to add the multiples services(memory use, drive ...etc) for single host how to do it. Could you please provide the API please for multiple services on single host...

And if we want add the multiples host what would be the API. Could you please provide the API please.
You would just make one API call for each service added to each host

Re: Does nagios API will help to add multiple servers at a t

Posted: Wed Sep 11, 2019 11:45 pm
by grayloglearn
you meant to say to add each host we need to create each host api
and if we want add the services we need create each service API, correct me if i am wrong.

Don't we have api to add the multiple host and multiple services?? I hope it should be there :-)

Re: Does nagios API will help to add multiple servers at a t

Posted: Thu Sep 12, 2019 7:13 am
by scottwilkerson
grayloglearn wrote:you meant to say to add each host we need to create each host api
and if we want add the services we need create each service API, correct me if i am wrong.
That is correct.
grayloglearn wrote:Don't we have api to add the multiple host and multiple services?? I hope it should be there
The API is designed to be used like any other API, and you can programmatically loop through the hosts or services you want to create, but each item is an individual call.