more work on aggregation
authorxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Tue, 31 Mar 2015 20:10:12 +0000 (20:10 +0000)
committerxchaos <xchaos@251d49ef-1d17-4917-a970-b30cf55b089b>
Tue, 31 Mar 2015 20:10:12 +0000 (20:10 +0000)
git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@250 251d49ef-1d17-4917-a970-b30cf55b089b

htmlandlogs.c
ipstruct.h
parsehosts.c
parseiptables.c
prometheus.c

index 2cb7898b5431cb44a02dff5d9dfbdc34ebffe87f..70377848b7c501bd89f458541495d637d9ecf941 100644 (file)
@@ -130,7 +130,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
   int active_classes = 0;\r
 //  int colspan = 14;\r
   struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums = NULL;\r
-  int limit_count = 0, prio_count = 0;\r
+  int agreg_count = 0, limit_count = 0, prio_count = 0;\r
   int popup_button = 0;\r
   /* IPv6 vs. IPv4 stats */\r
   unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0;\r
@@ -197,7 +197,13 @@ $(\'#pktsup_\'+n).show();\
    char *f1="", *f2="";\r
    i++;\r
 \r
-   if(ip->max < ip->desired) \r
+   if(ip->aggregated > 1)\r
+   {\r
+    f1 = "<span style=\"color:green\">";\r
+    f2 = "</span>";   \r
+    agreg_count++;\r
+   }\r
+   else if(ip->max < ip->desired) \r
    {\r
     f1 = "<span style=\"color:red\">";\r
     f2 = "</span>"; \r
@@ -419,9 +425,11 @@ style=\"cursor: pointer;\">+%d</a>]</span>",
 */\r
   fprintf(f, "<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%d</th>",\r
              total_direct, total_pktdown/i);\r
-  fprintf(f, "<th colspan=\"6\"><span style=\"color:red\">LIMIT %dx</span> \\r
-<span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</thead></table>\n",\r
-             limit_count, prio_count);\r
+  fprintf(f, "<th colspan=\"6\">\\r
+<span style=\"color:green\">AGR %dx</span> \\r
+<span style=\"color:red\">FUP %dx</span> \\r
+<span style=\"color:brown\">PRIO %dx</span></th></tr>\n</thead></table>\n",\r
+             agreg_count, limit_count, prio_count);\r
 \r
   if(ip6prefix)\r
   { \r
index d4383b32fc4192e98ce6d18f01dd2976e966b680..542cb0aa7c7a16ecca6c841481d971565b7c5fe0 100644 (file)
@@ -10,12 +10,15 @@ struct IP
  int max;\r
  int mark;\r
  int prio;\r
+ int aggregated;\r
  int fixedprio;\r
  int group;\r
  int lmsid;\r
  int pps_limit;\r
  unsigned long long direct;\r
  unsigned long long proxy;\r
+ unsigned long long traffic_down;\r
+ unsigned long long traffic_up;\r
  unsigned long long upload;\r
  unsigned long long traffic;\r
  unsigned long long credit;\r
index 1e0c65ceceaf5a6517f94074367b88d1e93d6b36..47b06bd5c28925d6495e7ddf20ca6065311a98e4 100644 (file)
@@ -25,27 +25,30 @@ void update_network(char *look_for, struct IP* ip);
 void TheIP(char *ipaddr, int is_network)\r
 {\r
  create(ip,IP);\r
- ip->name        = "";\r
- ip->addr        = ipaddr;\r
- ip->sharing     = NULL;\r
- ip->prio        = highest_priority+1;\r
- ip->lmsid       = -1;\r
- ip->fixedprio   = \\r
- ip->mark        = \\r
- ip->min         = \\r
- ip->max         = \\r
- ip->desired     = \\r
- ip->credit      = \\r
- ip->upload      = \\r
- ip->proxy       = \\r
- ip->direct      = \\r
- ip->traffic     = \\r
- ip->pktsup      = \\r
- ip->pps_limit   = \\r
- ip->pktsdown    = 0;\r
- ip->keyword     = keywords;\r
- ip->v6          = (strchr(ip->addr,':')!=NULL);\r
- ip->mask        = ((ip->v6)?64:32);\r
+ ip->name         = "";\r
+ ip->addr         = ipaddr;\r
+ ip->sharing      = NULL;\r
+ ip->prio         = highest_priority+1;\r
+ ip->lmsid        = -1;\r
+ ip->fixedprio    = \\r
+ ip->aggregated   = \\r
+ ip->mark         = \\r
+ ip->min          = \\r
+ ip->max          = \\r
+ ip->desired      = \\r
+ ip->credit       = \\r
+ ip->upload       = \\r
+ ip->proxy        = \\r
+ ip->direct       = \\r
+ ip->traffic      = \\r
+ ip->traffic_down = \\r
+ ip->traffic_up   = \\r
+ ip->pktsup       = \\r
+ ip->pps_limit    = \\r
+ ip->pktsdown     = 0;\r
+ ip->keyword      = keywords;\r
+ ip->v6           = (strchr(ip->addr,':')!=NULL);\r
+ ip->mask         = ((ip->v6)?64:32);\r
  if(is_network)\r
  {\r
   push(ip, networks);\r
index eca2ced6221c4af51d98be83b5a9c0adf9376c86..8544df788461c6a0aa29d6a83a89b7e68876a8d0 100644 (file)
@@ -178,6 +178,7 @@ void get_traffic_statistics(const char *whichiptables, int ipv6)
     else\r
     {*/\r
     ip->traffic += traffic;\r
+    ip->traffic_down += traffic;\r
 /*    } */\r
     ip->direct += traffic; /*-ip->proxy;*/\r
     ip->pktsdown += pkts;\r
@@ -185,6 +186,7 @@ void get_traffic_statistics(const char *whichiptables, int ipv6)
    else\r
    {\r
     ip->upload += traffic;\r
+    ip->traffic_up += traffic;\r
     ip->pktsup += pkts;\r
     if(include_upload)\r
     {\r
index 313941946142eb2cba45a134ae20ae66c507bff6..2b9b6052db88fb64b5cbf9bc44ace6d28850ca87 100644 (file)
@@ -7,7 +7,7 @@
 /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf  */\r
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
 \r
-/* Modified by: xChaos, 20150315\r
+/* Modified by: xChaos, 20150331\r
                  ludva, 20080415\r
  \r
    Prometheus QoS is free software; you can redistribute it and/or\r
@@ -605,6 +605,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   for_each(sharedip, ips) if(eq(sharedip->name, ip->sharing))\r
   {\r
    sharedip->traffic += ip->traffic;\r
+   sharedip->traffic_down += ip->direct;\r
+   sharedip->traffic_up += ip->upload;\r
    ip->traffic = 0;\r
    ip->mark = sharedip->mark; \r
    ip->lmsid = sharedip->lmsid;\r
@@ -1051,8 +1053,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
      if_exists(ip,ips,eq(ip->addr,_))\r
      {\r
       int unshape_this_ip = stop_shaping;\r
-      long avg_mbps_down = ip->direct * 8 / how_much_seconds;\r
-      long avg_mbps_up = ip->upload * 8 / how_much_seconds;\r
+      long avg_mbps_down = ip->traffic_down * 8 / how_much_seconds; \r
+      long avg_mbps_up = ip->traffic_up * 8 / how_much_seconds;\r
       int min_mbps = ip->min>>10;\r
       int agreg = 1, print_stats = 1;\r
       \r
@@ -1066,7 +1068,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
        if(min_mbps <= avg_mbps_down)\r
        {\r
         unshape_this_ip = 0;\r
-        agreg = (avg_mbps_down+1)/min_mbps;\r
+        agreg = (int)((float)(avg_mbps_down+1)/min_mbps+.5);\r
         ip->max /= agreg;\r
         printf("Download aggregation 1:%d for %s (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_down);\r
        }\r
@@ -1080,7 +1082,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
        if(min_mbps <= avg_mbps_up)\r
        {\r
         unshape_this_ip = 0;\r
-        agreg = (avg_mbps_up+1)/min_mbps;\r
+        agreg = (int)((float)(avg_mbps_up+1)/min_mbps+.5);\r
         ip->max /= agreg;\r
         printf("Upload aggregation 1:%d for %s: (min: %lu Mbps avg: %ld Mbps)\n", agreg, ip->name, min_mbps, avg_mbps_up);\r
        }\r
@@ -1089,7 +1091,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
         unshape_this_ip = 1;\r
        }\r
       }\r
-      ip->mark=atoi(ptr);\r
+      ip->aggregated = agreg;      \r
+      ip->mark = atoi(ptr);\r
       if(ip->max < ip->desired || unshape_this_ip || reduce_ceil) /* apply or disable FUP limit immediately.... */\r
       {\r
        if(unshape_this_ip)\r
This page took 0.189654 seconds and 4 git commands to generate.