From: xchaos Date: Fri, 25 Jan 2013 13:14:01 +0000 (+0000) Subject: prometheus -2, prometheus -4 X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=62b118c2d21d2ee89872ec6d3e253039728abd5d;p=svn%2FPrometheus-QoS%2F.git prometheus -2, prometheus -4 git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@221 251d49ef-1d17-4917-a970-b30cf55b089b --- diff --git a/help.c b/help.c index d4c7fb8..6602156 100644 --- a/help.c +++ b/help.c @@ -13,6 +13,8 @@ void help(void) -p just generate Preview of data transfer statistics and exit (after -r)\n\ -s Start shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\ -q Quit shaping FUP limits (keeps data transfer stat like -p) (after -r)\n\ +-2 Reduce HTB ceil (min+(max-min)/2 + keep stats like -p) (after -r)\n\ +-4 Reduce HTB ceil (min+(max-min)/2 + keep stats like -p) (after -r)\n\ -n run Now (like -r delay - overrides qos-free-delay keyword, after boot)\n\ -f just Flush iptables and tc classes and exit (stop shaping, no QiS)\n\ -9 emergency iptables flush (like -f, but dumps data transfer statistics)\n\ diff --git a/htmlandlogs.c b/htmlandlogs.c index 291871e..c6d1612 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -346,9 +346,9 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) perc6=(double)(bytes6)/(bytes4+bytes6)*100; fputs("

\n",f); - fprintf(f, "%s\n", + fprintf(f, "%s\n", tr_odd_even(), count4, bytes4, (double)(bytes4)/(bytes4+bytes6)*100, pkts4, (float)(100*pkts4)/(pkts4+pkts6)); - fprintf(f, "%s\n", + fprintf(f, "%s\n", tr_odd_even(), count6, bytes6, perc6, pkts6, (float)(100*pkts6)/(pkts4+pkts6)); fputs("
IP protocols usage
Total %d IPv4 (addreses)%Lu MB (%.2f %%)%Lu packets (%.2f %%)
Total %d IPv4 addreses%Lu MB (%.2f %%)%Lu packets (%.2f %%)
Total %d IPv6 (/64 ranges)%Lu MB (%.2f %%)%Lu packets (%.2f %%)
Total %d IPv6 /64 ranges%Lu MB (%.2f %%)%Lu packets (%.2f %%)

\n", f); } @@ -466,7 +466,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) iplog=fopen(str,"a"); if(iplog) { - fprintf(iplog, "%ld\t%d\t%d %%\t%Lu M\t%Ld %%\tACTIVE %d\tTRAFFIC %Lu M\tCLASSES %d\tFUP-LIMIT %d\tLOW-PRIO %d\tIPv6 %Lu\t%.2f %%\t%s", + fprintf(iplog, "%ld\t%d\t%d %%\t%Lu M\t%Ld %%\tACTIVE %d\tTRAFFIC %Lu M\tCLASSES %d\tFUP-LIMIT %d\tLOW-PRIO %d\tIPv6 %Lu M\t%.2f %%\t%s", time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, active_classes, total_traffic, i, limit_count, prio_count, bytes6, perc6, d); /* d = date*/ diff --git a/prometheus.c b/prometheus.c index 70b0953..b7b3a04 100644 --- a/prometheus.c +++ b/prometheus.c @@ -472,7 +472,8 @@ program int nodelay = FALSE; int just_preview = FALSE; /* preview - generate just stats */ int start_shaping = FALSE; /* apply FUP - requires classmap file */ - int stop_shaping = FALSE; /* apply FUP - requires classmap file */ + int stop_shaping = FALSE; /* lift FUP - requires classmap file */ + int reduce_ceil = 0; /* allow only rate+(ceil-rate)/2, /4, etc. */ int just_logs = FALSE; /* just parse logs */ int run = FALSE; int total = 0; @@ -496,6 +497,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); argument("-9") { run=TRUE; just_flush=9; } argument("-p") { run=TRUE; just_preview=TRUE; } argument("-q") { run=TRUE; just_preview=TRUE; stop_shaping=TRUE; } + argument("-2") { run=TRUE; just_preview=TRUE; reduce_ceil=2; } + argument("-4") { run=TRUE; just_preview=TRUE; reduce_ceil=4; } argument("-s") { run=TRUE; just_preview=TRUE; start_shaping=TRUE; } argument("-r") { run=TRUE; } argument("-n") { run=TRUE; nodelay=TRUE; } @@ -979,7 +982,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if(just_preview) { - if(start_shaping || stop_shaping) + if(start_shaping || stop_shaping || reduce_ceil) { printf("Reading %s and applying Fair Use Policy rules ... \n", classmap); parse(classmap) @@ -992,7 +995,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if_exists(ip,ips,eq(ip->addr,_)) { ip->mark=atoi(ptr); - if(ip->max < ip->desired || stop_shaping) /* apply or disable FUP limit immediately.... */ + if(ip->max < ip->desired || stop_shaping || reduce_ceil) /* apply or disable FUP limit immediately.... */ { if(stop_shaping) { @@ -1001,7 +1004,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } else { - printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); + printf("Applying limit for %-22s %-16s %04d ", ip->name, ip->addr, ip->mark); + if(reduce_ceil) + { + ip->max = ip->min + (ip->desired-ip->min)/reduce_ceil; + } } printf("(down: %dk-%dk ", ip->min, ip->max); sprintf(str, "%s class change dev %s parent 1:%d classid 1:%d htb rate %dkbit ceil %dkbit burst %dk prio %d", @@ -1051,6 +1058,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { swchar='s'; } + else if(reduce_ceil) + { + swchar='0'+reduce_ceil; /* -2, -4 */ + } else if(stop_shaping) { swchar='q';