]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Add a configuration option to report any error in the sum of the in-cache and out...
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 18 Sep 2010 12:35:29 +0000 (12:35 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 18 Sep 2010 12:35:29 +0000 (12:35 +0000)
CMakeLists.txt
configure.in
include/config.h.in
log.c
topuser.c

index de5081ff6bdd503fc4038d02da4c7f1da748e3bb..a428d462bba50c531f82386c5277c2bfb6161829 100755 (executable)
@@ -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)
 
index 11b919c3b26eddb738bd37556bf56554e614c333..a94fe5cbe2d52a5c880cc251c59076f28f17b17b 100644 (file)
@@ -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")
 
index 9a67a6b4647702fe4726bfefcef9bf8aedf77546..0dbe838054762f543a27bf91ebf7b0bec8b6084d 100644 (file)
@@ -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 e3ee7294d59d4d7af91a35d4e8e1b123d19b59c8..eecb2725801feb40c04cd084515163aeef3b39fd 100644 (file)
--- 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') {
index 444cfc2ac6bdb59c50fa5321057feac1be416477..b7d85a4002326c7ab30047485cdcf77243b3da97 100644 (file)
--- 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,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",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,"<td class=\"data\">%s</td>",buildtime(tnelap));
@@ -343,6 +348,11 @@ void topuser(void)
          inperc=(ttnbytes) ? ttnincache * 100. / ttnbytes : 0.;
          ouperc=(ttnbytes) ? ttnoucache *100. / ttnbytes : 0.;
          fprintf(fp_top3,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",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,"<th class=\"header_r\">%s</th>",buildtime(ttnelap));