Xymon Mailing List Archive search

find-host/bbhostgrep with page/subpage and includes

3 messages in this thread

list Dominique Frise · Sat, 01 Apr 2006 10:02:52 +0200 ·
Hi,

--- bb-hosts ---
title Common Services
#
page comServDNS DNS
group-only conn|dns DNS
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
#
page acadServDir Directories
group-only conn|ldap Academic Directories
130.223.8.20   uldns1     # noconn
130.223.4.5    uldns2     # noconn
#
page acadServMail Mail
group-only conn|http|imaps|pop3s|smtp|sslcert|webmailn Academic Mail
130.223.8.20   uldns1     # noconn
130.223.4.5    uldns2     # noconn
#
page acadServOther Other
group-only afp|conn|dhcp|ftp|lic|smb Academic Other
130.223.8.20   uldns1     # noconn
130.223.4.5    uldns2     # noconn
#
title <br>Systems
#
page acadSys Academic
title Academic Systems
include bb-hosts.acadSys

--- bb-host.acadSys ---
group-only bckp|cpu|disk|ifmx|info|memory|msgs|orcl|procs|svm|trends|vx Solaris
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:

Hostname (DisplayName)	Location (Group Name)
uldns1 	                DNS
                         Other
                         Mail
                         Directories
uldns1 	                Other
                         Mail
                         Directories
uldns1 	                Mail
                         Directories
uldns1 	                Directories


Host uldns1 appears for times!
The page/subpage on the info column is correct.


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?

Thanks for any tips (I am using snapshot of the 31 march)

Dominique
list Henrik Størner · Sat, 1 Apr 2006 11:01:20 +0200 ·
On Sat, Apr 01, 2006 at 10:02:52AM +0200, Dominique Frise wrote:
--- bb-hosts ---
quoted from Dominique Frise
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 ---
quoted from Dominique Frise
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.
quoted from Dominique Frise
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;
list Dominique Frise · Sat, 01 Apr 2006 14:41:23 +0200 ·
Henrik Stoerner wrote:
That's a bug. Attached a patch to fix it.

I would'nt expect such a quick reaction on saturdays!
Thank you for the fix!
quoted from Henrik Størner

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.
Thanks again for all these explanations.
The prefer tag is now on the network test line and bbhostgrep work as expected.


Dominique