[PATCH] Add display of parent and child hosts to extinfo.cgi

Matthias Eble PsychoTrahe at gmx.de
Sun May 17 16:28:54 CEST 2009


Hi again,

> The section above is quite alright, but...
> 
> > +				len=0;
> > +				/* look up and display child hosts */
> > +				for(temp_host2=host_list;temp_host2!=NULL;temp_host2=temp_host2->next){
> > +					if(len > child_host_display_len && !display_all_children) {
> > +						printf("<A HREF='%s?%s&display_all_children'>...</A>", EXTINFO_CGI, query_string);
> > +						break;
> > +					}
> > +					if (temp_host2->parent_hosts != NULL) {
> > +						for(temp_parenthost=temp_host2->parent_hosts;temp_parenthost!=NULL;temp_parenthost=temp_parenthost->next){
> > +							if(!strcmp(temp_host->name, temp_parenthost->host_name)) {
> > +								if(len == 0){
> > +									printf("<DIV CLASS='data'>Child Hosts:</DIV>\n");
> > +									printf("<DIV CLASS='dataTitle'>\n");
> > +								}
> > +								len += strlen(temp_parenthost->host_name);
> > +								printf("<A HREF='%s?host=%s'>%s</A>\n",STATUS_CGI,url_encode(temp_host2->name),temp_host2->name);
> > +							}
> > +						}
> > +					}
> > +				}
> 
> ... this really isn't. In a *best* case scenario (where each parent is a
> parent to only one host), this exhibits O(hosts*2) performance, which I
> have a hard time accepting.
>  Especially in view of Jean Gabès' recent
> patch, which makes Nagios scale to truly huge networks.

That's right. We've already talked about this in the prior thread
even though I thought it to be okay for most installations and searching
could also be disabled by switching child_host_display_len to -1.

>  I think a better
> solution would be to waste some memory for the host we're showing and
> plug in the host->child_hosts logic into the CGI's as well, but only
> for the host we're currently showing.

So you mean to add child_hosts to the host struct when included from
cgis? 

> The rest of the patch looks good though, although I'd personally have
> used a "max_show_{parent,child}_hosts=number-of-hosts-to-show" variable
> for this, since the sort-order of the hosts will sometimes affect how
> many parents are shown.

Thought about this also. My conclusion was that the intention of the
flag is to limit the length of the output. So if host names are short,
there's no reason to only display few of them. But really, I've no
strong opinion on this.

> Would you care to amend the patch, or would you prefer if I strip out
> the child-drawing stuff and only apply the parent-drawing logic for
> now?

I'll amend it. While digging into this, I found that the same "high
performance" logic as mine is already in the cgis...
common/objects.c:
number_of_immediate_child_hosts() calls
is_host_immediate_child_of_host() and is used by the statusmap cgi.

It was also called by the old circular path detection ;)

Matthias



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list