log bugfix + min. speed logging in monthly/yearly stats
authorxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Sun, 4 May 2008 09:52:06 +0000 (09:52 +0000)
committerxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Sun, 4 May 2008 09:52:06 +0000 (09:52 +0000)
git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@84 251d49ef-1d17-4917-a970-b30cf55b089b

prometheus.c

index d8eaef2d44f4dee405ef9d603ce9b082cffdca43..8a567a173671e6be1758b5f88d11a43facf48b52 100644 (file)
@@ -552,7 +552,6 @@ void get_traffic_statistics(void)
     }  \r
   }\r
 \r
-\r
  free(cmd);\r
 }\r
  \r
@@ -637,17 +636,17 @@ struct IpLog
 {\r
  char *name;\r
  long traffic;\r
+ long guaranted;\r
  list(IpLog);\r
 } *iplog,*iplogs;\r
 \r
 void parse_ip_log(int argc, char **argv) \r
 {\r
- char *month,*year,*str,*name,*ptr,*ptr2;\r
- long traffic,traffic_month,total=0;\r
- int col,col2,y_ok,m_ok,accept_month,i=1,any_month=0;\r
- char mstr[4],ystr[5];\r
- FILE *f;\r
\r
+ char *month, *year, *str, *name, *ptr, *ptr2;\r
+ long traffic, traffic_month, total=0, guaranted;\r
+ int col, col2, y_ok, m_ok, accept_month, i=1, any_month=0;\r
+ char mstr[4], ystr[5];\r
+ FILE *f; \r
  string(str,STRLEN);\r
 \r
  if(argv[1][1]=='l') /* -l */\r
@@ -696,30 +695,36 @@ void parse_ip_log(int argc, char **argv)
   printf("Parsing %s ...",str);\r
   accept_month=0;\r
   traffic_month=0;\r
+  guaranted = 0;\r
   parse(str)\r
   {\r
    y_ok=m_ok=0;  \r
    valid_columns(ptr,_,'\t',col) switch(col)\r
    {\r
-    case 2: name=ptr;break;\r
-    case 3: traffic=atol(ptr);break;\r
-    /* column number   - was 7, now 9...*/\r
+    case 2: name = ptr;break;\r
+    case 3: traffic = atol(ptr);break;\r
+    /* column number   - was 7, now 10...*/\r
     case 7:\r
     case 8:\r
-    case 9: if (isalnum(*ptr)) /* alphanumeric string = date, just one*/\r
-            {\r
-              valid_columns(ptr2,ptr,' ',col2) switch(col2)\r
-              {\r
-               case 2: if(any_month || eq(ptr2,month)) m_ok=1; break;\r
-               case 5: if(eq(ptr2,year)) y_ok=1; break;\r
-              }\r
-            }\r
+    case 9:\r
+    case 10: if (isalnum(*ptr)) /* alphanumeric string = date, just one*/\r
+             {\r
+               valid_columns(ptr2,ptr,' ',col2) switch(col2)\r
+               {\r
+                case 2: if(any_month || eq(ptr2,month)) m_ok = 1; break;\r
+                case 5: if(eq(ptr2,year)) y_ok = 1; break;\r
+               }\r
+             }\r
+             else\r
+             {\r
+               if(col == 7) guaranted = atol(ptr);\r
+             }\r
    }\r
    \r
    if(y_ok && m_ok) \r
    {\r
-    traffic_month+=traffic;\r
-    accept_month=1;\r
+    traffic_month += traffic;\r
+    accept_month = 1;\r
    }\r
   }\r
   done;\r
@@ -727,8 +732,9 @@ void parse_ip_log(int argc, char **argv)
   if(accept_month)\r
   {\r
    create(iplog,IpLog);\r
-   iplog->name=name;\r
-   iplog->traffic=traffic_month;\r
+   iplog->name = name;\r
+   iplog->guaranted = guaranted;\r
+   iplog->traffic = traffic_month;\r
    insert(iplog,iplogs,desc_order_by,traffic);\r
    printf(" %ld MB\n",iplog->traffic);\r
   }\r
@@ -740,14 +746,15 @@ void parse_ip_log(int argc, char **argv)
  f=fopen(str,"w");\r
  if(f)\r
  {\r
-  fprintf(f,"<table border><tr><th colspan=\"4\">Data transfers - %s %s</th></tr>\n ",month,year);\r
+  fprintf(f,"<table border><tr><th colspan=\"4\">Data transfers - %s %s</th><th align=\"right\">Min.speed</th></tr>\n ",month,year);\r
   every(iplog,iplogs)\r
    if(iplog->traffic)\r
    {\r
-    fprintf(f,"<tr><td align=\"right\">%d</td><th>%s</td><td align=\"right\">%ld MB</td><th align=\"right\">%ld GB</th></tr>\n",i++,iplog->name,iplog->traffic,iplog->traffic>>10);\r
+    fprintf(f,"<tr><td align=\"right\">%d</td><th>%s</td><td align=\"right\">%ld MB</td><th align=\"right\">%ld GB</th><th align=\"right\">%ld kbps</th></tr>\n",\r
+              i++, iplog->name, iplog->traffic, iplog->traffic>>10, iplog->guaranted);\r
     total+=iplog->traffic>>10;\r
    }\r
-  fprintf(f,"<tr><th colspan=\"3\" align=\"left\">Total:</th><th align=\"right\">%ld GB</th></tr>\n",total);\r
+  fprintf(f,"<tr><th colspan=\"3\" align=\"left\">Total:</th><th align=\"right\">%ld GB</th><th align=\"right\">%Ld kbps</th></tr>\n", total, line);\r
   fputs("</table>\n",f);\r
   fclose(f);\r
   puts(" done.");\r
This page took 0.162293 seconds and 4 git commands to generate.