[Nagios-checkins] CVS: nagios/cgi histogram.c,1.1.1.1,1.2

Ethan Galstad egalstad at users.sourceforge.net
Thu Feb 28 17:47:03 UTC 2002


Update of /cvsroot/nagios/nagios/cgi
In directory usw-pr-cvs1:/tmp/cvs-serv15717

Modified Files:
	histogram.c 
Log Message:
Histogram scaling bug fix

Index: histogram.c
===================================================================
RCS file: /cvsroot/nagios/nagios/cgi/histogram.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** histogram.c	26 Feb 2002 04:03:35 -0000	1.1.1.1
--- histogram.c	1 Mar 2002 01:46:08 -0000	1.2
***************
*** 4,8 ****
   *
   * Copyright (c) 2001-2002 Ethan Galstad (nagios at nagios.org)
!  * Last Modified: 02-14-2002
   *
   * License:
--- 4,8 ----
   *
   * Copyright (c) 2001-2002 Ethan Galstad (nagios at nagios.org)
!  * Last Modified: 02-28-2002
   *
   * License:
***************
*** 1503,1507 ****
  	double y_scaling_factor;
  	double x_units;
! 	int y_units;
  	int current_unit;
  	int actual_unit;
--- 1503,1507 ----
  	double y_scaling_factor;
  	double x_units;
! 	double y_units;
  	int current_unit;
  	int actual_unit;
***************
*** 1562,1590 ****
  	printf("Done determining max bucket values\n");
  	printf("MAX_VALUE=%lu\n",max_value);
  #endif
  
! 	/* determine y scaling factor */
! 	if(max_value==0)
! 		y_scaling_factor=1.0;
! 	else
! 		y_scaling_factor=floor((double)DRAWING_HEIGHT/(double)max_value);
! 	if(y_scaling_factor<1.0)
! 		y_scaling_factor=1.0;
! 
  #ifdef DEBUG
! 	printf("Y_SCALING_FACTOR=%.2f\n",y_scaling_factor);
  #endif
  
  	/* determine x scaling factor */
  	x_scaling_factor=(double)((double)DRAWING_WIDTH/(double)total_buckets);
  
! #ifdef DEBUG
! 	printf("X_SCALING_FACTOR=%.2f\n",x_scaling_factor);
! #endif
! 
! 	/* determine y units resolution */
! 	y_units=0.0;
! 	while((double)(DRAWING_HEIGHT/10.0)>y_units)
! 		y_units+=y_scaling_factor;
  
  	/* determine x units resolution */
--- 1562,1584 ----
  	printf("Done determining max bucket values\n");
  	printf("MAX_VALUE=%lu\n",max_value);
+ 	printf("DRAWING_HEIGHT=%lu\n",DRAWING_HEIGHT);
  #endif
  
! 	/* min number of values to graph */
! 	if(max_value<10)
! 		max_value=10;
  #ifdef DEBUG
! 	printf("ADJUSTED MAX_VALUE=%lu\n",max_value);
  #endif
  
+ 	/* determine y scaling factor */
+ 	y_scaling_factor=floor((double)DRAWING_HEIGHT/(double)max_value);
+ 
  	/* determine x scaling factor */
  	x_scaling_factor=(double)((double)DRAWING_WIDTH/(double)total_buckets);
  
! 	/* determine y units resolution - we want a max of about 10 y grid lines */
! 	y_units=(double)((double)DRAWING_HEIGHT/19.0);
! 	y_units=ceil(y_units/y_scaling_factor)*y_scaling_factor;
  
  	/* determine x units resolution */
***************
*** 2016,2020 ****
  	int skip_state=FALSE;
  
! #ifdef DEBUG
  	printf("NEW ENTRY: last=%d this=%d\n",last_state,state_type);
  #endif
--- 2010,2014 ----
  	int skip_state=FALSE;
  
! #ifdef DEBUG2
  	printf("NEW ENTRY: last=%d this=%d\n",last_state,state_type);
  #endif
