Does nagios API will help to add multiple servers at a time
-
grayloglearn
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Does nagios API will help to add multiple servers at a time
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.
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
In this case it would be easiest to run a wizard for one of the machines selecting all the services you want.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.
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
-
grayloglearn
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Does nagios API will help to add multiple servers at a t
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
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
Help -> Config Reference -> POST config/host
and
Help -> Config Reference -> POST config/service
Documentation and examples are available in the Help section
-
grayloglearn
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Does nagios API will help to add multiple servers at a t
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¬ification_interval=5¬ification_period=24x7&applyconfig=1"
-bash: !check_disk!-a: event not found
understand something is missing could not find it.
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¬ification_interval=5¬ification_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
You need to escape the ! in the command with \!
Like so
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¬ification_interval=5¬ification_period=24x7&applyconfig=1"-
grayloglearn
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Does nagios API will help to add multiple servers at a t
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.
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
You would just make one API call for each service added to each hostgrayloglearn 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.
-
grayloglearn
- Posts: 222
- Joined: Thu Jul 06, 2017 8:55 am
Re: Does nagios API will help to add multiple servers at a t
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
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
That is correct.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.
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.grayloglearn wrote:Don't we have api to add the multiple host and multiple services?? I hope it should be there