Xymon Mailing List Archive search

creating a macro made of macro's in hobbit-alerts.cfg

list Henrik Størner
Wed, 25 May 2005 21:54:54 +0200
Message-Id: <user-f2aa841692d3@xymon.invalid>

On Wed, May 25, 2005 at 02:58:18PM -0400, Tom Georgoulias wrote:
Is it possible to create some macros of hosts, then bundle combinations 
of those smaller macros into larger ones?
It's supposed to work, yes. And yes - there's a bug in how this is
handled. You need the attached patch first.
Say I have 3 groups of systems:

$DB=%(db1|data1|dbase).domain.com

$MAIL=%(mail1|smtp|webmail).domain.com

$WS=%(ws1|fred|wilma).domain.com

I'd like to make 2 macros of those systems, one for critical systems, 
the other for everthing on my network:

$CRITICAL=%($DB|$MAIL)

$ALL=%($DB|$MAIL|$WS)
When doing this, remember that the macros are simple text-substitutions.
So I'd leave out the "%" in the macros, because you end up with too many
of them they way you have it. Instead, I'd do it like this:

   $DB=(db1|data1|dbase).domain.com
   $MAIL=(mail1|smtp|webmail).domain.com
   $WS=(ws1|fred|wilma).domain.com

   $CRITICAL=($DB|$MAIL)
   $ALL=($DB|$MAIL|$WS)

   HOST=%$CRITICAL
      MAIL user-590e80d9822c@xymon.invalid

If in doubt, you can always run "hobbitd_alert --dump-config" to see
what your configuration ends up with - it shows the configuration after
expanding the macros.


Regards,
Henrik

-------------- next part --------------
--- hobbitd/do_alert.c	2005/05/22 07:31:22	1.65
+++ hobbitd/do_alert.c	2005/05/25 19:47:11
@@ -379,7 +379,7 @@
 			delim = strchr(l, '=');
 			*delim = '\0';
 			newtok->name = strdup(l+1);	/* Skip the '$' */
-			newtok->value = strdup(delim+1);
+			newtok->value = strdup(preprocess(delim+1));
 			newtok->next = tokhead;
 			tokhead = newtok;
 			continue;