creating a macro made of macro's in hobbit-alerts.cfg
list Tom Georgoulias
Is it possible to create some macros of hosts, then bundle combinations of those smaller macros into larger ones? 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) Then use only the variables $CRITICAL or $ALL as my HOST=<variable name> entry. If this can be done, I'm having problems getting the syntax right. Any pointers? Thanks, Tom
list Asif Iqbal
▸
On Wed, May 25, 2005 at 02:58:18PM, Tom Georgoulias wrote:
Is it possible to create some macros of hosts, then bundle combinations of those smaller macros into larger ones? 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) Then use only the variables $CRITICAL or $ALL as my HOST=<variable name> entry. If this can be done, I'm having problems getting the syntax right. Any pointers?
I could benefit from this too. What I found out is that it does not like macro made out of macro. Thanks -- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu "..there are two kinds of people: those who work and those who take the credit...try to be in the first group;...less competition there." - Indira Gandhi
list Henrik Størner
▸
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;
list Tom Georgoulias
▸
Henrik Stoerner wrote:
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.
Thanks for the patch and the tip on grouping. I've got nested macros working now, and it has really cleaned up my hobbit-alerts.cfg file! :) Tom