Adding a new host for monitoring
Adding a new host for monitoring
Hi,
We would like to write an automated script to add any new hosts to Nagios for monitoring.
This helps when we have huge number of servers to be added at once, takes time if we use Nagios XI.
Could you please let us know if we can do this way, if so how can we ?
Add a host to nagios monitoring by backend in nagios server and not through Nagios XI.
Map the host to the host group by backend in nagios server and not through Nagios XI.
We already have services mapped to hostgroup so it will work from there on.
Thanks.
We would like to write an automated script to add any new hosts to Nagios for monitoring.
This helps when we have huge number of servers to be added at once, takes time if we use Nagios XI.
Could you please let us know if we can do this way, if so how can we ?
Add a host to nagios monitoring by backend in nagios server and not through Nagios XI.
Map the host to the host group by backend in nagios server and not through Nagios XI.
We already have services mapped to hostgroup so it will work from there on.
Thanks.
Re: Adding a new host for monitoring
You can use the API, that's the best method that you can use. See the API section under the Help menu for working examples. See here specifically:
Or you can manually manage them (they won't be listed in the CCM then):
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Technically, you can create the configs and then import them as well:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Let us know if you have any questions.
Code: Select all
http://YOURXISERVER/nagiosxi/help/api-config-reference.php#add-hosthttps://assets.nagios.com/downloads/nag ... ios-XI.pdf
Technically, you can create the configs and then import them as well:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Let us know if you have any questions.
Re: Adding a new host for monitoring
Thanks for the link, it helped us.
We were able to add new host using the command.
Could you please let us know if we can add the host to a particular host group using command line.
We didn't find such thing in the link, though we were able to create host group using command line.
Thanks.
We were able to add new host using the command.
Could you please let us know if we can add the host to a particular host group using command line.
We didn't find such thing in the link, though we were able to create host group using command line.
Thanks.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding a new host for monitoring
Yes, if using the API you would add the following to the string after -d &hostgroups=YOURHOSTGROUP
In the other scenarios you would add it inside the host define like
In both cases the hostgroup must previously exist
In the other scenarios you would add it inside the host define like
Code: Select all
hostgroups YOURHOSTGROUPRe: Adding a new host for monitoring
Hi,
This command is not working.
curl -XPOST "https://10.106.93.70/nagiosxi/api/v1/co ... y&pretty=1" -d "host_name=testapihost1&address=127.0.0.1&hostgroups=Linux_server_VM&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1" -k
It is not adding the host to the hostgroup.
Kindly advise.
This command is not working.
curl -XPOST "https://10.106.93.70/nagiosxi/api/v1/co ... y&pretty=1" -d "host_name=testapihost1&address=127.0.0.1&hostgroups=Linux_server_VM&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&applyconfig=1" -k
It is not adding the host to the hostgroup.
Kindly advise.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding a new host for monitoring
Hmm, I just tested this on a 5.7.1 system and it worked as expected. Do you have a host group named Linux_server_VM specifically with underscores and case sensitive?
Re: Adding a new host for monitoring
Yes we do have it with same name.
But still host is not getting added to the hostgroup.
But still host is not getting added to the hostgroup.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding a new host for monitoring
What version of Nagios XI are you running?ets_user wrote:Yes we do have it with same name.
But still host is not getting added to the hostgroup.
Re: Adding a new host for monitoring
It is Nagios XI 5.5.6 .
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Adding a new host for monitoring
Adding hostgroups and servicegroups was not added until 5.6.0