[PATCH] Add display of parent and child hosts to extinfo.cgi
Andreas Ericsson
ae at op5.se
Sun May 17 14:47:32 CEST 2009
psychotrahe at gmx.de wrote:
> From: Matthias Eble <matthias.eble at mailing.kaufland-informationssysteme.com>
>
> When extinfo.cgi displays a host's status, parent and/or child hosts
> get displayed also. New cgi.cfg variables have been added to prevent
> flooding in case of too many parents/children:
> child_host_display_len
> parent_host_display_len
> ---
>
> Hi all,
>
> so after some tinkering I thought that it'd be a good idea to display
> parent/child hosts on extinfo.cgi rather linking to config.cgi.
> So here's the patch including doc updates.
>
Nice work, and nicely submitted patch. Comments inline:
> +
> + if (temp_host->parent_hosts != NULL) {
> + /* display parent hosts */
> + printf("<DIV CLASS='data'>Parent Hosts:</DIV>\n");
> + printf("<DIV CLASS='dataTitle'>\n");
> + for(temp_parenthost=temp_host->parent_hosts;temp_parenthost!=NULL;temp_parenthost=temp_parenthost->next){
> + len += strlen(temp_parenthost->host_name);
> + if(len > parent_host_display_len && !display_all_parents) {
> + printf("<A HREF='%s?%s&display_all_parents'>...</A>",EXTINFO_CGI,query_string);
> + break;
> + }
> + printf("<A HREF='%s?host=%s'>%s</A>\n",STATUS_CGI, url_encode(temp_parenthost->host_name),temp_parenthost->host_name);
> + }
> + printf("</DIV><BR>\n");
> + }
> +
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. 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.
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.
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?
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
http://nordicmeetonnagios.op5.org/
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
------------------------------------------------------------------------------
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
More information about the Developers
mailing list