[Nagios-devel] Silly precision in a timing macros
Posted: Tue Oct 26, 2004 7:56 am
This is a multi-part message in MIME format.
--------------040103090101040100040907
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
The precision provided by timing macros (for latency and executin times)
are a bit silly, since it holds room for 6 decimal points but only ever
uses 3 of them (a limit in the Linux kernel, I've heard).
The attached patch takes care of that, and also fixes a couple of
warnings (use of 'l' length character with 'f' type character) for those
selfsame macros.
In the passing, it removes an unused variable (encoded_buffer) from
process_macros, and fixes the above error message for a couple of debug
printlines in config.c.
To apply only the precision part, remove the first files'
(base/config.c) hunks entirely and remove the first hunk from the second
file (base/utils.c).
On a side-note, I'm really glad development seems to have taken a huge
leap forward again.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer
--------------040103090101040100040907
Content-Type: text/plain;
name="nagios-base-macro-precision_fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-base-macro-precision_fix.diff"
diff -urN ../Nagios/base/config.c ./base/config.c
--- ../Nagios/base/config.c Fri Oct 22 18:51:26 2004
+++ ./base/config.c Tue Oct 26 16:18:59 2004
@@ -1267,7 +1267,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\tlow_service_flap_threshold set to %lf\n",low_service_flap_threshold);
+ printf("\t\tlow_service_flap_threshold set to %f\n",low_service_flap_threshold);
#endif
}
else if(!strcmp(variable,"high_service_flap_threshold")){
@@ -1278,7 +1278,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\thigh_service_flap_threshold set to %lf\n",high_service_flap_threshold);
+ printf("\t\thigh_service_flap_threshold set to %f\n",high_service_flap_threshold);
#endif
}
else if(!strcmp(variable,"low_host_flap_threshold")){
@@ -1289,7 +1289,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\tlow_host_flap_threshold set to %lf\n",low_host_flap_threshold);
+ printf("\t\tlow_host_flap_threshold set to %f\n",low_host_flap_threshold);
#endif
}
else if(!strcmp(variable,"high_host_flap_threshold")){
@@ -1300,7 +1300,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\thigh_host_flap_threshold set to %lf\n",high_host_flap_threshold);
+ printf("\t\thigh_host_flap_threshold set to %f\n",high_host_flap_threshold);
#endif
}
else if(!strcmp(variable,"date_format")){
diff -urN ../Nagios/base/utils.c ./base/utils.c
--- ../Nagios/base/utils.c Tue Oct 26 15:13:28 2004
+++ ./base/utils.c Tue Oct 26 16:24:08 2004
@@ -310,7 +310,6 @@
int arg_index=0;
int user_index=0;
int address_index=0;
- char *encoded_macro=NULL;
char *selected_macro=NULL;
int clean_macro=FALSE;
@@ -821,7 +820,7 @@
free(macro_x[MACRO_SERVICEEXECUTIONTIME]);
macro_x[MACRO_SERVICEEXECUTIONTIME]=(char *)malloc(MAX_EXECUTIONTIME_LENGTH);
if(macro_x[MACRO_SERVICEEXECUTIONTIME]!=NULL){
- snprintf(macro_x[MACRO_SERVICEEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%lf",svc->execution_time);
+ snprintf(macro_x[MACRO_SERVICEEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%.3f",svc->execution_time);
macro_x[MACRO_SERVICEEXECUTIONTIME][MAX_EXECUTIONTIME_LENGTH-1]='\x0';
}
@@ -830,7 +829,7 @@
free(macro_x[MACRO_SERVICELATENCY]);
macro_x[MACRO_SERVICELATENCY]=(char *)malloc(MAX_LATENCY_LENGTH);
if(macro_x[MACRO_SERVICELATENCY]!=NULL){
- snprintf(macro_x[MACRO_SERVICELATENCY],MAX_LATENCY_LENGTH,"%lf",svc->latency);
+ snprintf(macro_x[MACRO_SERVICELATENCY],MAX_LATENCY_LENGTH,"%.3f",svc->latency);
macro_x[MACRO_SERVICELATENCY][MAX_LATENCY_LENGTH-1]='\x0';
}
@@ -1148,7 +1147,7 @@
free(macro_x[MACRO_HOSTEXECUTIONTIME]);
macro_x[MACRO_HOSTEXECUTIONTIME]=(char *)malloc(MAX_EXECUTIONTIME_LENGTH);
if(macro_x[MACRO_HOSTEXECUTIONTIME]!=NULL){
- snprintf(macro_x[MACRO_HOSTEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%lf",hst->execution_time);
+ snprintf(macro_x[MACRO_HOSTEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%.3f",hst->execution_time);
macro_x[MACRO_HOSTEXECUTIONTIME][
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
--------------040103090101040100040907
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
The precision provided by timing macros (for latency and executin times)
are a bit silly, since it holds room for 6 decimal points but only ever
uses 3 of them (a limit in the Linux kernel, I've heard).
The attached patch takes care of that, and also fixes a couple of
warnings (use of 'l' length character with 'f' type character) for those
selfsame macros.
In the passing, it removes an unused variable (encoded_buffer) from
process_macros, and fixes the above error message for a couple of debug
printlines in config.c.
To apply only the precision part, remove the first files'
(base/config.c) hunks entirely and remove the first hunk from the second
file (base/utils.c).
On a side-note, I'm really glad development seems to have taken a huge
leap forward again.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer
--------------040103090101040100040907
Content-Type: text/plain;
name="nagios-base-macro-precision_fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-base-macro-precision_fix.diff"
diff -urN ../Nagios/base/config.c ./base/config.c
--- ../Nagios/base/config.c Fri Oct 22 18:51:26 2004
+++ ./base/config.c Tue Oct 26 16:18:59 2004
@@ -1267,7 +1267,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\tlow_service_flap_threshold set to %lf\n",low_service_flap_threshold);
+ printf("\t\tlow_service_flap_threshold set to %f\n",low_service_flap_threshold);
#endif
}
else if(!strcmp(variable,"high_service_flap_threshold")){
@@ -1278,7 +1278,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\thigh_service_flap_threshold set to %lf\n",high_service_flap_threshold);
+ printf("\t\thigh_service_flap_threshold set to %f\n",high_service_flap_threshold);
#endif
}
else if(!strcmp(variable,"low_host_flap_threshold")){
@@ -1289,7 +1289,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\tlow_host_flap_threshold set to %lf\n",low_host_flap_threshold);
+ printf("\t\tlow_host_flap_threshold set to %f\n",low_host_flap_threshold);
#endif
}
else if(!strcmp(variable,"high_host_flap_threshold")){
@@ -1300,7 +1300,7 @@
break;
}
#ifdef DEBUG1
- printf("\t\thigh_host_flap_threshold set to %lf\n",high_host_flap_threshold);
+ printf("\t\thigh_host_flap_threshold set to %f\n",high_host_flap_threshold);
#endif
}
else if(!strcmp(variable,"date_format")){
diff -urN ../Nagios/base/utils.c ./base/utils.c
--- ../Nagios/base/utils.c Tue Oct 26 15:13:28 2004
+++ ./base/utils.c Tue Oct 26 16:24:08 2004
@@ -310,7 +310,6 @@
int arg_index=0;
int user_index=0;
int address_index=0;
- char *encoded_macro=NULL;
char *selected_macro=NULL;
int clean_macro=FALSE;
@@ -821,7 +820,7 @@
free(macro_x[MACRO_SERVICEEXECUTIONTIME]);
macro_x[MACRO_SERVICEEXECUTIONTIME]=(char *)malloc(MAX_EXECUTIONTIME_LENGTH);
if(macro_x[MACRO_SERVICEEXECUTIONTIME]!=NULL){
- snprintf(macro_x[MACRO_SERVICEEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%lf",svc->execution_time);
+ snprintf(macro_x[MACRO_SERVICEEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%.3f",svc->execution_time);
macro_x[MACRO_SERVICEEXECUTIONTIME][MAX_EXECUTIONTIME_LENGTH-1]='\x0';
}
@@ -830,7 +829,7 @@
free(macro_x[MACRO_SERVICELATENCY]);
macro_x[MACRO_SERVICELATENCY]=(char *)malloc(MAX_LATENCY_LENGTH);
if(macro_x[MACRO_SERVICELATENCY]!=NULL){
- snprintf(macro_x[MACRO_SERVICELATENCY],MAX_LATENCY_LENGTH,"%lf",svc->latency);
+ snprintf(macro_x[MACRO_SERVICELATENCY],MAX_LATENCY_LENGTH,"%.3f",svc->latency);
macro_x[MACRO_SERVICELATENCY][MAX_LATENCY_LENGTH-1]='\x0';
}
@@ -1148,7 +1147,7 @@
free(macro_x[MACRO_HOSTEXECUTIONTIME]);
macro_x[MACRO_HOSTEXECUTIONTIME]=(char *)malloc(MAX_EXECUTIONTIME_LENGTH);
if(macro_x[MACRO_HOSTEXECUTIONTIME]!=NULL){
- snprintf(macro_x[MACRO_HOSTEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%lf",hst->execution_time);
+ snprintf(macro_x[MACRO_HOSTEXECUTIONTIME],MAX_EXECUTIONTIME_LENGTH,"%.3f",hst->execution_time);
macro_x[MACRO_HOSTEXECUTIONTIME][
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]