[hobbit] find-host/bbhostgrep with page/subpage and includes
Henrik Stoerner
henrik at hswn.dk
Sat Apr 1 11:01:20 CEST 2006
On Sat, Apr 01, 2006 at 10:02:52AM +0200, Dominique Frise wrote:
> --- bb-hosts ---
> 130.223.8.20 uldns1 # dhcp dns smtp ldap://uldns1/o=universite%20de%20lausanne,c=ch
> 130.223.4.5 uldns2 # dhcp dns smtp ldap://uldns2/o=universite%20de%20lausanne,c=ch
> include bb-hosts.acadSys
>
> --- bb-host.acadSys ---
> 130.223.8.20 uldns1 # prefer noconn COMMENT:"Prim. DNS/DHCP/People LDAP/MailGateway"
> 130.223.4.5 uldns2 # prefer noconn COMMENT:"Sec. DNS/DHCP/People LDAP/MailGateway"
>
> With the simplified configuration above, when I look for "uldns1" with
> find-host I have following result:
[snip]
> Host uldns1 appears for times!
That's a bug. Attached a patch to fix it.
> Also bbhostgrep in custom script doesn't show what I would expect:
> [bb at iris etc]$ bbhostgrep dhcp
>
>
> When I put "dispinclude" instead of "include" in bb-hosts, I have:
> [bb at iris etc]$ bbhostgrep dhcp
> 130.223.8.20 uldns1 # dhcp
> 130.223.4.5 uldns2 # dhcp
>
> Am I missing something?
This is really a configuration problem. When using the "prefer" tag, you
also tell bbhostgrep to look at only the "preferred" entry in the
bb-hosts file. So you really should have put the network tests on the
preferred entry in bb-hosts.
bbtest-net takes a somewhat more cautious approach, and performs all of
the network tests it sees.
But I agree that it is a trap that is easy to fall into. So perhaps
bbhostgrep should ignore the "prefer" ? At least when looking for
tests to run, which is what it will commonly be used to do. So
I've added an enhancement to bbhostgrep which does that.
Henrik
-------------- next part --------------
--- web/bb-findhost.c 2006/03/12 16:38:32 1.26
+++ web/bb-findhost.c 2006/04/01 08:26:48
@@ -37,7 +37,7 @@
*
*/
-static char rcsid[] = "$Id: bb-findhost.c,v 1.26 2006/03/12 16:38:32 henrik Exp $";
+static char rcsid[] = "$Id: bb-findhost.c,v 1.27 2006/04/01 08:26:37 henrik Exp $";
#include <stdio.h>
#include <string.h>
@@ -154,7 +154,8 @@
printf("<td align=left><font color=red>%s</font></td></tr>\n", re_errstr);
} else {
- for (hostwalk=hosthead; (hostwalk); hostwalk = hostwalk->next) {
+ hostwalk = hosthead;
+ while (hostwalk) {
/*
* [wm] - Allow the search to be done on the hostname
* also on the "displayname" and the host comment
@@ -195,6 +196,10 @@
printf("</td>\n</tr>\n");
gotany++;
+ hostwalk = clonewalk;
+ }
+ else {
+ hostwalk = hostwalk->next;
}
}
-------------- next part --------------
--- common/bbhostgrep.c 2006/03/29 16:07:14 1.33
+++ common/bbhostgrep.c 2006/04/01 08:58:58
@@ -13,7 +13,7 @@
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: bbhostgrep.c,v 1.33 2006/03/29 16:07:14 henrik Exp $";
+static char rcsid[] = "$Id: bbhostgrep.c,v 1.34 2006/04/01 08:58:37 henrik Exp $";
#include <stdio.h>
#include <string.h>
@@ -104,6 +104,7 @@
int extras = 1;
int testuntagged = 0;
int nodownhosts = 0;
+ int onlypreferredentry = 0;
char *p;
char **lookv;
int argi, lookc;
@@ -139,9 +140,11 @@
}
else if (strcmp(argv[argi], "--bbnet") == 0) {
include2 = "netinclude";
+ onlypreferredentry = 0;
}
else if (strcmp(argv[argi], "--bbdisp") == 0) {
include2 = "dispinclude";
+ onlypreferredentry = 1;
}
else if (argnmatch(argv[argi], "--bbhosts=")) {
bbhostsfn = strchr(argv[argi], '=') + 1;
@@ -218,7 +221,7 @@
}
}
- do { hwalk = hwalk->next; } while (hwalk && (strcmp(curname, hwalk->bbhostname) == 0));
+ do { hwalk = hwalk->next; } while (hwalk && onlypreferredentry && (strcmp(curname, hwalk->bbhostname) == 0));
}
return 0;
More information about the Xymon
mailing list