Host Multiple -> Hostgroup Inheritance Sources/Priority

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jonatgil
Posts: 18
Joined: Thu Jan 31, 2019 7:26 am

Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by jonatgil »

Hello guy,
I'm in the following situation.
I got a bunch of windows server. And I would like to apply a default hostgroup for every host that would have service attacge to it.
->''Check_C_Drive".
I have a few servers that would require to have a different check_C_Drive, for example a check with less resource.

I would like to select witch host group have the priority over the other. In the Nagios XI UI. Even if I try to put one first and put the other after. After saving the configuration, the order is change and sort in alphabetic Order.
I though the order would go up to down or inverse similar to the list of hostgroup with comma but it's does seems to take it.

Do you have any idea?

When I check the file configuration it's always staying in this order.
Is there a way to invert those that in the UI ?

hostgroups win_check_C_Hight,win_check_Default

Thank you.

https://assets.nagios.com/downloads/nag ... tance.html


Note: At the moment I'm only testing this behavior. At the moment I cannot put the ''win_check_Default'' before the ''win_check_C_Hight'' since the letter C is before the D and it's doing some sort of aphabic sort. I know I could change the name of the hostgroup but that's is not the ideal situation.
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by SteveBeauchemin »

You could use Free Variables (FV) to solve this.

Where I work we have some systems with very small drives, and some with Huge drives. The 2 different systems need to run tests using different thresholds. The small systems can provide a warning at 4% free and critical at 2% free with no problem. On the Huge disk, 4% free could be 800GB and they do not want alerts. So on the small system we use 2% and 4% free for thresholds and on the big disk we may use 4GB and 2GB free for alert thresholds.

We use one service test for this. It works on both disk sizes. The way we do it is to have the common Host Template store a default warning and critical threshold. To the Host template we add 2 Free Variables. For example:

Code: Select all

__DRIVE_C_WARN_FREE	4%
__DRIVE_C_CRIT_FREE	2%
Since the FV are in a template they get inherited by all hosts using the template. A single Service tied to a single Host Group is all we use.
The Free Variable name __DRIVE_C_WARN_FREE will be converted to a macro named $_HOST_DRIVE_C_WARN_FREE$ by Nagios when it runs. I use extra underscores to make the variable easier to read later. Basically, we make free variables but we use Macros.

The power of this approach is that you can now make exceptions host by host as needed.

The initial setup uses the same setting for all systems. Here are some command and service definitions I use to do this. I will show a C drive example.
Check command:

Code: Select all

/usr/local/nagios/libexec/check_nrpe --unknown-timeout --timeout 120:3 --host $HOSTADDRESS$ --command $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$
Service Definition:

Code: Select all

$ARG1$ = check_drivesize
$ARG2$ = -a "drive=c:"
$ARG3$ = "filter=size>1G"
$ARG4$ = "warn=free<$_HOST_DRIVE_C_WARN_FREE$"
$ARG5$ = "crit=free<$_HOST_DRIVE_C_CRIT_FREE$"
$ARG6$ = "detail-syntax=Drive %(drive) (Currently %(total_free) %(free_pct)% Available) Thresholds: Warn lt $_HOST_DRIVE_C_WARN_FREE$, Crit lt $_HOST_DRIVE_C_CRIT_FREE$"
$ARG7$ = show-all
This will use the Template definition with 2% and 4%. So that covers 'most' of the systems. The output looks like this.

Code: Select all

OK Drive c: (Currently 3.345GB 4% Available) Thresholds: Warn lt 4%, Crit lt 2%|'c: free'=3.34494GB;3.19992;1.59996;0;79.99804 'c: free %'=4%;4;2;0;100
Now lets edit one host, add the FV, and use different thresholds.
Edit a host definition for a system that needs different thresholds. Open the Misc tab and add FV.

Code: Select all

__DRIVE_C_WARN_FREE	4GB
__DRIVE_C_CRIT_FREE	2GB
So now this one host uses the same service definition as all the other hosts, but has different alerting criteria and looks like this.

Code: Select all

OK Drive c: (Currently 71.529GB 71% Available) Thresholds: Warn lt 4G, Crit lt 2G|'c: free'=71.52921GB;4;2;0;99.99804 'c: free %'=72%;4;2;0;100
Single Service, single Host Group, single Host Template, different Free Variable depending on the host.

This methodology can be applied in many places.

Hope this helps.

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by cdienger »

Thanks for sharing the excellent post, @SteveBeuchemin!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jonatgil
Posts: 18
Joined: Thu Jan 31, 2019 7:26 am

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by jonatgil »

Thank you SteveBeauchemin for this wonderfull solution. Will try it out for sure tomorrow.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by cdienger »

Keep us posted.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jonatgil
Posts: 18
Joined: Thu Jan 31, 2019 7:26 am

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by jonatgil »

Did not try it out at the end since it would have been to advance for the team but the idea was pretty good.
Thank you for sharing the idea.
Can close the post .
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Host Multiple -> Hostgroup Inheritance Sources/Priority

Post by scottwilkerson »

jonatgil wrote:Did not try it out at the end since it would have been to advance for the team but the idea was pretty good.
Thank you for sharing the idea.
Can close the post .
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked