From 128e038085291f40482e39e9481d47942af7ceee Mon Sep 17 00:00:00 2001 From: xchaos Date: Sat, 2 Feb 2008 10:38:28 +0000 Subject: [PATCH] yearly stats git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@64 251d49ef-1d17-4917-a970-b30cf55b089b --- optional-tools/monthly-stats.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/optional-tools/monthly-stats.c b/optional-tools/monthly-stats.c index f588a53..b9e2457 100644 --- a/optional-tools/monthly-stats.c +++ b/optional-tools/monthly-stats.c @@ -19,19 +19,20 @@ int main (int argc, char **argv) { char *month,*year,*str,*name,*ptr,*ptr2; long traffic,traffic_month,total=0; - int col,col2,y_ok,m_ok,accept_month,i=1; + int col,col2,y_ok,m_ok,accept_month,i=1,any_month=0; FILE *f; string(str,STRLEN); if(argc<3) { - puts("Usage: monthly-stats Mmm YYYY (Mmm=Jan-Dec, YYYY=year)"); + puts("Usage: monthly-stats Mmm YYYY (Mmm=Jan-Dec or Year, YYYY=year)"); exit(-1); } else { month=argv[1]; + if(eq(month,"Year")) any_month=1; year=argv[2]; } @@ -53,7 +54,7 @@ int main (int argc, char **argv) case 3: traffic=atol(ptr);break; case 7: valid_columns(ptr2,ptr,' ',col2) switch(col2) { - case 2: if(eq(ptr2,month)) m_ok=1; break; + case 2: if(any_month || eq(ptr2,month)) m_ok=1; break; case 5: if(eq(ptr2,year)) y_ok=1; break; } } @@ -84,7 +85,7 @@ int main (int argc, char **argv) every(ip,ips) if(ip->traffic) { - fprintf(f,"%d%s %ld MB %ld GB\n",i++,ip->name,ip->traffic,ip->traffic>>10); fprintf(f,"%d%s%ld MB%ld GB\n",i++,ip->name,ip->traffic,ip->traffic>>10); + fprintf(f,"%d%s%ld MB%ld GB\n",i++,ip->name,ip->traffic,ip->traffic>>10); total+=ip->traffic>>10; } fprintf(f,"Total:%ld GB\n",total); -- 2.30.2