[Pkg-nagios-devel] statusmap.c patched to draw only selected hostgroup
Mathieu Baeumler
mathieu.baeumler@gmail.com
Tue, 28 Jun 2005 11:54:39 +0200
--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
I'm currently working with nagios and more than 150 hosts... and I
think that the statusmap, (circular, marked-up), has a bad behaviour
when using the include/exclude switch.
For now, the whole map is always drawn, but with that many hosts, this
is not very good. So I've produced a little patch to draw only selected
hosts (thus the map is a lot smaller, and easier to read).
If you think it can be of any interest, tell me and I will complete it
for the tree mode.
cheers,
--
Mathieu Baeumler - Blackbox package co-maintainer
blackbox wiki: http://blackboxwm.sourceforge.net
--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="20_multi_map_fix.dpatch"
#! /bin/sh /usr/share/dpatch/dpatch-run
## 20_multi_map_fix.dpatch by Mathieu Baeumler <mathieu.baeumler@gmail.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.
@DPATCH@
diff -urNad --exclude=CVS --exclude=.svn ./cgi/statusmap.c /tmp/dpep-work.HmUqCn/nagios-1.3-cvs.20050402/cgi/statusmap.c
--- ./cgi/statusmap.c 2005-03-11 02:19:10.000000000 +0100
+++ /tmp/dpep-work.HmUqCn/nagios-1.3-cvs.20050402/cgi/statusmap.c 2005-06-27 22:52:07.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,15 @@
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){
@@ -2544,19 +2554,29 @@
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){
-
- if(is_host_immediate_child_of_host(parent,temp_host)==TRUE)
- child_width+=max_child_host_drawing_width(temp_host);
- }
+
+ in_layer_list=is_host_in_layer_list(temp_host);
- /* no children, so set width to 1 for this host */
- if(child_width==0)
- return 1;
+ 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);
+ }
- else
- return child_width;
- }
+ /* no children, so set width to 1 for this host */
+ if(child_width<=0)
+ return 1;
+
+ else
+ return child_width;
+}
@@ -2692,13 +2712,32 @@
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 +2759,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 +2841,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);
- /* bail out if we're done */
- if(immediate_children==0)
+ 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)
return;
/* calculate total drawing "width" of parent host */
@@ -2822,6 +2886,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);
--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=00list
01_fix_postgresql_path.dpatch
02_reasonable_config.dpatch
03_no_service_depends.dpatch
04_command_pipe_move.dpatch
05_fix_script_errors.dpatch
06_makefile.in_delete_defaults.dpatch
07_fix_default_config.dpatch
08_side.html_absolute_url_fix.dpatch
09_grouplist.cgi-apan.sourceforge.net.dpatch
10_grouplist.cgi-pathfixes.dpatch
20_multi_map_fix.dpatch
9999_nsca_pathfix.dpatch
10000_no-password-disclosure.dpatch
--nFreZHaLTZJo0R7j--