hosts-ping: moving averages added
[svn/Prometheus-QoS/.git] / prometheus.c
index 503bbac068ccc51ae089671cb4709c7b50f9b319..b7b3a04620b9f55b3a6252728a44baf8c7094287 100644 (file)
@@ -472,6 +472,8 @@ program
  int nodelay       = FALSE;\r
  int just_preview  = FALSE;       /* preview - generate just stats */\r
  int start_shaping = FALSE;       /* apply FUP - requires classmap file */\r
+ int stop_shaping  = FALSE;       /* lift FUP - requires classmap file */\r
+ int reduce_ceil     = 0;           /* allow only rate+(ceil-rate)/2, /4, etc. */\r
  int just_logs     = FALSE;       /* just parse logs */\r
  int run           = FALSE;\r
  int total         = 0;\r
@@ -494,6 +496,9 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   argument("-f") { run=TRUE; just_flush=TRUE; }\r
   argument("-9") { run=TRUE; just_flush=9; }\r
   argument("-p") { run=TRUE; just_preview=TRUE; }\r
+  argument("-q") { run=TRUE; just_preview=TRUE; stop_shaping=TRUE; }\r
+  argument("-2") { run=TRUE; just_preview=TRUE; reduce_ceil=2; }\r
+  argument("-4") { run=TRUE; just_preview=TRUE; reduce_ceil=4; }\r
   argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; }\r
   argument("-r") { run=TRUE; }\r
   argument("-n") { run=TRUE; nodelay=TRUE; }\r
@@ -977,7 +982,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
 \r
  if(just_preview)\r
  {\r
-  if(start_shaping)\r
+  if(start_shaping || stop_shaping || reduce_ceil)\r
   {\r
    printf("Reading %s and applying Fair Use Policy rules ... \n", classmap);\r
    parse(classmap)\r
@@ -990,9 +995,21 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
      if_exists(ip,ips,eq(ip->addr,_))\r
      {\r
       ip->mark=atoi(ptr);\r
-      if(ip->max < ip->desired) /* apply FUP limit immediately.... */\r
+      if(ip->max < ip->desired || stop_shaping || reduce_ceil) /* apply or disable FUP limit immediately.... */\r
       {\r
-       printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark);       \r
+       if(stop_shaping)\r
+       {\r
+        ip->max = ip->desired;\r
+        printf("Removing limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark);               \r
+       }\r
+       else\r
+       {\r
+        printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark);\r
+        if(reduce_ceil)\r
+        {\r
+         ip->max = ip->min + (ip->desired-ip->min)/reduce_ceil;\r
+        }\r
+       }\r
        printf("(down: %dk-%dk ", ip->min, ip->max); \r
        sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", \r
                     tc, lan, ip->group, ip->mark,ip->min,ip->max, burst, ip->prio);\r
@@ -1013,6 +1030,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
     perror(classmap);\r
     puts("Warning - classmap file not fund, just generating preview ...");\r
     start_shaping=FALSE;\r
+    stop_shaping=FALSE;\r
    }\r
    done; /* ugly macro end */\r
   }\r
@@ -1040,6 +1058,15 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
   {\r
    swchar='s';\r
   }\r
+  else if(reduce_ceil)\r
+  {\r
+   swchar='0'+reduce_ceil; /* -2, -4 */\r
+  }\r
+  else if(stop_shaping)\r
+  {\r
+   swchar='q';\r
+  }\r
+\r
   printf("Statistics preview generated (-%c switch) - now exiting ...\n", swchar);\r
   exit(0);\r
  }  \r
This page took 0.123359 seconds and 4 git commands to generate.