Automate Adding Metrics To Host Via Templates Or Api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rtpipkin
Posts: 5
Joined: Tue Jan 15, 2019 8:31 pm

Automate Adding Metrics To Host Via Templates Or Api

Post 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?
rtpipkin
Posts: 5
Joined: Tue Jan 15, 2019 8:31 pm

Re: Automate Adding Metrics To Host Via Templates Or Api

Post 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
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Automate Adding Metrics To Host Via Templates Or Api

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
rtpipkin
Posts: 5
Joined: Tue Jan 15, 2019 8:31 pm

Re: Automate Adding Metrics To Host Via Templates Or Api

Post 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!
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Automate Adding Metrics To Host Via Templates Or Api

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked