ip protocol usage statistics and more
authorxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Thu, 24 Jan 2013 13:29:23 +0000 (13:29 +0000)
committerxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Thu, 24 Jan 2013 13:29:23 +0000 (13:29 +0000)
git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@217 251d49ef-1d17-4917-a970-b30cf55b089b

htmlandlogs.c
parsehosts.c
prometheus.c

index c0d564894684a645e37372c6b44ab3c93e850797..f16580adbb597adf97499255bc9280316255ce89 100644 (file)
@@ -20,6 +20,7 @@ extern char *log_url;
 extern int found_lmsid;\r
 extern char *lms_url;\r
 extern char *log_dir;\r
+extern char *ip6prefix;\r
 \r
 const char *tr_odd_even(void);\r
 /* implemented in prometheus.c, shared with parselogs.c */\r
@@ -89,8 +90,8 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
 \r
    for_each(keyword, keywords) if(keyword->ip_count)\r
    {\r
-    fprintf(f,"<td style=\"text-align: right\"><span style=\"color:#%s\">%d&nbsp;MB</span></td>",\r
-              keyword->html_color, group->min*keyword->data_limit);\r
+    fprintf(f, "<td style=\"text-align: right\"><span style=\"color:#%s\">%d&nbsp;MB</span></td>",\r
+               keyword->html_color, group->min*keyword->data_limit);\r
    }   \r
    i += group->desired; \r
    total += group->count;\r
@@ -172,15 +173,15 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
    i++;\r
 \r
    if(ip->max < ip->desired) \r
-   { \r
-    f1 = "<span style=\"color:red\">"; \r
+   {\r
+    f1 = "<span style=\"color:red\">";\r
     f2 = "</span>"; \r
     limit_count++; \r
-   } \r
-   else if(ip->prio > highest_priority+1) \r
-   { \r
-    f1 = "<span style=\"color:brown\">"; \r
-    f2 = "</span>"; \r
+   }\r
+   else if(ip->prio > highest_priority+1)\r
+   {\r
+    f1 = "<span style=\"color:brown\">";\r
+    f2 = "</span>";\r
     prio_count++; \r
    }       \r
 \r
@@ -193,23 +194,28 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
 \r
    if(use_jquery_popups)\r
    {\r
-     fprintf(f,"<span id=\"sharing_%d\" style=\"display:none\">",i);\r
+     fprintf(f, "<span id=\"sharing_%d\" style=\"display:none\">",i);\r
      popup_button=0;\r
+\r
      for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r
      {\r
-      fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", log_url, sharedip->name, sharedip->name);\r
+      fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", \r
+                 log_url, sharedip->name, sharedip->name);\r
       popup_button++;\r
      }\r
+\r
      for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */\r
      {\r
-      fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s/64</a>\n", log_url, sharedip->addr, sharedip->addr);\r
+      fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s/64</a>\n", \r
+                 log_url, sharedip->addr, sharedip->addr);\r
       popup_button++;\r
      }\r
+\r
      fputs("</span>\n",f);\r
      if(popup_button)\r
      {\r
-      fprintf(f,"<span>[<a class=\"blue\" href=\"#\" onClick=\"$(this).parent().hide();$(\'#sharing_%d\').show();$(\'#download_%d\').show();$(\'#upload_%d\').show();return(false);\" style=\"cursor: pointer;\">+%d</a>]</span>",\r
-                i, i, i, popup_button);\r
+      fprintf(f, "<span>[<a class=\"blue\" href=\"#\" onClick=\"$(this).parent().hide();$(\'#sharing_%d\').show();$(\'#download_%d\').show();$(\'#upload_%d\').show();return(false);\" style=\"cursor: pointer;\">+%d</a>]</span>",\r
+                 i, i, i, popup_button);\r
      }\r
    }\r
    fputs("</td>\n",f);\r
@@ -237,7 +243,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
    fprintf(f,"</td><td style=\"text-align: right\">%Lu", ip->direct);\r
    if(use_jquery_popups)\r
    {\r
-     fprintf(f,"<span id=\"download_%d\" style=\"display:none\">",i);\r
+     fprintf(f,"<span id=\"download_%d\" style=\"display:none\">", i);\r
      for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r
      {\r
       fprintf(f,"<br />%Lu", sharedip->direct);\r
@@ -259,7 +265,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
    fprintf(f,"<td style=\"text-align: right\">%Lu", ip->upload);\r
    if(use_jquery_popups)\r
    {\r
-     fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">",i);\r
+     fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">", i);\r
      for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r
      {\r
       fprintf(f,"<br />%Lu", sharedip->upload);\r
@@ -314,6 +320,31 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
   fprintf(f,"<th style=\"text-align: right\">%Lu</th>", total_upload);\r
   fprintf(f,"<th colspan=\"4\"><span style=\"color:red\">LIMIT %dx</span> <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</thead></table>\n",limit_count,prio_count);\r
 \r
+  if(ip6prefix)\r
+  {\r
+   unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0;\r
+   for_each(ip, ips)\r
+   { \r
+    if(ip->v6)\r
+    {\r
+     bytes6 += ip->traffic;\r
+     pkts6 += ip->pktsdown+ip->pktsup;\r
+    }\r
+    else\r
+    {\r
+     bytes4 += ip->traffic;\r
+     pkts4 += ip->pktsdown+ip->pktsup;\r
+    }\r
+   }\r
+\r
+   fputs("<p><table class=\"decorated last\"><caption>IP protocols usage</caption>\n",f);\r
+   fprintf(f, "%s<td>Total IPv4</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%d %%)</td></tr>\n",\r
+              tr_odd_even(), bytes4, (float)(100*bytes4)/(bytes4+bytes6), pkts4, (float)(100*pkts4)/(pkts4+pkts6));\r
+   fprintf(f, "%s<td>Total IPv6</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%d %%)</td></tr>\n",\r
+              tr_odd_even(), bytes6, (float)(100*bytes6)/(bytes4+bytes6), pkts6, (float)(100*pkts6)/(pkts4+pkts6));\r
+   fputs("</table>\n", f);\r
+  }\r
+\r
   row_odd_even = 0;\r
   if(active_classes>10)\r
   {\r
index cbd2d48a1513f94a256d193448d5682a56199405..92ee23ac12dd5442b8b83f8774d4cd9da72a901a 100644 (file)
@@ -57,7 +57,7 @@ parse_ip(char *str)
   if(ptr && ptr-str > 4)\r
   {\r
    ptr -= 4;   \r
-   duplicate(ptr,ip6range);\r
+   duplicate(ptr, ip6range);\r
    ptr = strstr(ip6range, "::");\r
    if(ptr)\r
    {\r
index b5f610be06f59aedc3f3370d8abe5ba0a1e78f2e..20a7603d7b4f7f776d96ca48a5a366c5792ccb72 100644 (file)
@@ -630,8 +630,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   {\r
     perror(cmdlog);\r
     exit(-1);\r
-  }\r
-  \r
+  }  \r
   \r
   sprintf(str,"%s qdisc del dev %s root 2>/dev/null",tc,lan);\r
   safe_run(str);\r
This page took 0.288023 seconds and 4 git commands to generate.