Re: [Nagios-devel] [PATCH] Add display of parent and child hosts to

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] [PATCH] Add display of parent and child hosts to

Post by Guest »

[email protected] wrote:
> From: Matthias Eble
>
> 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("Parent Hosts:\n");
> + printf("\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("...",EXTINFO_CGI,query_string);
> + break;
> + }
> + printf("%s\n",STATUS_CGI, url_encode(temp_parenthost->host_name),temp_parenthost->host_name);
> + }
> + printf("\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("...", 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("Child Hosts:\n");
> + printf("\n");
> + }
> + len += strlen(temp_parenthost->host_name);
> + printf("%s\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 [email protected]
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.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked