Update of /cvsroot/netsaint/netsaint-alpha/cgi
In directory usw-pr-cvs1:/tmp/cvs-serv4991/cgi
Modified Files:
cgiutils.h cgiutils.h.in statusmap.c trends.c
Log Message:
misc doc fixes, layer support in statusmap CGI, popup supression in statusmap and trends CGIs
Index: cgiutils.h
===================================================================
RCS file: /cvsroot/netsaint/netsaint-alpha/cgi/cgiutils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cgiutils.h 2001/01/25 03:32:54 1.3
--- cgiutils.h 2001/01/27 17:40:53 1.4
***************
*** 160,163 ****
--- 160,166 ----
+ #define ZOOM1_ICON "zoom1.gif"
+ #define ZOOM2_ICON "zoom2.gif"
+
/************************** PLUGIN RETURN VALUES ****************************/
Index: cgiutils.h.in
===================================================================
RCS file: /cvsroot/netsaint/netsaint-alpha/cgi/cgiutils.h.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cgiutils.h.in 2001/01/25 03:32:55 1.3
--- cgiutils.h.in 2001/01/27 17:40:53 1.4
***************
*** 3,7 ****
* CGIUTILS.H - Header file for common CGI functions
* Written By: Ethan Galstad (netsaint@...)
! * Last Modified: 01-24-2001
*
* License:
--- 3,7 ----
* CGIUTILS.H - Header file for common CGI functions
* Written By: Ethan Galstad (netsaint@...)
! * Last Modified: 01-27-2001
*
* License:
***************
*** 156,159 ****
--- 156,162 ----
#define TAC_DISABLED_ICON "tacdisabled.jpg"
#define TAC_ENABLED_ICON "tacenabled.jpg"
+
+ #define ZOOM1_ICON "zoom1.gif"
+ #define ZOOM2_ICON "zoom2.gif"
Index: statusmap.c
===================================================================
RCS file: /cvsroot/netsaint/netsaint-alpha/cgi/statusmap.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** statusmap.c 2001/01/15 23:19:53 1.1.1.1
--- statusmap.c 2001/01/27 17:40:53 1.2
***************
*** 3,8 ****
* STATUSMAP.C - NetSaint Network Status Map CGI
*
! * Copyright (c) 1999-2000 Ethan Galstad (netsaint@...)
! * Last Modified: 11-15-2000
*
* Description:
--- 3,8 ----
* STATUSMAP.C - NetSaint Network Status Map CGI
*
! * Copyright (c) 1999-2001 Ethan Galstad (netsaint@...)
! * Last Modified: 01-27-2001
*
* Description:
***************
*** 63,69 ****
#define DEFAULT_NODE_HEIGHT 65
! #define DEFAULT_PROXIMITY_WIDTH 800
! #define DEFAULT_PROXIMITY_HEIGHT 600
#define CREATE_HTML 0
#define CREATE_IMAGE 1
--- 63,72 ----
#define DEFAULT_NODE_HEIGHT 65
! #define DEFAULT_PROXIMITY_WIDTH 1000
! #define DEFAULT_PROXIMITY_HEIGHT 800
+ #define MINIMUM_PROXIMITY_WIDTH 250
+ #define MINIMUM_PROXIMITY_HEIGHT 200
+
#define CREATE_HTML 0
#define CREATE_IMAGE 1
***************
*** 74,81 ****
--- 77,91 ----
+ typedef struct layer_struct{
+ char *layer_name;
+ struct layer_struct *next;
+ }layer;
+
+
void document_header(int);
void document_footer(void);
int process_cgivars(void);
+ void display_page_header(void);
void display_map(void);
void calculate_host_coords(void);
***************
*** 96,100 ****
--- 106,116 ----
void cleanup_graphics(void);
void draw_line(int,int,int,int,int);
+ void draw_dashed_line(int,int,int,int,int);
+ int is_host_in_layer_list(host *);
+ int add_layer(char *);
+ void free_layer_list(void);
+ void print_layer_url(int);
+
char physical_logo_images_path[MAX_FILENAME_LENGTH];
***************
*** 122,125 ****
--- 138,142 ----
int embedded=FALSE;
int display_header=TRUE;
+ int display_popups=TRUE;
int use_links=TRUE;
int use_text=TRUE;
***************
*** 151,154 ****
--- 168,175 ----
extern time_t program_start;
+ layer *layer_list=NULL;
+ int exclude_layers=TRUE;
+ int all_layers=FALSE;
+
***************
*** 156,161 ****
int main(int argc, char **argv){
int result;
- char temp_buffer[MAX_INPUT_BUFFER];
-
/* get the arguments passed in the URL */
--- 177,180 ----
***************
*** 211,305 ****
read_extended_object_config_data(DEFAULT_CGI_CONFIG_FILE,READ_EXTENDED_HOST_INFO);
-
- if(create_type==CREATE_HTML && display_header==TRUE){
-
- /* begin top table */
- printf("<table border=0 width=100%% cellspacing=0 cellpadding=0>\n");
- printf("<tr>\n");
-
- /* left column of the first row */
- printf("<td align=left valign=top width=50%%>\n");
-
- if(show_all_hosts==TRUE)
- snprintf(temp_buffer,sizeof(temp_buffer)-1,"Network Map For All Hosts");
- else
- snprintf(temp_buffer,sizeof(temp_buffer)-1,"Network Map For Host <I>%s</I>",host_name);
- temp_buffer[sizeof(temp_buffer)-1]='\x0';
- display_info_table(temp_buffer,TRUE,¤t_authdata);
-
- printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
- printf("<TR><TD CLASS='linkBox'>\n");
-
- if(show_all_hosts==FALSE){
- printf("<a href='%s?host=all&max_width=%d&max_height=%d'>View Status Map For All Hosts</a><BR>",STATUSMAP_CGI,max_image_width,max_image_height);
- printf("<a href='%s?host=%s'>View Status Detail For This Host</a><BR>\n",STATUS_CGI,url_encode(host_name));
- }
- printf("<a href='%s?host=all'>View Status Detail For All Hosts</a><BR>\n",STATUS_CGI);
- printf("<a href='%s?hostgroup=all'>View Status Overview For All Hosts</a>\n",STATUS_CGI);
-
- printf("</TD></TR>\n");
- printf("</TABLE>\n");
-
- printf("</td>\n");
-
- /* right hand column of top row */
- printf("<td align=right valign=top width=50%%>\n");
-
- printf("<table border=0 CLASS='optBox'>\n");
- printf("<tr><td valign=top>\n");
- printf("<form method=\"GET\" action=\"%s\">\n",STATUSMAP_CGI);
- printf("<input type='hidden' name='host' value='%s'>\n",host_name);
-
- printf("</td><td valign=top>\n");
-
- printf("<table border=0>\n");
- /*
- printf("<tr><td CLASS='optBoxItem'>\n");
- printf("Layout Method:<br>\n");
- printf("<select name='layout'>\n");
- printf("<option value=%d %s>User-supplied coords\n",LAYOUT_USER_SUPPLIED,(layout_method==LAYOUT_USER_SUPPLIED)?"selected":"");
- printf("<option value=%d %s>Balanced tree\n",LAYOUT_BALANCED_TREE,(layout_method==LAYOUT_BALANCED_TREE)?"selected":"");
- printf("<option value=%d %s>Best fit\n",LAYOUT_BEST_FIT,(layout_method==LAYOUT_BEST_FIT)?"selected":"");
- printf("</select>\n");
- printf("</td></tr>\n");
- */
- printf("<tr><td CLASS='optBoxItem'>\n");
- printf("Max image width:<br>\n");
- printf("<select name='max_width'>\n");
- printf("<option value=0 %s>Unlimited\n",(max_image_width==0)?"selected":"");
- printf("<option value=600 %s>600 pixels\n",(max_image_width==600)?"selected":"");
- printf("<option value=800 %s>800 pixels\n",(max_image_width==800)?"selected":"");
- printf("<option value=1000 %s>1000 pixels\n",(max_image_width==1000)?"selected":"");
- printf("<option value=1200 %s>1200 pixels\n",(max_image_width==1200)?"selected":"");
- printf("<option value=1400 %s>1400 pixels\n",(max_image_width==1400)?"selected":"");
- printf("</select>\n");
- printf("</td></tr>\n");
- printf("<tr><td CLASS='optBoxItem'>\n");
- printf("Max image height:<br>\n");
- printf("<select name='max_height'>\n");
- printf("<option value=0 %s>Unlimited\n",(max_image_height==0)?"selected":"");
- printf("<option value=300 %s>300 pixels\n",(max_image_height==300)?"selected":"");
- printf("<option value=400 %s>400 pixels\n",(max_image_height==400)?"selected":"");
- printf("<option value=500 %s>500 pixels\n",(max_image_height==500)?"selected":"");
- printf("<option value=600 %s>600 pixels\n",(max_image_height==600)?"selected":"");
- printf("<option value=800 %s>800 pixels\n",(max_image_height==800)?"selected":"");
- printf("<option value=1000 %s>1000 pixels\n",(max_image_height==1000)?"selected":"");
- printf("</select>\n");
- printf("<input type='submit' value='Update'>\n");
- printf("</td></tr>\n");
- printf("</table>\n");
-
- printf("</form>\n");
- printf("</td></tr>\n");
- printf("</table>\n");
-
- printf("</td>\n");
-
- /* end of top table */
- printf("</tr>\n");
- printf("</table>\n");
- }
-
-
/* display the network map... */
display_map();
--- 230,233 ----
***************
*** 310,313 ****
--- 238,242 ----
free_memory();
free_extended_data();
+ free_layer_list();
return OK;
***************
*** 353,357 ****
printf("</head>\n");
! printf("<body CLASS='statusmap'>\n");
printf("<div id=\"popup\" style=\"position:absolute; z-index:1; visibility: hidden\"></div>\n");
--- 282,286 ----
printf("</head>\n");
! printf("<body CLASS='statusmap' name='mappage' id='mappage'>\n");
printf("<div id=\"popup\" style=\"position:absolute; z-index:1; visibility: hidden\"></div>\n");
***************
*** 539,542 ****
--- 468,500 ----
else if(!strcmp(variables[x],"nohighlights"))
use_highlights=FALSE;
+
+ /* we found the no popups argument*/
+ else if(!strcmp(variables[x],"nopopups"))
+ display_popups=FALSE;
+
+ /* we found the layer inclusion/exclusion argument */
+ else if(!strcmp(variables[x],"layermode")){
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x],"include"))
+ exclude_layers=FALSE;
+ else
+ exclude_layers=TRUE;
+ }
+
+ /* we found the layer argument */
+ else if(!strcmp(variables[x],"layer")){
+ x++;
+ if(variables[x]==NULL){
+ error=TRUE;
+ break;
+ }
+
+ add_layer(variables[x]);
+ }
}
***************
*** 545,578 ****
! /* top-level map generation... */
! void display_map(void){
int zoom;
int zoom_width, zoom_height;
- calculate_host_coords();
- calculate_total_image_bounds();
- calculate_canvas_bounds();
- calculate_scaling_factor();
- find_eligible_hosts();
! initialize_graphics();
! draw_background_image();
! draw_host_links();
! if(create_type==CREATE_HTML)
! printf("<map name='statusmap'>\n");
! draw_hosts();
! if(create_type==CREATE_HTML)
! printf("</map>\n");
! write_graphics();
! cleanup_graphics();
! if(create_type==CREATE_HTML){
/* print image size and scaling info */
/*
--- 503,559 ----
!
! /* top of page */
! void display_page_header(void){
! char temp_buffer[MAX_INPUT_BUFFER];
int zoom;
int zoom_width, zoom_height;
+ int zoom_width_granularity=0;
+ int zoom_height_granularity=0;
+ int current_zoom_granularity=0;
+ hostgroup *temp_hostgroup;
+ layer *temp_layer;
+ int found=0;
! if(create_type!=CREATE_HTML)
! return;
! if(display_header==TRUE){
! /* begin top table */
! printf("<table border=0 width=100%% cellspacing=0 cellpadding=0>\n");
! printf("<tr>\n");
! /* left column of the first row */
! printf("<td align=left valign=top>\n");
! if(show_all_hosts==TRUE)
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Network Map For All Hosts");
! else
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Network Map For Host <I>%s</I>",host_name);
! temp_buffer[sizeof(temp_buffer)-1]='\x0';
! display_info_table(temp_buffer,TRUE,¤t_authdata);
! printf("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 CLASS='linkBox'>\n");
! printf("<TR><TD CLASS='linkBox'>\n");
! if(show_all_hosts==FALSE){
! printf("<a href='%s?host=all&max_width=%d&max_height=%d'>View Status Map For All Hosts</a><BR>",STATUSMAP_CGI,max_image_width,max_image_height);
! printf("<a href='%s?host=%s'>View Status Detail For This Host</a><BR>\n",STATUS_CGI,url_encode(host_name));
! }
! printf("<a href='%s?host=all'>View Status Detail For All Hosts</a><BR>\n",STATUS_CGI);
! printf("<a href='%s?hostgroup=all'>View Status Overview For All Hosts</a>\n",STATUS_CGI);
! printf("</TD></TR>\n");
! printf("</TABLE>\n");
!
! printf("</td>\n");
+
+
+ /* center column of top row */
+ printf("<td align=center valign=center>\n");
+
/* print image size and scaling info */
/*
***************
*** 580,586 ****
printf("[ Raw Image Size: %d x %d pixels | Scaling Factor: %1.2lf | Scaled Image Size: %d x %d pixels ]",canvas_width,canvas_height,scaling_factor,(int)(canvas_width*scaling_factor),(int)(canvas_height*scaling_factor));
printf("</font></div></p>\n");
- */
- /*
printf("<p><div align=center><font size=-1>\n");
printf("[ Canvas_x: %d | Canvas_y: %d | Canvas_width: %d | Canvas_height: %d ]",canvas_x,canvas_y,canvas_width,canvas_height);
--- 561,565 ----
***************
*** 591,619 ****
if(user_supplied_canvas==FALSE && strcmp(host_name,"all") && display_header==TRUE){
! printf("<p><div align=center><font size=-1>\n");
! printf("Zoom Out [ ");
! for(zoom=5;zoom>=-5;zoom--){
! if(zoom==0)
! printf("| ");
! else{
! if(zoom>0){
! zoom_width=proximity_width+((proximity_width*zoom)/5);
! zoom_height=proximity_height+((proximity_height*zoom)/5);
! }
! else{
! zoom_width=(proximity_width*(6+zoom))/(2*5);
! zoom_height=(proximity_height*(6+zoom))/(2*5);
! }
! printf("<a href='%s?host=%s&max_width=%d&max_height=%d&proximity_width=%d&proximity_height=%d%s'>%d</a> \n",STATUSMAP_CGI,url_encode(host_name),max_image_width,max_image_height,zoom_width,zoom_height,(display_header==TRUE)?"":"&noheader",(zoom>0)?zoom:-zoom);
! }
}
! printf("] Zoom In");
! printf("</font></div></p>\n");
}
! /* write the URL location for the image we just generated - the web browser will come and get it... */
printf("<P><DIV ALIGN=center>\n");
printf("<img src='%s?host=%s&createimage",STATUSMAP_CGI,url_encode(host_name));
printf("&canvas_x=%d&canvas_y=%d&canvas_width=%d&canvas_height=%d&max_width=%d&max_height=%d&layout=%d%s%s%s",canvas_x,canvas_y,canvas_width,canvas_height,max_image_width,max_image_height,layout_method,(use_links==FALSE)?"&nolinks":"",(use_text==FALSE)?"¬ext":"",(use_highlights==FALSE)?"&nohighlights":"");
printf("' width=%d height=%d border=0 name='statusimage' useMap='#statusmap'>\n",(int)(canvas_width*scaling_factor),(int)(canvas_height*scaling_factor));
printf("</DIV></P>\n");
--- 570,725 ----
if(user_supplied_canvas==FALSE && strcmp(host_name,"all") && display_header==TRUE){
! printf("<p><div align=center>\n");
!
! zoom_width_granularity=((total_image_width-MINIMUM_PROXIMITY_WIDTH)/11);
! zoom_height_granularity=((total_image_height-MINIMUM_PROXIMITY_HEIGHT)/11);
!
! if(proximity_width<=0)
! current_zoom_granularity=0;
! else
! current_zoom_granularity=(total_image_width-proximity_width)/zoom_width_granularity;
! if(current_zoom_granularity>10)
! current_zoom_granularity=10;
!
! printf("<table border=0 cellpadding=0 cellspacing=2>\n");
! printf("<tr>\n");
! printf("<td valign=center class='zoomTitle'>Zoom Out </td>\n");
!
! for(zoom=0;zoom<=10;zoom++){
!
! zoom_width=total_image_width-(zoom*zoom_width_granularity);
! zoom_height=total_image_height-(zoom*zoom_height_granularity);
!
! printf("<td valign=center><a href='%s?host=%s&max_width=%d&max_height=%d&proximity_width=%d&proximity_height=%d%s%s",STATUSMAP_CGI,url_encode(host_name),max_image_width,max_image_height,zoom_width,zoom_height,(display_header==TRUE)?"":"&noheader",(display_popups==FALSE)?"&nopopups":"");
! print_layer_url(TRUE);
! printf("'>");
! printf("<img src='%s%s' border=0 alt='%d'></a></td>\n",url_images_path,(current_zoom_granularity==zoom)?ZOOM2_ICON:ZOOM1_ICON,zoom);
}
!
! printf("<td valign=center class='zoomTitle'> Zoom In</td>\n");
! printf("</tr>\n");
! printf("</table>\n");
!
! printf("</div></p>\n");
! }
!
! printf("</td>\n");
!
!
!
! /* right hand column of top row */
! printf("<td align=right valign=top>\n");
!
! printf("<table border=0 CLASS='optBox'>\n");
! printf("<tr><td valign=top>\n");
! printf("<form method=\"POST\" action=\"%s\">\n",STATUSMAP_CGI);
! printf("<input type='hidden' name='host' value='%s'>\n",host_name);
! printf("<input type='hidden' name='proximity_width' value='%d'>\n",proximity_width);
! printf("<input type='hidden' name='proximity_height' value='%d'>\n",proximity_height);
!
! printf("</td><td valign=top>\n");
!
! printf("<table border=0>\n");
! /*
! printf("<tr><td CLASS='optBoxItem'>\n");
! printf("Layout Method:<br>\n");
! printf("<select name='layout'>\n");
! printf("<option value=%d %s>User-supplied coords\n",LAYOUT_USER_SUPPLIED,(layout_method==LAYOUT_USER_SUPPLIED)?"selected":"");
! printf("<option value=%d %s>Balanced tree\n",LAYOUT_BALANCED_TREE,(layout_method==LAYOUT_BALANCED_TREE)?"selected":"");
! printf("<option value=%d %s>Best fit\n",LAYOUT_BEST_FIT,(layout_method==LAYOUT_BEST_FIT)?"selected":"");
! printf("</select>\n");
! printf("</td></tr>\n");
! */
! printf("<tr><td CLASS='optBoxItem'>\n");
! printf("Max image width:<br>\n");
! printf("<input type='text' name='max_width' maxlength='5' size='4' value='%d'>\n",max_image_width);
! printf("</td>\n");
! printf("<td CLASS='optBoxItem'>\n");
! printf("Max image height:<br>\n");
! printf("<input type='text' name='max_height' maxlength='5' size='4' value='%d'>\n",max_image_height);
! printf("</td></tr>\n");
!
! printf("<tr><td CLASS='optBoxItem'>Layers:<br>\n");
! printf("<select multiple name='layer' size='4'>\n");
! for(temp_hostgroup=hostgroup_list;temp_hostgroup!=NULL;temp_hostgroup=temp_hostgroup->next){
! found=0;
! for(temp_layer=layer_list;temp_layer!=NULL;temp_layer=temp_layer->next){
! if(!strcmp(temp_layer->layer_name,temp_hostgroup->group_name)){
! found=1;
! break;
! }
! }
! printf("<option value='%s' %s>%s\n",temp_hostgroup->group_name,(found==1)?"SELECTED":"",temp_hostgroup->alias);
}
+ printf("</select>\n");
+ printf("</td><td CLASS='optBoxItem' valign=top>Layer mode:<br>");
+ printf("<input type='radio' name='layermode' value='include' %s>Include<br>\n",(exclude_layers==FALSE)?"CHECKED":"");
+ printf("<input type='radio' name='layermode' value='exclude' %s>Exclude\n",(exclude_layers==TRUE)?"CHECKED":"");
+ printf("</td></tr>\n");
+
+ printf("<tr><td CLASS='optBoxItem'>\n");
+ printf("Supress popups:<br>\n");
+ printf("<input type='checkbox' name='nopopups' %s>\n",(display_popups==FALSE)?"CHECKED":"");
+ printf("</td><td CLASS='optBoxItem'>\n");
+ printf("<input type='submit' value='Update'>\n");
+ printf("</td></tr>\n");
+
+ printf("</table>\n");
+
+ printf("</form>\n");
+ printf("</td></tr>\n");
+ printf("</table>\n");
+
+ printf("</td>\n");
+
+ /* end of top table */
+ printf("</tr>\n");
+ printf("</table>\n");
+ }
+
+
+ return;
+ }
+
+
+
+ /* top-level map generation... */
+ void display_map(void){
+
+ calculate_host_coords();
+ calculate_total_image_bounds();
+ calculate_canvas_bounds();
+ calculate_scaling_factor();
+ find_eligible_hosts();
+
+
+ /* display page header */
+ display_page_header();
+
+
+ initialize_graphics();
+
+ draw_background_image();
+
+ draw_host_links();
+
+ if(create_type==CREATE_HTML)
+ printf("<map name='statusmap'>\n");
! draw_hosts();
!
! if(create_type==CREATE_HTML)
! printf("</map>\n");
!
! write_graphics();
! cleanup_graphics();
!
!
! /* write the URL location for the image we just generated - the web browser will come and get it... */
! if(create_type==CREATE_HTML){
printf("<P><DIV ALIGN=center>\n");
printf("<img src='%s?host=%s&createimage",STATUSMAP_CGI,url_encode(host_name));
printf("&canvas_x=%d&canvas_y=%d&canvas_width=%d&canvas_height=%d&max_width=%d&max_height=%d&layout=%d%s%s%s",canvas_x,canvas_y,canvas_width,canvas_height,max_image_width,max_image_height,layout_method,(use_links==FALSE)?"&nolinks":"",(use_text==FALSE)?"¬ext":"",(use_highlights==FALSE)?"&nohighlights":"");
+ print_layer_url(TRUE);
printf("' width=%d height=%d border=0 name='statusimage' useMap='#statusmap'>\n",(int)(canvas_width*scaling_factor),(int)(canvas_height*scaling_factor));
printf("</DIV></P>\n");
***************
*** 763,766 ****
--- 869,873 ----
int total_eligible_hosts=0;
host *temp_host;
+ int in_layer_list=FALSE;
/* check all extended host information entries... */
***************
*** 769,772 ****
--- 876,880 ----
/* find the host */
temp_host=find_host(temp_hostextinfo->host_name,NULL);
+
if(temp_host==NULL)
temp_hostextinfo->should_be_drawn=FALSE;
***************
*** 854,857 ****
--- 962,968 ----
hoststatus *this_hoststatus;
hoststatus *parent_hoststatus;
+ int child_in_layer_list=FALSE;
+ int parent_in_layer_list=FALSE;
+ int dotted_line=FALSE;
if(create_type==CREATE_HTML)
***************
*** 864,871 ****
for(temp_hostextinfo=hostextinfo_list;temp_hostextinfo!=NULL;temp_hostextinfo=temp_hostextinfo->next){
- /* skip hosts that should not be drawn */
- if(temp_hostextinfo->should_be_drawn==FALSE)
- continue;
-
/* find the config entry for this host */
this_host=find_host(temp_hostextinfo->host_name,NULL);
--- 975,978 ----
***************
*** 886,890 ****
/* don't draw the link if we don't have the coords */
! if(temp_parent_hostextinfo->have_2d_coords==FALSE)
continue;
--- 993,997 ----
/* don't draw the link if we don't have the coords */
! if(temp_parent_hostextinfo->have_2d_coords==FALSE || temp_hostextinfo->have_2d_coords==FALSE)
continue;
***************
*** 898,901 ****
--- 1005,1023 ----
continue;
+ /* are the hosts in the layer list? */
+ child_in_layer_list=is_host_in_layer_list(this_host);
+ parent_in_layer_list=is_host_in_layer_list(parent_host);
+
+ /* use dotted or solid line? */
+ /* either the child or parent should not be drawn, so use a dotted line */
+ if((child_in_layer_list==TRUE && parent_in_layer_list==FALSE) || (child_in_layer_list==FALSE && parent_in_layer_list==TRUE))
+ dotted_line=TRUE;
+ /* both hosts should not be drawn, so use a dotted line */
+ else if((child_in_layer_list==FALSE && parent_in_layer_list==FALSE && exclude_layers==FALSE) || (child_in_layer_list==TRUE && parent_in_layer_list==TRUE && exclude_layers==TRUE))
+ dotted_line=TRUE;
+ /* both hosts should be drawn, so use a solid line */
+ else
+ dotted_line=FALSE;
+
/* determine color to use when drawing links to parent host */
parent_hoststatus=find_hoststatus(temp_parent_hostextinfo->host_name);
***************
*** 910,916 ****
/* draw the link */
! draw_line((temp_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH)/2)-canvas_y,(temp_parent_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_parent_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH/2))-canvas_y,status_color);
}
/* determine color to use when drawing links to child hosts */
this_hoststatus=find_hoststatus(temp_hostextinfo->host_name);
--- 1032,1042 ----
/* draw the link */
! if(dotted_line==TRUE)
! draw_dashed_line((temp_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH)/2)-canvas_y,(temp_parent_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_parent_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH/2))-canvas_y,status_color);
! else
! draw_line((temp_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH)/2)-canvas_y,(temp_parent_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_parent_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH/2))-canvas_y,status_color);
}
+ #ifdef ETHAN_IS_STUPID_DUPLICATION_IS_UNNECESSARY
/* determine color to use when drawing links to child hosts */
this_hoststatus=find_hoststatus(temp_hostextinfo->host_name);
***************
*** 942,945 ****
--- 1068,1072 ----
draw_line((temp_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH/2))-canvas_y,(temp_child_hostextinfo->x_2d+(DEFAULT_NODE_WIDTH/2))-canvas_x,(temp_child_hostextinfo->y_2d+(DEFAULT_NODE_WIDTH/2))-canvas_y,status_color);
}
+ #endif
}
***************
*** 962,965 ****
--- 1089,1093 ----
int status_color=color_black;
hoststatus *temp_hoststatus;
+ int in_layer_list=FALSE;
/* draw all hosts... */
***************
*** 970,973 ****
--- 1098,1109 ----
continue;
+ /* find the host */
+ temp_host=find_host(temp_hostextinfo->host_name,NULL);
+
+ /* is this host in the layer inclusion/exclusion list? */
+ 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 coords of host bounding box */
x1=temp_hostextinfo->x_2d-canvas_x;
***************
*** 993,998 ****
status_color=color_black;
- temp_host=find_host(temp_hostextinfo->host_name,NULL);
-
/* draw a target around root hosts (hosts with no parents) */
if(temp_host!=NULL && use_highlights==TRUE){
--- 1129,1132 ----
***************
*** 1070,1080 ****
if(!strcmp(host_name,temp_hostextinfo->host_name))
printf("href='%s?host=%s' ",STATUS_CGI,url_encode(temp_hostextinfo->host_name));
! else
! printf("href='%s?host=%s&max_width=%d&max_height=%d&proximity_width=%d&proximity_height=%d%s%s%s%s' ",STATUSMAP_CGI,url_encode(temp_hostextinfo->host_name),max_image_width,max_image_height,proximity_width,proximity_height,(display_header==TRUE)?"":"&noheader",(use_links==FALSE)?"&nolinks":"",(use_text==FALSE)?"¬ext":"",(use_highlights==FALSE)?"&nohighlights":"");
/* popup text */
! printf("onMouseOver='showPopup(\"");
! write_host_popup_text(find_host(temp_hostextinfo->host_name,NULL));
! printf("\",event)' onMouseOut='hidePopup()'");
printf(">\n");
--- 1204,1220 ----
if(!strcmp(host_name,temp_hostextinfo->host_name))
printf("href='%s?host=%s' ",STATUS_CGI,url_encode(temp_hostextinfo->host_name));
! else{
! printf("href='%s?host=%s&max_width=%d&max_height=%d&proximity_width=%d&proximity_height=%d%s%s%s%s%s",STATUSMAP_CGI,url_encode(temp_hostextinfo->host_name),max_image_width,max_image_height,proximity_width,proximity_height,(display_header==TRUE)?"":"&noheader",(use_links==FALSE)?"&nolinks":"",(use_text==FALSE)?"¬ext":"",(use_highlights==FALSE)?"&nohighlights":"",(display_popups==FALSE)?"&nopopups":"");
! print_layer_url(TRUE);
! printf("' ");
! }
/* popup text */
! if(display_popups==TRUE){
!
! printf("onMouseOver='showPopup(\"");
! write_host_popup_text(find_host(temp_hostextinfo->host_name,NULL));
! printf("\",event)' onMouseOut='hidePopup()'");
! }
printf(">\n");
***************
*** 1265,1269 ****
--- 1405,1435 ----
+ /* draws a dashed line */
+ void draw_dashed_line(int x1,int y1,int x2,int y2,int color){
+ int styleDashed[12];
+
+ styleDashed[0]=color;
+ styleDashed[1]=gdTransparent;
+ styleDashed[2]=gdTransparent;
+ styleDashed[3]=gdTransparent;
+ styleDashed[4]=gdTransparent;
+ styleDashed[5]=gdTransparent;
+ styleDashed[6]=color;
+ styleDashed[7]=gdTransparent;
+ styleDashed[8]=gdTransparent;
+ styleDashed[9]=gdTransparent;
+ styleDashed[10]=gdTransparent;
+ styleDashed[11]=gdTransparent;
+
+ /* sets current style to a dashed line */
+ gdImageSetStyle(map_image,styleDashed,12);
+
+ /* draws a line (dashed) */
+ gdImageLine(map_image,x1,y1,x2,y2,gdStyled);
+ return;
+ }
+
+
/******************************************************************/
/*********************** GRAPHICS FUNCTIONS ***********************/
***************
*** 1424,1426 ****
--- 1590,1686 ----
return;
}
+
+
+
+ /* adds a layer to the list in memory */
+ int add_layer(char *group_name){
+ layer *new_layer;
+
+ if(group_name==NULL)
+ return ERROR;
+
+ /* allocate memory for a new layer */
+ new_layer=(layer *)malloc(sizeof(layer));
+ if(new_layer==NULL)
+ return ERROR;
+
+ new_layer->layer_name=(char *)malloc(strlen(group_name)+1);
+ if(new_layer->layer_name==NULL){
+ free(new_layer);
+ return ERROR;
+ }
+
+ strcpy(new_layer->layer_name,group_name);
+
+ /* add new layer to head of layer list */
+ new_layer->next=layer_list;
+ layer_list=new_layer;
+
+ return OK;
+ }
+
+
+
+ /* frees memory allocated to the layer list */
+ void free_layer_list(void){
+ layer *this_layer;
+ layer *next_layer;
+
+ return;
+
+ for(this_layer=layer_list;layer_list!=NULL;this_layer=next_layer){
+ next_layer=this_layer->next;
+ free(this_layer->layer_name);
+ free(this_layer);
+ }
+
+ return;
+ }
+
+
+ /* checks to see if a host is in the layer list */
+ int is_host_in_layer_list(host *hst){
+ hostgroup *temp_hostgroup;
+ layer *temp_layer;
+
+ if(hst==NULL)
+ return FALSE;
+
+ /* check each layer... */
+ for(temp_layer=layer_list;temp_layer!=NULL;temp_layer=temp_layer->next){
+
+ /* find the hostgroup */
+ temp_hostgroup=find_hostgroup(temp_layer->layer_name,NULL);
+ if(temp_hostgroup==NULL)
+ continue;
+
+ /* is the requested host a member of the hostgroup/layer? */
+ if(is_host_member_of_hostgroup(temp_hostgroup,hst)==TRUE)
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+ /* print layer url info */
+ void print_layer_url(int get_method){
+ layer *temp_layer;
+
+ for(temp_layer=layer_list;temp_layer!=NULL;temp_layer=temp_layer->next){
+ if(get_method==TRUE)
+ printf("&layer=%s",temp_layer->layer_name);
+ else
+ printf("<input type='hidden' name='layer' value='%s'>\n",temp_layer->layer_name);
+ }
+
+ if(get_method==TRUE)
+ printf("&layermode=%s",(exclude_layers==TRUE)?"exclude":"include");
+ else
+ printf("<input type='hidden' name='layermode' value='%s'>\n",(exclude_layers==TRUE)?"exclude":"include");
+
+ return;
+ }
+
+
Index: trends.c
===================================================================
RCS file: /cvsroot/netsaint/netsaint-alpha/cgi/trends.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** trends.c 2001/01/25 03:32:55 1.2
--- trends.c 2001/01/27 17:40:53 1.3
***************
*** 4,8 ****
*
* Copyright (c) 1999-2001 Ethan Galstad (netsaint@...)
! * Last Modified: 01-24-2001
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2001 Ethan Galstad (netsaint@...)
! * Last Modified: 01-25-2001
*
* License:
***************
*** 103,106 ****
--- 103,109 ----
int timeperiod_type=TIMEPERIOD_LAST24HOURS;
+ int display_popups=TRUE;
+ int use_map=TRUE;
+
int assume_initial_states=TRUE;
int assume_state_retention=TRUE;
***************
*** 538,556 ****
if(display_type!=DISPLAY_NO_TRENDS){
! /* read in all necessary archived state data */
! read_archived_state_data();
! /* graph archived state trend data */
! graph_all_trend_data();
! /* draw timestamps */
! draw_timestamps();
! /* draw horizontal lines */
! draw_horizontal_grid_lines();
! /* draw state time breakdowns */
! draw_time_breakdowns();
if(mode==CREATE_IMAGE){
--- 541,585 ----
if(display_type!=DISPLAY_NO_TRENDS){
+
+ if(mode==CREATE_IMAGE || (mode==CREATE_HTML && use_map==TRUE)){
+
+ /* read in all necessary archived state data */
+ read_archived_state_data();
+
+ /* graph archived state trend data */
+ graph_all_trend_data();
+ }
+
+ /* print URL to image */
+ if(mode==CREATE_HTML){
! printf("<BR><BR>\n");
! printf("<DIV ALIGN=CENTER>\n");
! printf("<IMG SRC='%s?createimage&t1=%lu&t2=%lu",TRENDS_CGI,(unsigned long)t1,(unsigned long)t2);
! if(assume_initial_states==TRUE)
! printf("&assumeinitialstates=on");
! if(assume_state_retention==TRUE)
! printf("&assumestateretention=on");
! printf("&host=%s",url_encode(host_name));
! if(display_type==DISPLAY_SERVICE_TRENDS)
! printf("&service=%s",url_encode(svc_description));
! if(backtrack_archives>0)
! printf("&backtrack=%d",backtrack_archives);
! printf("&zoom=%d",zoom_factor);
! printf("' BORDER=0 name='trendsimage' useMap='#trendsmap' width=900>\n");
! printf("</DIV>\n");
! }
! if(mode==CREATE_IMAGE || (mode==CREATE_HTML && use_map==TRUE)){
! /* draw timestamps */
! draw_timestamps();
! /* draw horizontal lines */
! draw_horizontal_grid_lines();
! /* draw state time breakdowns */
! draw_time_breakdowns();
! }
if(mode==CREATE_IMAGE){
***************
*** 630,633 ****
--- 659,670 ----
printf("<option value=lastyear>Last Year\n");
printf("</select>\n");
+ printf("</td></tr>\n");
+
+ printf("<tr><td class='reportSelectSubTitle'>Suppress map:</td></tr>\n");
+ printf("<tr><td class='reportSelectItem'><input type='checkbox' name='nomap'>");
+ printf("</td></tr>\n");
+
+ printf("<tr><td class='reportSelectSubTitle'>Suppress popups:</td></tr>\n");
+ printf("<tr><td class='reportSelectItem'><input type='checkbox' name='nopopups'>\n");
printf("<input type='submit' value='Submit'>\n");
printf("</td></tr>\n");
***************
*** 695,701 ****
printf("<option value=lastyear>Last Year\n");
printf("</select>\n");
- printf("<input type='submit' value='Submit'>\n");
printf("</td></tr>\n");
printf("</form>\n");
printf("</TABLE>\n");
--- 732,746 ----
printf("<option value=lastyear>Last Year\n");
printf("</select>\n");
printf("</td></tr>\n");
+ printf("<tr><td class='reportSelectSubTitle'>Suppress map:</td></tr>\n");
+ printf("<tr><td class='reportSelectItem'><input type='checkbox' name='nomap'>");
+ printf("</td></tr>\n");
+
+ printf("<tr><td class='reportSelectSubTitle'>Suppress popups:</td></tr>\n");
+ printf("<tr><td class='reportSelectItem'><input type='checkbox' name='nopopups'>");
+ printf("<input type='submit' value='Submit'>\n");
+ printf("</td></tr>\n");
+
printf("</form>\n");
printf("</TABLE>\n");
***************
*** 975,978 ****
--- 1020,1033 ----
else if(!strcmp(variables[x],"noheader"))
display_header=FALSE;
+
+ /* we found the nopopups option */
+ else if(!strcmp(variables[x],"nopopups"))
+ display_popups=FALSE;
+
+ /* we found the nomap option */
+ else if(!strcmp(variables[x],"nomap")){
+ display_popups=FALSE;
+ use_map=FALSE;
+ }
}
***************
*** 1184,1208 ****
}
! /* if we're creating the HTML, close the map code and write the image link */
! if(mode==CREATE_HTML){
printf("</MAP>\n");
- printf("<BR><BR>\n");
- printf("<DIV ALIGN=CENTER>\n");
- printf("<IMG SRC='%s?createimage&t1=%lu&t2=%lu",TRENDS_CGI,(unsigned long)t1,(unsigned long)t2);
- if(assume_initial_states==TRUE)
- printf("&assumeinitialstates=on");
- if(assume_state_retention==TRUE)
- printf("&assumestateretention=on");
- printf("&host=%s",url_encode(host_name));
- if(display_type==DISPLAY_SERVICE_TRENDS)
- printf("&service=%s",url_encode(svc_description));
- if(backtrack_archives>0)
- printf("&backtrack=%d",backtrack_archives);
- printf("&zoom=%d",zoom_factor);
- printf("' BORDER=0 name='trendsimage' useMap='#trendsmap' width=900>\n");
- printf("</DIV>\n");
- }
-
return;
}
--- 1239,1246 ----
}
! /* if we're creating the HTML, close the map code */
! if(mode==CREATE_HTML)
printf("</MAP>\n");
return;
}
***************
*** 1429,1449 ****
printf("' ");
-
- snprintf(start_timestring,sizeof(start_timestring)-1,"%s",ctime(&real_start_time));
- start_timestring[sizeof(start_timestring)-1]='\x0';
- start_timestring[strlen(start_timestring)-1]='\x0';
-
- snprintf(end_timestring,sizeof(end_timestring)-1,"%s",ctime(&end_time));
- end_timestring[sizeof(end_timestring)-1]='\x0';
- end_timestring[strlen(end_timestring)-1]='\x0';
! /* calculate total time in this state */
! get_time_breakdown((time_t)(end_time-start_time),&days,&hours,&minutes,&seconds);
! printf("onMouseOver='showPopup(\"");
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"<B><U>%s</U></B><BR><B>Time Range</B>: <I>%s</I> to <I>%s</I><BR><B>Duration</B>: <I>%dd %dh %dm %ds</I><BR><B>State Info</B>: <I>%s</I>",state_string,start_timestring,end_timestring,days,hours,minutes,seconds,(state_info==NULL)?"N/A":strip_html(state_info));
! temp_buffer[sizeof(temp_buffer)-1]='\x0';
! printf("%s",temp_buffer);
! printf("\",event)' onMouseOut='hidePopup()'");
printf(">\n");
--- 1467,1491 ----
printf("' ");
! /* display popup text */
! if(display_popups==TRUE){
! snprintf(start_timestring,sizeof(start_timestring)-1,"%s",ctime(&real_start_time));
! start_timestring[sizeof(start_timestring)-1]='\x0';
! start_timestring[strlen(start_timestring)-1]='\x0';
!
! snprintf(end_timestring,sizeof(end_timestring)-1,"%s",ctime(&end_time));
! end_timestring[sizeof(end_timestring)-1]='\x0';
! end_timestring[strlen(end_timestring)-1]='\x0';
!
! /* calculate total time in this state */
! get_time_breakdown((time_t)(end_time-start_time),&days,&hours,&minutes,&seconds);
!
! printf("onMouseOver='showPopup(\"");
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"<B><U>%s</U></B><BR><B>Time Range</B>: <I>%s</I> to <I>%s</I><BR><B>Duration</B>: <I>%dd %dh %dm %ds</I><BR><B>State Info</B>: <I>%s</I>",state_string,start_timestring,end_timestring,days,hours,minutes,seconds,(state_info==NULL)?"N/A":strip_html(state_info));
! temp_buffer[sizeof(temp_buffer)-1]='\x0';
! printf("%s",temp_buffer);
! printf("\",event)' onMouseOut='hidePopup()'");
! }
printf(">\n");
|