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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
grayloglearn
Posts: 222
Joined: Thu Jul 06, 2017 8:55 am

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

Post 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 :-)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked