Page 1 of 1
Automating Services/Hosts
Posted: Mon Jun 15, 2015 9:01 am
by haile711
Hey everyone,
I need some suggestions and or advise. I need to do some automation for Nagios monitoring. I've set up a scenario.
Basically, we have tons of VM provision everyday for our environment, and majority of these VMs will have the same setup and services need to be monitored, lets say JVM/JMX metrics.
Is there a way to put these same "services" to be monitored out to all these newly provisioned VMs? I might missed a thing here and there with my thought processes, let me know if I need to clarify anything. Thanks for looking and helping out guys.
Re: Automating Services/Hosts
Posted: Mon Jun 15, 2015 9:07 am
by tmcdonald
I would do this with passive checks if possible. I assume you have this deployment automated? If so, you could use something like Puppet/Chef/Salt/Ansible to set up a monitoring agent that will send the results back to Nagios. This has the advantage of automation and somewhat lower load on the Nagios machine since it only has to worry about processing the check results and not actually running them.
I can't say there is much in the way of automatically provisioning active checks - we have the Autodiscovery Wizard, but that is more for a broad scan of a network than for fine-tuned checks. You could do a lot of the work required by using templates and host/service groups, but as far as "When a new host is brought up give it X, Y, and Z checks" I would go with the passive route.
Re: Automating Services/Hosts
Posted: Mon Jun 15, 2015 9:42 am
by haile711
hey tmcdonald,
yea we already have nrpe agent automated for deployment with chef. Do we have to setup services to be monitored when we deployed this agent too?
Re: Automating Services/Hosts
Posted: Mon Jun 15, 2015 9:47 am
by tmcdonald
NRPE is for active checks - it allows Nagios to make requests to the NRPE agent which then returns the results of whatever Nagios asks. Think of it as a sort of proxy.
For passive checks, you will want to use something like NSCA or (preferably) NRDP:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Edit: I just noticed that in the second set of links on the first page for NRDP, the lower link still points to the NSCA doc but the upper link works for NRDP. I will get this updated.
Re: Automating Services/Hosts
Posted: Wed Jun 17, 2015 4:53 pm
by gormank
Our services have hostgroups connected to them, and hosts are also connected to hostgroups. Most of what defines a host and/or service can be in templates. This makes the host/service definitions smaller and easier to manage.
If you create a file that contains the info for a generic host, with placeholders for hostname, alias, and address, you can use a script running from cron to create hosts. Put the resulting hostname.cfg file in the import dir and run the standard update script to import the hosts. I don't recall the name of the script, but it does what's behind the apply configuration button in CCM.
Re: Automating Services/Hosts
Posted: Thu Jun 18, 2015 1:08 am
by Box293
gormank wrote:Put the resulting hostname.cfg file in the import dir and run the standard update script to import the hosts. I don't recall the name of the script, but it does what's behind the apply configuration button in CCM.
Code: Select all
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
Re: Automating Services/Hosts
Posted: Thu Jun 18, 2015 10:08 am
by haile711
Hello everyone,
Im trying to automate adding new hosts the Nagios, I'm not good with scripting. Does anyone know a good script to pull data from database and insert them into a file in this format or a good lead

.
Thxs for your help!!!
Re: Automating Services/Hosts
Posted: Thu Jun 18, 2015 11:04 am
by lmiltchev
Basically, we have tons of VM provision everyday for our environment, and majority of these VMs will have the same setup and services need to be monitored, lets say JVM/JMX metrics.
If you have many similar hosts/services, you can set up one host, use it as a template and bulk clone it from the command line. Please, read through the following post to see how you can do this:
http://support.nagios.com/forum/viewtop ... 16&t=32968
Hope this helps.