***************
*** 2022,2026 ****
  	/* don't record program starts/stops, just make a note that one occurred */
  	if(state_type==AS_PROGRAM_START || state_type==AS_PROGRAM_END){
! #ifdef DEBUG
  		printf("Recording a program start: %d\n",state_type);
  #endif
--- 2016,2020 ----
  	/* don't record program starts/stops, just make a note that one occurred */
  	if(state_type==AS_PROGRAM_START || state_type==AS_PROGRAM_END){
! #ifdef DEBUG2
  		printf("Recording a program start: %d\n",state_type);
  #endif
***************
*** 2032,2036 ****
  	if(program_restart_has_occurred==TRUE){
  
! #ifdef DEBUG
  		printf("program_restart_has_occurred: last=%d this=%d\n",last_state,state_type);
  #endif
--- 2026,2030 ----
  	if(program_restart_has_occurred==TRUE){
  
! #ifdef DEBUG2
  		printf("program_restart_has_occurred: last=%d this=%d\n",last_state,state_type);
  #endif
***************
*** 2058,2062 ****
  		if(skip_state==TRUE){
  			program_restart_has_occurred=FALSE;
! #ifdef DEBUG
  			printf("Skipping state...\n");
  #endif
--- 2052,2056 ----
  		if(skip_state==TRUE){
  			program_restart_has_occurred=FALSE;
! #ifdef DEBUG2
  			printf("Skipping state...\n");
  #endif
***************
*** 2070,2074 ****
  	/* are we only processing new states */
  	if(new_states_only==TRUE && state_type==last_state){
! #ifdef DEBUG
  		printf("Skipping state (not a new state)...\n");
  #endif
--- 2064,2068 ----
  	/* are we only processing new states */
  	if(new_states_only==TRUE && state_type==last_state){
! #ifdef DEBUG2
  		printf("Skipping state (not a new state)...\n");
  #endif
***************
*** 2076,2080 ****
  	        }
  
! #ifdef DEBUG
  	printf("GOODSTATE: %d @ %lu\n",state_type,(unsigned long)time_stamp);
  #endif
--- 2070,2074 ----
  	        }
  
! #ifdef DEBUG2
  	printf("GOODSTATE: %d @ %lu\n",state_type,(unsigned long)time_stamp);
  #endif
***************
*** 2097,2101 ****
  		bucket=(our_time->tm_hour*4)+(our_time->tm_min/15);
  
! #ifdef DEBUG
  	printf("\tBucket=%d\n",bucket);
  #endif	
--- 2091,2095 ----
  		bucket=(our_time->tm_hour*4)+(our_time->tm_min/15);
  
! #ifdef DEBUG2
  	printf("\tBucket=%d\n",bucket);
  #endif	
***************
*** 2132,2136 ****
  	int current_archive;
  
! #ifdef DEBUG
  	printf("Determining archives to use...\n");
  #endif
--- 2126,2130 ----
  	int current_archive;
  
! #ifdef DEBUG2
  	printf("Determining archives to use...\n");
  #endif
***************
*** 2147,2151 ****
  		oldest_archive=newest_archive;
  
! #ifdef DEBUG
  	printf("Oldest archive: %d\n",oldest_archive);
  	printf("Newest archive: %d\n",newest_archive);
--- 2141,2145 ----
  		oldest_archive=newest_archive;
  
! #ifdef DEBUG2
  	printf("Oldest archive: %d\n",oldest_archive);
  	printf("Newest archive: %d\n",newest_archive);
***************
*** 2158,2162 ****
  		get_log_archive_to_use(current_archive,filename,sizeof(filename)-1);
  
! #ifdef DEBUG	
  		printf("\tCurrent archive: %d (%s)\n",current_archive,filename);
  #endif
--- 2152,2156 ----
  		get_log_archive_to_use(current_archive,filename,sizeof(filename)-1);
  
! #ifdef DEBUG2
  		printf("\tCurrent archive: %d (%s)\n",current_archive,filename);
  #endif
***************
*** 2189,2193 ****
  	fp=fopen(filename,"r");
  	if(fp==NULL){
! #ifdef DEBUG
  		printf("Could not open file '%s' for reading.\n",filename);
  #endif
--- 2183,2187 ----
  	fp=fopen(filename,"r");
  	if(fp==NULL){
! #ifdef DEBUG2
  		printf("Could not open file '%s' for reading.\n",filename);
  #endif
***************
*** 2195,2199 ****
  	        }
  
! #ifdef DEBUG
  	printf("Scanning log file '%s' for archived state data...\n",filename);
  #endif
--- 2189,2193 ----
  	        }
  
! #ifdef DEBUG2
  	printf("Scanning log file '%s' for archived state data...\n",filename);
  #endif





More information about the Nagios-commits mailing list