[icinga-checkins] icinga.org: icinga-core/rbartels/cgi-current: Prevent statusmap. cgi markup from drawing when host should not be drawn

git at icinga.org git at icinga.org
Thu Apr 7 12:39:01 CEST 2011


Module: icinga-core
Branch: rbartels/cgi-current
Commit: 41c626546f843974f63ea3c4c5925a38926141b2
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=41c626546f843974f63ea3c4c5925a38926141b2

Author: Matthew J. Brooks <matthew at sonomatechpartners.com>
Date:   Sun Apr  3 22:08:01 2011 -0700

Prevent statusmap.cgi markup from drawing when host should not be drawn

refs #1383

Signed-off-by: Michael Friedrich <michael.friedrich at univie.ac.at>

---

 Changelog       |    1 +
 cgi/statusmap.c |   74 ++++++++++++++++++++++++++++++------------------------
 2 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/Changelog b/Changelog
index 222f026..957894c 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ FIXES
 * classic ui: fix display_name survive reconfiguration and is use instead of host_name in classic ui #1282
 * classic ui: don't show pause/continue urls on non-refreshable pages
 * classic ui: fix segfaults if no default_user_name= given in cgi.cfg #1289
+* classic ui: Prevent statusmap.cgi markup from drawing when host should not be drawn (Matthew Brooks) #1383
 
 * idoutils: update oracle hints in ido2db.cfg with tnsnames.ora and port cfg #1283
 * idoutils: idomod: larger buffer size (by Opsview) #1286
diff --git a/cgi/statusmap.c b/cgi/statusmap.c
index 57aed8d..bee10ff 100644
--- a/cgi/statusmap.c
+++ b/cgi/statusmap.c
@@ -2639,48 +2639,56 @@ void draw_circular_layer_markup(host *parent, double start_angle, double useable
 			x_offset=nagios_icon_x+(DEFAULT_NODE_WIDTH/2)-canvas_x;
 			y_offset=nagios_icon_y+(DEFAULT_NODE_HEIGHT/2)-canvas_y;
 
-			/* draw "slice" dividers */
-			if(immediate_children>1 || layer>1){
+			/* if the host should be drawn */
+			/* this enforces the privacy of hosts that are not eligble to be drawn */
+			if(temp_host->should_be_drawn==TRUE){
 
-				/* draw "leftmost" divider */
-				gdImageLine(map_image,(int)x_coord[0]+x_offset,(int)y_coord[0]+y_offset,(int)x_coord[1]+x_offset,(int)y_coord[1]+y_offset,color_lightgrey);
+				/* draw "slice" dividers */
+				if(immediate_children>1 || layer>1){
 
-				/* draw "rightmost" divider */
-				gdImageLine(map_image,(int)x_coord[2]+x_offset,(int)y_coord[2]+y_offset,(int)x_coord[3]+x_offset,(int)y_coord[3]+y_offset,color_lightgrey);
-			        }
+					/* draw "leftmost" divider */
+					gdImageLine(map_image,(int)x_coord[0]+x_offset,(int)y_coord[0]+y_offset,(int)x_coord[1]+x_offset,(int)y_coord[1]+y_offset,color_lightgrey);
 
-			/* determine arc drawing angles */
-			arc_start_angle=current_drawing_angle-90.0;
-			while(arc_start_angle<0.0)
-				arc_start_angle+=360.0;
-			arc_end_angle=arc_start_angle+available_angle;
+					/* draw "rightmost" divider */
+					gdImageLine(map_image,(int)x_coord[2]+x_offset,(int)y_coord[2]+y_offset,(int)x_coord[3]+x_offset,(int)y_coord[3]+y_offset,color_lightgrey);
+				        }
 
-			/* draw inner arc */
-			gdImageArc(map_image,x_offset,y_offset,(radius-(CIRCULAR_DRAWING_RADIUS/2))*2,(radius-(CIRCULAR_DRAWING_RADIUS/2))*2,floor(arc_start_angle),ceil(arc_end_angle),color_lightgrey);
 
-			/* draw outer arc */
-			gdImageArc(map_image,x_offset,y_offset,(radius+(CIRCULAR_DRAWING_RADIUS/2))*2,(radius+(CIRCULAR_DRAWING_RADIUS/2))*2,floor(arc_start_angle),ceil(arc_end_angle),color_lightgrey);
+				/* determine arc drawing angles */
+				arc_start_angle=current_drawing_angle-90.0;
+				while(arc_start_angle<0.0)
+					arc_start_angle+=360.0;
+				arc_end_angle=arc_start_angle+available_angle;
 
+				/* draw inner arc */
+				gdImageArc(map_image,x_offset,y_offset,(radius-(CIRCULAR_DRAWING_RADIUS/2))*2,(radius-(CIRCULAR_DRAWING_RADIUS/2))*2,floor(arc_start_angle),ceil(arc_end_angle),color_lightgrey);
 
-			/* determine center of "slice" and fill with appropriate color */
-			center_x=-(sin(-(current_drawing_angle+(available_angle/2.0))*(M_PI/180.0))*(radius));
-			center_y=-(sin((90+current_drawing_angle+(available_angle/2.0))*(M_PI/180.0))*(radius));
-			translated_x=center_x+x_offset;
-			translated_y=center_y+y_offset;
+				/* draw outer arc */
+				gdImageArc(map_image,x_offset,y_offset,(radius+(CIRCULAR_DRAWING_RADIUS/2))*2,(radius+(CIRCULAR_DRAWING_RADIUS/2))*2,floor(arc_start_angle),ceil(arc_end_angle),color_lightgrey);
 
-			/* determine background color */
-			temp_hoststatus=find_hoststatus(temp_host->name);
-			if(temp_hoststatus==NULL)
-				bgcolor=color_lightgrey;
-			else if(temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE)
-				bgcolor=color_lightred;
-			else
-				bgcolor=color_lightgreen;
 
-			/* fill slice with background color */
-			/* the fill function only works with coordinates that are in bounds of the actual image */
-			if(translated_x>0 && translated_y>0 && translated_x<canvas_width && translated_y<canvas_height)
-				gdImageFillToBorder(map_image,translated_x,translated_y,color_lightgrey,bgcolor);
+				/* determine center of "slice" and fill with appropriate color */
+				center_x=-(sin(-(current_drawing_angle+(available_angle/2.0))*(M_PI/180.0))*(radius));
+				center_y=-(sin((90+current_drawing_angle+(available_angle/2.0))*(M_PI/180.0))*(radius));
+				translated_x=center_x+x_offset;
+				translated_y=center_y+y_offset;
+
+				/* determine background color */
+				temp_hoststatus=find_hoststatus(temp_host->name);
+				if(temp_hoststatus==NULL)
+					bgcolor=color_lightgrey;
+				else if(temp_hoststatus->status==HOST_DOWN || temp_hoststatus->status==HOST_UNREACHABLE)
+					bgcolor=color_lightred;
+				else
+					bgcolor=color_lightgreen;
+
+
+				/* fill slice with background color */
+				/* the fill function only works with coordinates that are in bounds of the actual image */
+				if(translated_x>0 && translated_y>0 && translated_x<canvas_width && translated_y<canvas_height)
+					gdImageFillToBorder(map_image,translated_x,translated_y,color_lightgrey,bgcolor);
+
+				}
 
 			/* recurse into child host ... */
 			draw_circular_layer_markup(temp_host,current_drawing_angle+((available_angle-clipped_available_angle)/2),clipped_available_angle,layer+1,radius+CIRCULAR_DRAWING_RADIUS);





More information about the icinga-checkins mailing list