To automatically add new hosts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mlawrence
Posts: 6
Joined: Thu Oct 25, 2012 7:07 pm

To automatically add new hosts

Post by mlawrence »

Hello - my company is planning on using AWS auto-scaling. We use Chef recipes to help configure new instances and I am looking at how to best craft a recipe to automatically add new instances to Nagios XI.

So far I have found this document:

http://assets.nagios.com/downloads/nagi ... gement.pdf

And I believe I can script around what is described there for adding new hosts via Chef. What I like about this method is that the hosts can then be easily removed from XI programatically without XI complaining about any dependencies with just one command as all of its services live in one place. With auto-scaling in particular we will need a scripted method for instances to remove themselves from XI to prevent false alarms.

However, we also wanted to leverage hostgroups as a way of adding in new systems for a number of reasons. One was to keep the number of services we have in XI trim/scalable. Also we want to be able to easily change a monitoring service config setting and have it automatically apply to all hosts in a hostgroup. If we add all of our hosts via the method described in the "Automated Host Management" doc it will make them more difficult to manage them as we'd have to change settings for every host rather than for just one service.

So I am wondering what other command line options are available with XI? Is there any way to add/remove a host to a hostgroup via the command line?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: To automatically add new hosts

Post by scottwilkerson »

There aren't any other methods, but you do realize that in the config you create you can add a hostgroup to have all the services that contain that hostgroup applied

ie.

Code: Select all

define host{
     host_name LOC_MASShost_1
     hostgroups windows-servers
     address 127.0.0.1
     use xiwizard_generic_host
}
Then, if you have hostgroup windows-servers added to any services, this new host will have all those services added.

The only difference here is that when you remove these hosts you will not remove the service that had the host group added.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mlawrence
Posts: 6
Joined: Thu Oct 25, 2012 7:07 pm

Re: To automatically add new hosts

Post by mlawrence »

I had thought of doing it like that, but if I do will the delete_host command work or will it complain that the host is part of a hostgroup - ie would that cause some dependency problem for automatic removal? Going to test it out when I get a chance but if the removal part works then I think this is a great solution.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: To automatically add new hosts

Post by scottwilkerson »

No it would not, because the hostgroup is added to the host definition and not the other way around...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mlawrence
Posts: 6
Joined: Thu Oct 25, 2012 7:07 pm

Re: To automatically add new hosts

Post by mlawrence »

Yep just tested and it works well, I had always thought you had to define hostgroup members in the hostgroup object and didn't realize you could do it in the host objects as well. Only snag was making the directive "hostgroups" instead of "hostgroup" in the .cfg. But it's being added, picking up the right services from the hostgroup, and gets deleted with no complaints - all we wanted, thanks for the advice!
Locked