New feature patch: using hostgroups or servicegroups as arguments to on-demand macros

Christopher Gurnee gurnec at gis.net
Sat Mar 27 02:42:43 CET 2004


On-demand macros are a great thing, and the check_cluster2 plug-in is a
great way to use them. Unfortunately, if you want to use more than a few
on-demand macros on a single line, it can be a bit of a pain (but of
course, works just fine). This patch lets you use a hostgroup or
servicegroup name as an argument to an on-demand macro, and then expands
the macro appropriately with respect to all the members of the group.
For example, instead of saying:

check_command
check_service_cluster!"DNS"!1!5!$SERVICESTATEID:dns-server-1:DNS$,$SERVI
CESTATEID:dns-server-2:DNS$,...

you can define a service group (using regular expressions in this case):

define servicegroup{
  servicegroup_name All-DNS
  alias             All DNS services
  members           dns-server-[0-9]*,DNS
}

and then replace all of the SERVICESTATEID macros in the check_command
with:

$SERVICESTATEID:All-DNS:,$

This will expand to all of the SERVICESTATEIDs of all of the services in
the All-DNS servicegroup, separated by commas. After this patch, there
are 4 ways to use on-demand macros:

$HOSTMACRO:host$
$HOSTMACRO:hostgroup:delimiter$
$SERVICEMACRO:host:service$
$SERVICEMACRO:servicegroup:delimiter$

The delimiter is used to separate the results after expanded (it doesn't
have to be a single character, but it will usually just be a comma).
Note that this adds an ambiguity with on-demand service macros. In order
to differentiate in between the last two lines above, Nagios will first
try to expand an on-demand service macro as a
$SERVICEMACRO:host:service$, and if that doesn't work (if host:service
doesn't exist), then Nagios will try it as
$SERVICEMACRO:servicegroup:delimiter$.

Please be forewarned; although I've done a little testing, I can't be
sure this doesn't introduce some new bug....

Regards,
Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios-groups-for-on-demand-macros.patch
Type: application/octet-stream
Size: 7492 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20040326/c3081e33/attachment.obj>


More information about the Developers mailing list