Page 1 of 1
Automate Adding Metrics To Host Via Templates Or Api
Posted: Thu Jan 24, 2019 11:49 pm
by rtpipkin
Hi, I’m in the process of setting up a new Nagios XI system and want to automate setup of our host/service configuration.
I found instructions on setting up templates and host groups, and also api calls for adding hosts and services. However, I can’t seem to find anything on how to add metrics like cpu, memory and disk like what happens with the configuration wizards.
I’m using Nagios XI 5.5.8 Redhat Linux 7 and NRPE agent on CentOS 7.
Is this possible? And if so is there a reference of which commands to use and their arguments?
Re: Automate Adding Metrics To Host Via Templates Or Api
Posted: Fri Jan 25, 2019 3:03 pm
by rtpipkin
I haven't found specific documentation on the template process yet. But I stumbled across a way to figure i t out. Basically, I just used a host and service configured via the wizard then under the service's Configure tab I chose to Reconfigure This Service.
The command is under “Monitor the service with this command:(Advanced users only)”
check_nrpe!check_cpu_stats!-a '-w 85 -c 95'
When setting up the template I chose the check command as check_nrpe the $ARG1$ as check_cpu_stats and $ARG2$ as -a ‘-w 85 -c 95’. So basically the command and args are the string from "Monitor ... this command" with exclamation point delimiter.
Setup the service and run test. This command returns the following
[nagios@e2lxnagweb01 ~]$ /usr/local/nagios/libexec/check_nrpe -H 10.203.26.108 -t 30 -c check_cpu_stats -a '-w 85 -c 95'
CPU STATISTICS OK: user=4.98% system=4.48% iowait=0.10% idle=90.44% | user=4.98% system=4.48% iowait=0.0%;85;95 idle=90.44%
Some Documentation Here on this specific command.
https://exchange.nagios.org/directory/P ... sh/details
Re: Automate Adding Metrics To Host Via Templates Or Api
Posted: Fri Jan 25, 2019 4:42 pm
by npolovenko
Hello,
@rtpipkin. Are you looking to automate the creation of multiple hosts with different IP addresses but similar sets of services?
If that is the case you could add one host(manually or using a wizard), then copy the host and service configs to a notepad and multiply them in a text file replacing host IP address and hostname. Then import the new file with configs using the import tool in the CCM.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Re: Automate Adding Metrics To Host Via Templates Or Api
Posted: Fri Jan 25, 2019 5:51 pm
by rtpipkin
Hi @npolovenko,
Yes, your description of my use case is correct. We're using Chef and Jenkins to manage provisioning and configuration of groups of identical servers across multiple sites.
This is very helpful. I'll give your suggestion a try and see if it works better for our processes.
Thanks!
Re: Automate Adding Metrics To Host Via Templates Or Api
Posted: Mon Jan 28, 2019 3:40 pm
by npolovenko
@rtpipkin, No problem. You can also copy manually written configs to the /usr/local/nagios/etc/import/ folder and then run the /usr/local/nagiosxi/scripts/reconfigure_nagios.sh script. This is an alternative if you don't want to use GUI.