From: Frédéric Marchal Date: Sun, 28 Nov 2010 15:40:28 +0000 (+0000) Subject: Replace the IP address by the user ID in the e-mail report X-Git-Tag: v2.3.2~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=028087222ff33578bc839f3c46ef432f4f886e34;p=thirdparty%2Fsarg.git Replace the IP address by the user ID in the e-mail report --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ff65b4..314ac88 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(sarg C) SET(sarg_VERSION 2) SET(sarg_REVISION "3.2-pre1") SET(sarg_BUILD "") -SET(sarg_BUILDDATE "Nov-22-2010") +SET(sarg_BUILDDATE "Nov-28-2010") INCLUDE(AddFileDependencies) INCLUDE(CheckIncludeFile) diff --git a/ChangeLog b/ChangeLog index fc0b682..eda38c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ SARG ChangeLog -Nov-21-2010 Version 2.3.2-pre1 +Nov-28-2010 Version 2.3.2-pre1 - Add support for sorttable.js (http://www.kryogenix.org/code/browser/sorttable/) to dynamically sort some tables (thanks to Éric). - Add the two command line options --lastlog and --keeplogs to set the number of reports to keep or to keep all the reports respectively (thanks to Emmanuel Lacour for the suggestion). + - Report the user ID in the e-mail report. Sep-18-2010 Version 2.3.1 - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway. diff --git a/email.c b/email.c index 691e596..4a0ca94 100644 --- a/email.c +++ b/email.c @@ -49,6 +49,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema struct getwordstruct gwarea; struct generalitemstruct item; longline line; + const struct userinfostruct *uinfo; snprintf(wger,sizeof(wger),"%s/sarg-general",dirname); if((fp_in=fopen(wger,"r"))==NULL) { @@ -129,17 +130,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema unlink(top2); - if((fp_top1=fopen(top1,"a"))==NULL) { - debuga(_("(email) Cannot open file %s\n"),top1); - exit(EXIT_FAILURE); - } -#if defined(__FreeBSD__) - fprintf(fp_top1,"TOTAL\t%qu\t%qu\t%qu\n",ttnbytes,ttnacc,ttnelap); -#else - fprintf(fp_top1,"TOTAL\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",(uint64_t)ttnbytes,(uint64_t)ttnacc,(uint64_t)ttnelap); -#endif - fclose(fp_top1); - if((fp_top1=fopen(top1,"r"))==NULL) { debuga(_("(email) Cannot open file %s\n"),top1); exit(EXIT_FAILURE); @@ -201,27 +191,33 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema exit(EXIT_FAILURE); } + uinfo=userinfo_find_from_id(user); + if (!uinfo) { + debuga(_("Unknown user ID %s in file %s\n"),user,top1); + exit(EXIT_FAILURE); + } + perc=(ttnbytes) ? nbytes * 100. / ttnbytes : 0; perc2=(ttnelap) ? elap * 100. / ttnelap : 0; posicao++; - if(strcmp(user,"TOTAL") == 0){ - fputs("------- -------------------- -------- --------------- ------- ---------- ---------- -------\n",fp_top3); #if defined(__FreeBSD__) - fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap); + fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10qu %3.2lf%%\n",posicao,uinfo->label,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2); #else - fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",_("TOTAL")," ",(uint64_t)ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),(uint64_t)ttnelap); + fprintf(fp_top3,"%7d %20s %8"PRIu64" %15s %3.2lf%% %10s %10"PRIu64" %3.2lf%%\n",posicao,uinfo->label,(uint64_t)nacc,fixnum(nbytes,1),perc,buildtime(elap),(uint64_t)elap,perc2); #endif - } else { + } + + // output total + fputs("------- -------------------- -------- --------------- ------- ---------- ---------- -------\n",fp_top3); #if defined(__FreeBSD__) - fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10qu %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2); + fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap); #else - fprintf(fp_top3,"%7d %20s %8"PRIu64" %15s %3.2lf%% %10s %10"PRIu64" %3.2lf%%\n",posicao,user,(uint64_t)nacc,fixnum(nbytes,1),perc,buildtime(elap),(uint64_t)elap,perc2); + fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",_("TOTAL")," ",(uint64_t)ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),(uint64_t)ttnelap); #endif - } - } + // compute and write average if (totuser>0) { tnbytes=(totuser) ? ttnbytes / totuser : 0; avgacc=ttnacc/totuser; diff --git a/include/info.h b/include/info.h index e9c1413..a397708 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION PACKAGE_VERSION" Nov-23-2010" +#define VERSION PACKAGE_VERSION" Nov-28-2010" #define PGM PACKAGE_NAME #define URL "http://sarg.sourceforge.net"