json bug fix :-)
[svn/Prometheus-QoS/.git] / prometheus.c
index f12de15..8c70bb0 100644 (file)
@@ -610,7 +610,7 @@ void get_traffic_statistics(void)
      {\r
       printf("(upload) ");\r
      }\r
-     printf("IP %s: %Lu M (%ld pkts)\n", ipaddr, traffic, pkts);\r
+     printf("IP %s: %Lu MB (%ld pkts)\n", ipaddr, traffic, pkts);\r
 \r
      if_exists(ip,ips,eq(ip->addr,ipaddr)); \r
      else \r
@@ -958,7 +958,11 @@ void parse_ip_log(int argc, char **argv)
    if_exists(iplog,iplogs,iplog->l>=total/4)\r
    {\r
     fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
-    fprintf(f,"<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d %%</td><td style=\"text-align: right\">%ld G</td><td style=\"text-align: right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+    fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+              iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
    \r
    if_exists(iplog,iplogs,iplog->i==10)\r
@@ -966,9 +970,9 @@ void parse_ip_log(int argc, char **argv)
     fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r
     fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\\r
 <td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld G</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
 <td style=\"text-align: right\">%d %%</td></tr>\n",\r
-               (100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+               (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    if_exists(iplog,iplogs,iplog->l>=total/2)\r
@@ -976,7 +980,7 @@ void parse_ip_log(int argc, char **argv)
     fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r
     fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
 <td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld G</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
 <td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
               iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
    }\r
@@ -986,9 +990,9 @@ void parse_ip_log(int argc, char **argv)
     fprintf(f,"%s<td>Top 80%% of traffic</td>\n",tr_odd_even());\r
     fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
 <td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld G</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
 <td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
-              iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+              iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    if_exists (iplog,iplogs,iplog->i>=i/5)\r
@@ -996,15 +1000,19 @@ void parse_ip_log(int argc, char **argv)
     fprintf(f,"%s<td>Top 20%% downloaders</td>\n",tr_odd_even());\r
     fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
-<td style=\"text-align: right\">%ld G</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
 <td style=\"text-align: right\">%d %%</td></tr>\n",\r
-              iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+              iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    if_exists(iplog,iplogs,iplog->i>=i/4)\r
    {\r
     fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r
-    fprintf(f,"<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d %%</td><td style=\"text-align: right\">%ld G</td><td style=\"text-align: right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+    fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+               iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    if_exists(iplog,iplogs,iplog->i>=i/2)\r
@@ -1012,19 +1020,25 @@ void parse_ip_log(int argc, char **argv)
     fprintf(f,"%s<td>Top 50%% downloaders</td>\n",tr_odd_even());\r
     fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
-<td style=\"text-align: right\">%ld G</td><td style=\"text-align: right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+              iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    if_exists(iplog,iplogs,iplog->i>=4*i/5)\r
    {\r
     fprintf(f,"%s<td>Top 80%% downloaders</td>\n",tr_odd_even());\r
-    fprintf(f,"<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d %%</td><td style=\"text-align: right\">%ld G</td><td style=\"text-align: right\">%d %%</td></tr>\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+    fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+              iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
    }\r
 \r
    fprintf(f,"</tbody><thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);\r
    fprintf(f,"<th style=\"text-align: right\">%d</th>\n\\r
 <th style=\"text-align: right\">100 %%</th>\n\\r
-<th style=\"text-align: right\">%ld G</th>\n\\r
+<th style=\"text-align: right\">%ld GB</th>\n\\r
 <th style=\"text-align: right\">100 %%</th></tr>\n",i-1,total);\r
    fputs("</thead></table>\n", f);\r
   }\r
@@ -1639,7 +1653,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
     {\r
      fprintf(f, ",\n");\r
     }\r
-    if(ip->traffic || ip->direct || ip->proxy || ip->upload)\r
+    if(     ip->lmsid > 0 \r
+        && (ip->traffic || ip->direct || ip->proxy || ip->upload))\r
     {\r
      fprintf(f, " %d:{ \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu }",\r
                 ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload);\r
@@ -1924,7 +1939,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
    if_exists(sum,sums,sum->l>=total_traffic/4)\r
    {\r
     fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
-    fprintf(f,"<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d %%</td><td style=\"text-align: right\">%Lu M</td><td style=\"text-align: right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
+    fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%Lu MB</td>\n\\r
+<td style=\"text-align: right\">%Ld %%</td></tr>\n",\r
+              sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);\r
    }\r
    \r
    if_exists(sum,sums,sum->i==10)\r
@@ -1934,7 +1953,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
 <td style=\"text-align: right\">%d %%</td>\n\\r
 <td style=\"text-align: right\">%Lu MB</td>\n\\r
 <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r
-              (100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
+              (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);\r
    }\r
 \r
    if_exists(sum,sums,sum->l>=total_traffic/2)\r
@@ -2004,7 +2023,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
    fprintf(f,"<thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);\r
    fprintf(f,"<th style=\"text-align: right\">%d</th>\n\\r
 <th style=\"text-align: right\">100 %%</th>\n\\r
-<th style=\"text-align: right\">%Lu M</th>\n\\r
+<th style=\"text-align: right\">%Lu MB</th>\n\\r
 <th style=\"text-align: right\">100 %%</th></tr>\n",active_classes,total_traffic);\r
    fputs("</thead></table>\n", f);\r
 \r
@@ -2165,7 +2184,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   \r
    if(f)\r
    {\r
-     fprintf(f, "%s %d", ip->addr, ip->mark);\r
+     fprintf(f, "%s %d\n", ip->addr, ip->mark);\r
    }\r
   }\r
   else\r
This page took 0.346354 seconds and 4 git commands to generate.