[Nagios-devel] Patch for Nagios 2.9 - increase radius of circular
Posted: Tue Jul 10, 2007 10:31 pm
Hi All,
I have found that when I have a lot of hosts the circular layout
statusmap.cgi output makes the host icons overlap, this made reading their
names and details difficult.
I have made some changes to the source to increase the radius of the circle
if the hosts are too close together, this "closeness" value is defined on
the config file so you can play with it to find one that looks correct. For
my map a value of 60 seemed OK (measuring the icons I got 72 as about right
but the smaller you make it the smaller the map is).
The diff for this against the 2.9 tar file is below, I will post a diff
against the 3.0 CVS as soon as I get a chance. I havent done any C
programing for a lot of years so I hope my style isn't too ugly. If anyone
would like to see the difference the patch makes I could post the JPG's to
the list but will wait to see if anyone wants them.
diff -bB -C 3 -r nagios-2.9/cgi/cgiutils.c nagios-2.9-dev/cgi/cgiutils.c
*** nagios-2.9/cgi/cgiutils.c 2007-04-10 22:50:22.000000000 +0800
--- nagios-2.9-dev/cgi/cgiutils.c 2007-07-11 08:50:55.000000000 +0800
***************
*** 111,116 ****
--- 111,117 ----
int refresh_rate=DEFAULT_REFRESH_RATE;
int default_statusmap_layout_method=0;
+ int default_statusmap_circular_layout_minimum_host_diameter=0;
int default_statuswrl_layout_method=0;
extern hostgroup *hostgroup_list;
***************
*** 182,187 ****
--- 183,189 ----
default_statusmap_layout_method=0;
default_statusmap_layout_method=0;
+ default_statusmap_circular_layout_minimum_host_diameter=0;
service_critical_sound=NULL;
service_warning_sound=NULL;
***************
*** 437,442 ****
--- 439,450 ----
default_statusmap_layout_method=atoi((temp_buffer==NULL)?"0":temp_buffer);
}
+ else
if(strstr(input,"default_statusmap_circular_layout_minimum_host_diameter=")=
=input){
+ temp_buffer=strtok(input,"=");
+ temp_buffer=strtok(NULL,"\x0");
+
default_statusmap_circular_layout_minimum_host_diameter=atoi((temp_buffer==N
ULL)?"0":temp_buffer);
+ }
+
else if(strstr(input,"default_statuswrl_layout=")==input){
temp_buffer=strtok(input,"=");
temp_buffer=strtok(NULL,"\x0");
diff -bB -C 3 -r nagios-2.9/cgi/statusmap.c nagios-2.9-dev/cgi/statusmap.c
*** nagios-2.9/cgi/statusmap.c 2006-03-22 05:31:46.000000000 +0800
--- nagios-2.9-dev/cgi/statusmap.c 2007-07-11 14:17:09.000000000 +0800
***************
*** 62,67 ****
--- 62,68 ----
extern char *statusmap_background_image;
extern int default_statusmap_layout_method;
+ extern int default_statusmap_circular_layout_minimum_host_diameter;
#define DEFAULT_NODE_WIDTH 40
#define DEFAULT_NODE_HEIGHT 65
***************
*** 2674,2684 ****
--- 2675,2711 ----
}
+ /* calculate radius necessary to give each host enough room - value of
enough set in config file - if set to 0 do nothing */
+ int calculate_radius_for_host(double anglewidth, int oldradius)
+ {
+ int newradius;
+ double tmp1;
+ newradius=oldradius;
+ /* for this angle and radius see what the width is - if it is less
than the minimum then return the new value */
+ if ( default_statusmap_circular_layout_minimum_host_diameter != 0 )
{
+ /* now do something - diam = angle/360 2 PI R
+ make 2 PI / 360 a constant 0.17453 (close enough)
+ then if diam is too small radius should become
+ DIAMWANTED * 360 / 2 PI ANGLE */
+
+ tmp1=0.017453 * anglewidth * (double) oldradius ;
+ if ( (int) tmp1 <
default_statusmap_circular_layout_minimum_host_diameter )
+ {
+ tmp1 = (double)
default_statusmap_circular_layout_minimum_host_diameter / ( 0.017453 *
anglewidth) ;
+ newradius = (int) tmp1;
+ /* now round up to nearest "standard" radius */
+ newradius = CIRCULAR_DRAWING_RADIUS * ( 1 + (int)
(newradius / CIRCULAR_DRAWING_RADIUS) ) ;
+ }
+ }
+ return newradius;
+ }
+
/* calculates coords of all hosts in a particular "layer" in circular
layout method */
void calculate_circular_layer_coords(host *parent, double start_angle,
double useable_angle, int layer, int radius){
int parent_drawing_width=0;
int this_drawing_width=0;
int immediate_ch
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
I have found that when I have a lot of hosts the circular layout
statusmap.cgi output makes the host icons overlap, this made reading their
names and details difficult.
I have made some changes to the source to increase the radius of the circle
if the hosts are too close together, this "closeness" value is defined on
the config file so you can play with it to find one that looks correct. For
my map a value of 60 seemed OK (measuring the icons I got 72 as about right
but the smaller you make it the smaller the map is).
The diff for this against the 2.9 tar file is below, I will post a diff
against the 3.0 CVS as soon as I get a chance. I havent done any C
programing for a lot of years so I hope my style isn't too ugly. If anyone
would like to see the difference the patch makes I could post the JPG's to
the list but will wait to see if anyone wants them.
diff -bB -C 3 -r nagios-2.9/cgi/cgiutils.c nagios-2.9-dev/cgi/cgiutils.c
*** nagios-2.9/cgi/cgiutils.c 2007-04-10 22:50:22.000000000 +0800
--- nagios-2.9-dev/cgi/cgiutils.c 2007-07-11 08:50:55.000000000 +0800
***************
*** 111,116 ****
--- 111,117 ----
int refresh_rate=DEFAULT_REFRESH_RATE;
int default_statusmap_layout_method=0;
+ int default_statusmap_circular_layout_minimum_host_diameter=0;
int default_statuswrl_layout_method=0;
extern hostgroup *hostgroup_list;
***************
*** 182,187 ****
--- 183,189 ----
default_statusmap_layout_method=0;
default_statusmap_layout_method=0;
+ default_statusmap_circular_layout_minimum_host_diameter=0;
service_critical_sound=NULL;
service_warning_sound=NULL;
***************
*** 437,442 ****
--- 439,450 ----
default_statusmap_layout_method=atoi((temp_buffer==NULL)?"0":temp_buffer);
}
+ else
if(strstr(input,"default_statusmap_circular_layout_minimum_host_diameter=")=
=input){
+ temp_buffer=strtok(input,"=");
+ temp_buffer=strtok(NULL,"\x0");
+
default_statusmap_circular_layout_minimum_host_diameter=atoi((temp_buffer==N
ULL)?"0":temp_buffer);
+ }
+
else if(strstr(input,"default_statuswrl_layout=")==input){
temp_buffer=strtok(input,"=");
temp_buffer=strtok(NULL,"\x0");
diff -bB -C 3 -r nagios-2.9/cgi/statusmap.c nagios-2.9-dev/cgi/statusmap.c
*** nagios-2.9/cgi/statusmap.c 2006-03-22 05:31:46.000000000 +0800
--- nagios-2.9-dev/cgi/statusmap.c 2007-07-11 14:17:09.000000000 +0800
***************
*** 62,67 ****
--- 62,68 ----
extern char *statusmap_background_image;
extern int default_statusmap_layout_method;
+ extern int default_statusmap_circular_layout_minimum_host_diameter;
#define DEFAULT_NODE_WIDTH 40
#define DEFAULT_NODE_HEIGHT 65
***************
*** 2674,2684 ****
--- 2675,2711 ----
}
+ /* calculate radius necessary to give each host enough room - value of
enough set in config file - if set to 0 do nothing */
+ int calculate_radius_for_host(double anglewidth, int oldradius)
+ {
+ int newradius;
+ double tmp1;
+ newradius=oldradius;
+ /* for this angle and radius see what the width is - if it is less
than the minimum then return the new value */
+ if ( default_statusmap_circular_layout_minimum_host_diameter != 0 )
{
+ /* now do something - diam = angle/360 2 PI R
+ make 2 PI / 360 a constant 0.17453 (close enough)
+ then if diam is too small radius should become
+ DIAMWANTED * 360 / 2 PI ANGLE */
+
+ tmp1=0.017453 * anglewidth * (double) oldradius ;
+ if ( (int) tmp1 <
default_statusmap_circular_layout_minimum_host_diameter )
+ {
+ tmp1 = (double)
default_statusmap_circular_layout_minimum_host_diameter / ( 0.017453 *
anglewidth) ;
+ newradius = (int) tmp1;
+ /* now round up to nearest "standard" radius */
+ newradius = CIRCULAR_DRAWING_RADIUS * ( 1 + (int)
(newradius / CIRCULAR_DRAWING_RADIUS) ) ;
+ }
+ }
+ return newradius;
+ }
+
/* calculates coords of all hosts in a particular "layer" in circular
layout method */
void calculate_circular_layer_coords(host *parent, double start_angle,
double useable_angle, int layer, int radius){
int parent_drawing_width=0;
int this_drawing_width=0;
int immediate_ch
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]