per host custom macros

John P. Rouillard rouilj at cs.umb.edu
Thu Mar 30 00:14:22 CEST 2006


In message <1143655576.9440.310.camel at chi101100.int.tt.local>,
jeff vier writes:
>On Wed, 2006-03-29 at 12:55 -0500, David Mansfield wrote:
>
>> Something like:
>>=20
>> define host {
>> 	use generic-host
>> 	host_name myhost.mydomain.com
>> 	alias myhost
>> 	address 1.2.3.4
>> 	custom_macro FOOPROPERTY=3DAA:BB:CC:DD
>> 	custom_macro BARVALUE=3DBigImportantValue

(rouilj addition)
        custom_macro EXTERNAL_WEB_INTERFACE=192.169.33.10

>> 	hostgroups all_foo,all_bar,runs_external_http
>> }
>> With:
>> define hostgroup {
>> 	name all_foo
>> 	alias all_foo
>> }
>> define service {
>> 	hostgroup_name all_foo
>> 	check_command check_foo
>> }
(rouilj addition)
   define service {
        service_description    check_http

 	hostgroup_name runs_external_web
 	check_command check_http!-H $EXTERNAL_WEB_INTERFACE$
   }
   define service {
        service_description  check_certitifcate_exp
 	hostgroup_name runs_external_web
 	check_command check_http!-H $EXTERNAL_WEB_INTERFACE$ -C 30 --ssl
   }
   define service {
 	hostgroup_name runs_external_web
 	check_command check_apache!-H $EXTERNAL_WEB_INTERFACE$
   }
>> And finally, the payoff:
>> define command {
>> 	command_name check_foo
>> 	command_line $USER1$/check_foo -f $FOOPROPERTY$
>> }
(rouilj addition)
   define command {
	command_name check_http
	command_line $USER1$/check_http $ARG1$
   }

>You've pretty much exactly described $ARG1$, $ARG2$, ... $ARGn$

Not at all.  Using my augmented config above, change the web address
to 193.169.10.2.

Only one line changes. Using a hardcoded argument in the service
definition 10 lines have to change.

Hardcoding the server IP in the service check is much more labor
intensive. Say you have 10 services for each host in the hostgroup,
and you have 20 hosts. You now have 200 services to define, one for
each argument. This way you have 10 services to define. You add a new
host, add one new host definition and no service definitions.

It's a major pain for 100 services that you want to run for a
hostgroup. Yes, I can write perl one-liners just as well as the next
guy but I still have to verify every change in the diff.

This is also a nice way to handle multiple interfaces on devices as
well. Define hostgroups and macros for each interface. Want to shut
down the host, simply put host in downtime and all services defined on
that host (regardless of interface) are shut down.

No need to create multiple hosts in nagios, one for each interface you
want to define like you do now in nagios. Want to shut down the host
with this setup, you have to down each host you defined.

I am working on a hack using filepp (the 'for' macro is nice) to
define alternate interfaces as #define macros that cause expansion of
the "hostgroup" service definitions. Also it is designed to allow
generation of servicedependencies. If I get it working well,
I'll post it to allow enhancing the configuration language.

				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list