#! /bin/sh /usr/share/dpatch/dpatch-run ## 20_draw_statusmap_fix.dpatch by Mathieu Baeumler ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: hostgroups excluded from statusmap are now *really* removed, thus ## DP: making the map a lot smaller and easier to read. @DPATCH@ diff -urNad --exclude=CVS --exclude=.svn ./cgi/statusmap.c /tmp/dpep-work.g61ojE/nagios-1.3-cvs.20050402/cgi/statusmap.c --- ./cgi/statusmap.c 2005-03-11 02:19:10.000000000 +0100 +++ /tmp/dpep-work.g61ojE/nagios-1.3-cvs.20050402/cgi/statusmap.c 2005-06-30 08:55:12.000000000 +0200 @@ -1487,6 +1487,7 @@ int dotted_line=FALSE; int x=0; int y=0; + int in_layer_list=FALSE; if(create_type==CREATE_HTML) return; @@ -1511,6 +1512,12 @@ if(is_authorized_for_host(this_host,¤t_authdata)==FALSE) continue; + in_layer_list=is_host_in_layer_list(this_host); + + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + continue; + /* this is a "root" host, so draw link to Nagios process icon if using auto-layout mode */ if(this_host->parent_hosts==NULL && layout_method!=LAYOUT_USER_SUPPLIED && draw_nagios_icon==TRUE){ @@ -2543,15 +2550,21 @@ int max_child_host_drawing_width(host *parent){ host *temp_host; int child_width=0; + int in_layer_list=FALSE; for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){ - + + in_layer_list=is_host_in_layer_list(temp_host); + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + continue; + if(is_host_immediate_child_of_host(parent,temp_host)==TRUE) child_width+=max_child_host_drawing_width(temp_host); } /* no children, so set width to 1 for this host */ - if(child_width==0) + if(child_width<=0) return 1; else @@ -2692,13 +2705,33 @@ double y_coord=0.0; host *temp_host; hostextinfo *temp_hostextinfo; + int in_layer_list=FALSE; /* get the total number of immediate children to this host */ immediate_children=number_of_immediate_child_hosts(parent); + for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){ + + if (parent == temp_host) + continue; + + temp_hostextinfo=find_hostextinfo(temp_host->name); + if(temp_hostextinfo==NULL) + continue; + + if (is_host_immediate_child_of_host(parent,temp_host)==TRUE) { + in_layer_list=is_host_in_layer_list(temp_host); + + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + immediate_children--; + } + } + + /* bail out if we're done */ - if(immediate_children==0) + if(immediate_children<=0) return; /* calculate total drawing "width" of parent host */ @@ -2720,6 +2753,12 @@ if(is_host_immediate_child_of_host(parent,temp_host)==TRUE){ + in_layer_list=is_host_in_layer_list(temp_host); + + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + continue; + /* get drawing width of child host */ this_drawing_width=max_child_host_drawing_width(temp_host); @@ -2796,12 +2835,31 @@ double arc_end_angle=0.0; int translated_x=0; int translated_y=0; + int in_layer_list=FALSE; /* get the total number of immediate children to this host */ immediate_children=number_of_immediate_child_hosts(parent); + for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){ + + if (parent == temp_host) + continue; + + temp_hostextinfo=find_hostextinfo(temp_host->name); + if(temp_hostextinfo==NULL) + continue; + + if (is_host_immediate_child_of_host(parent,temp_host)==TRUE) { + in_layer_list=is_host_in_layer_list(temp_host); + + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + immediate_children--; + } + } + /* bail out if we're done */ - if(immediate_children==0) + if(immediate_children<=0) return; /* calculate total drawing "width" of parent host */ @@ -2822,6 +2880,12 @@ if(is_host_immediate_child_of_host(parent,temp_host)==TRUE){ + in_layer_list=is_host_in_layer_list(temp_host); + + if((in_layer_list==TRUE && exclude_layers==TRUE) + || (in_layer_list==FALSE && exclude_layers==FALSE)) + continue; + /* get drawing width of child host */ this_drawing_width=max_child_host_drawing_width(temp_host); @@ -2903,4 +2967,3 @@ return; } -