From: Frédéric Marchal Date: Sat, 18 Sep 2010 12:35:29 +0000 (+0000) Subject: Add a configuration option to report any error in the sum of the in-cache and out... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65b4ec2c7ecc6ca559940a678aeede9333b9d1d5;p=thirdparty%2Fsarg.git Add a configuration option to report any error in the sum of the in-cache and out-cache columns of the reports. The sum must be 100.00%. The total column is also checked for any discrepency. The check is activated at compile time as it will likely be used by me alone. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index de5081f..a428d46 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,6 +342,9 @@ IF(ENABLE_DEBUG) SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAGS "${TMPCFLAGS} -g") ENDIF(ENABLE_DEBUG) +# Enable double check of the data written in the reports +OPTION(ENABLE_DOUBLE_CHECK_DATA "Make sarg double check the data it manipulates and output a warning if an error is found" OFF) + # Save the configuration for the project CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/include/config.h.in" "${CMAKE_BINARY_DIR}/config.h" @ONLY) diff --git a/configure.in b/configure.in index 11b919c..a94fe5c 100644 --- a/configure.in +++ b/configure.in @@ -215,6 +215,16 @@ AC_ARG_ENABLE(extraprotection, fi ]) +dnl Enable double check of the data written in the reports +AC_ARG_ENABLE(doublecheck, +[ --enable-doublecheck + Make sarg double check the data it manipulates and output a warning if an error is found ], +[ + if test "$enableval"; then + AC_DEFINE(ENABLE_DOUBLE_CHECK_DATA) + fi +]) + AC_SUBST(PACKAGE,"$PACKAGE_NAME") AC_SUBST(VERSION,"$PACKAGE_VERSION") diff --git a/include/config.h.in b/include/config.h.in index 9a67a6b..0dbe838 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -63,6 +63,8 @@ #define RLIM_STRING "@RLIM_STRING@" #define ICONV_CONST @ICONV_CONST@ +#cmakedefine ENABLE_DOUBLE_CHECK_DATA + #cmakedefine HAVE_LC_MESSAGES #endif /*CONFIG_H*/ diff --git a/log.c b/log.c index e3ee729..eecb272 100644 --- a/log.c +++ b/log.c @@ -709,6 +709,10 @@ int main(int argc,char *argv[]) if(debug) debuga(_("sarg version: %s\n"),VERSION); +#ifdef ENABLE_DOUBLE_CHECK_DATA + debuga(_("Sarg compiled to report warnings if the output is inconsistent\n")); +#endif + maxopenfiles=MAX_OPEN_USER_FILES; #ifdef HAVE_RLIM_T if (Ulimit[0] != '\0') { diff --git a/topuser.c b/topuser.c index 444cfc2..b7d85a4 100644 --- a/topuser.c +++ b/topuser.c @@ -306,6 +306,11 @@ void topuser(void) inperc=(tnbytes) ? incac * 100. / tnbytes : 0.; ouperc=(tnbytes) ? oucac * 100. / tnbytes : 0.; fprintf(fp_top3,"%3.2lf%%%3.2lf%%",inperc,ouperc); +#ifdef ENABLE_DOUBLE_CHECK_DATA + if (fabs(inperc+ouperc-100.)>=0.01) { + debuga(_("The total of the in-cache and cache-miss is not 100%% at position %d of user %s\n"),posicao,uinfo->label); + } +#endif } if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0) fprintf(fp_top3,"%s",buildtime(tnelap)); @@ -343,6 +348,11 @@ void topuser(void) inperc=(ttnbytes) ? ttnincache * 100. / ttnbytes : 0.; ouperc=(ttnbytes) ? ttnoucache *100. / ttnbytes : 0.; fprintf(fp_top3,"%3.2lf%%%3.2lf%%",inperc,ouperc); +#ifdef ENABLE_DOUBLE_CHECK_DATA + if (fabs(inperc+ouperc-100.)>=0.01) { + debuga(_("The total of the in-cache and cache-miss is not 100%% for user %s\n"),uinfo->label); + } +#endif } if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0) fprintf(fp_top3,"%s",buildtime(ttnelap));