Automating Services/Hosts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Automating Services/Hosts

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Automating Services/Hosts

Post 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.
Former Nagios employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Automating Services/Hosts

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Automating Services/Hosts

Post 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.
Former Nagios employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Automating Services/Hosts

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Automating Services/Hosts

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: Automating Services/Hosts

Post 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 :).

Code: Select all

AAAA, BBBB, CCCC, DDDD
Thxs for your help!!!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Automating Services/Hosts

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked