From 8e7aa99528485133231579d5933643eecfe0e0af Mon Sep 17 00:00:00 2001 From: xchaos Date: Tue, 19 Nov 2013 11:08:24 +0000 Subject: [PATCH] iptables --burst-limit added + some preliminary packet statistics in html output (to be continued) git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@235 251d49ef-1d17-4917-a970-b30cf55b089b --- htmlandlogs.c | 153 +++++++++++++++++++++++++++++++++++++++++--------- prometheus.c | 5 +- 2 files changed, 128 insertions(+), 30 deletions(-) diff --git a/htmlandlogs.c b/htmlandlogs.c index c6d1612..39a4286 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -1,3 +1,5 @@ +/* Modified by: xChaos, 20131119 */ + #include "cll1-0.6.2.h" #include "ipstruct.h" #define STRLEN 512 @@ -124,33 +126,50 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) if(f > 0) { unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0; + unsigned long long total_pktup = 0, total_pktdown = 0; int active_classes = 0; - int colspan = 12; +// int colspan = 14; struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums = NULL; int limit_count = 0, prio_count = 0; int popup_button = 0; /* IPv6 vs. IPv4 stats */ unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0; int count4 = 0, count6 = 0; + int mpkts; double perc6; +/* if(qos_proxy) { colspan++; } - +*/ + if(use_jquery_popups) + { + fprintf(f,""); + } + fprintf(f,"

\n\n", d); fputs("\n\n",f); - fputs("\n\ + fputs("\n\ \n\ \n\ -\n",f); +\n",f); +/* if(qos_proxy) { fputs("\n",f); } - fputs("\n\ +*/ + fputs("\n\ \n\ \n\ \n\ @@ -163,11 +182,13 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) \n\ \n\ \n\ +\n\ \n\ +\n\ \n\ \n\ \n\ -\n\ +\n\ \n",f); row_odd_even = 0; @@ -193,7 +214,8 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); #endif /* hostnames -------------------------------------- */ - fprintf(f,"%s\ +\n",f); @@ -230,7 +254,8 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) fputs("\n", ip->credit); fprintf(f,"", ip->keyword->html_color, ip->realquota); - fprintf(f,"", f1, ip->traffic, f2); - /* download --------------------------------------- */ - fprintf(f,"\n",f); - /* ----------------------------------------------- */ + /* pkts up ----------------------------------- */ + mpkts = ip->pktsup>>20; + total_pktup += mpkts; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"\n",f); + +/* if(qos_proxy) { fprintf(f,"\n", ip->proxy); } - /* upload ---------------------------------------- */ - fprintf(f,"\n",f); + + /* pkts down ---------------------------------------- */ + mpkts = ip->pktsdown>>20; + total_pktdown += mpkts; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"\n\ -", colspan-7, i); - fprintf(f, "\n", - total_traffic, total_direct); + fprintf(f, "\n\ +", i); + fprintf(f, "\ +\n", + total_traffic, total_upload, total_pktup/i); +/* if(qos_proxy) { fprintf(f," \n", total_proxy); } - fprintf(f, "", total_upload); - fprintf(f, "\n
%s",title); fprintf(f," (%s)
 creditcred.FUPtotaldownuploadproxyupdownloadminmaxlimitMBMBMBpktMBpktkb/skb/skb/sprio!
%d%s\n", + fprintf(f,"%s%d%s\n", tr_odd_even(), ip->name, i, log_url, ip->name, ip->name); if(use_jquery_popups) @@ -218,8 +240,10 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) fputs("\n",f); if(popup_button) { - fprintf(f, "[+%d]", - i, i, i, popup_button); + fprintf(f, "[+%d]", + i, popup_button); } } fputs("",f); if(ip->lmsid > 0) { - fprintf(f,"%04d\n", lms_url, ip->lmsid, ip->lmsid); + fprintf(f, "%04d\n", + lms_url, ip->lmsid, ip->lmsid); } else if(ip->lmsid == 0) { @@ -241,42 +266,109 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) fprintf(f,"%Lu%Lu%s%Lu%s", f1, ip->traffic, f2); + fprintf(f,"%s%Lu%s%Lu", ip->direct); + /* upload --------------------------------------- */ + fprintf(f,"%Lu", ip->upload); if(use_jquery_popups) { - fprintf(f,"", i); + fprintf(f,"", i); for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */ { - fprintf(f,"
%Lu", sharedip->direct); + fprintf(f,"
%Lu", sharedip->upload); } for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */ { - fprintf(f,"
%Lu", sharedip->direct); + fprintf(f,"
%Lu", sharedip->upload); } fputs("
\n",f); } fputs("
%d", ip->upload/mpkts); + if(use_jquery_popups) + { + fprintf(f,"", i); + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */ + { + mpkts = sharedip->pktsup>>20; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"
%d", sharedip->upload/mpkts); + } + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */ + { + mpkts = sharedip->pktsup>>20; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"
%d", sharedip->upload/mpkts); + } + fputs("
\n",f); + } + fputs("
%Lu%Lu", ip->upload); +*/ + /* download ---------------------------------------- */ + fprintf(f,"%Lu", ip->direct); if(use_jquery_popups) { - fprintf(f,"", i); + fprintf(f,"", i); for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */ { - fprintf(f,"
%Lu", sharedip->upload); + fprintf(f,"
%Lu", sharedip->direct); } for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */ { - fprintf(f,"
%Lu", sharedip->upload); + fprintf(f,"
%Lu", sharedip->direct); + } + fputs("
\n",f); + } + fputs("
%d", ip->direct/mpkts); + if(use_jquery_popups) + { + fprintf(f,"", i); + for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */ + { + mpkts = sharedip->pktsdown>>20; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"
%d", sharedip->direct/mpkts); + } + for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */ + { + mpkts = sharedip->pktsdown>>20; + if(mpkts == 0) + { + mpkts = 1; /* prevent divide by zero*/ + } + fprintf(f,"
%d", sharedip->direct/mpkts); } fputs("
\n",f); } @@ -314,16 +406,21 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) } } } - fprintf(f,"
%d CLASSES%Lu%Lu
%d CLASSES%Lu%Lu%d%Lu%LuLIMIT %dx LOW-PRIO %dx
\n", +*/ + fprintf(f, "%Lu%d", + total_direct, total_pktdown/i); + fprintf(f, "LIMIT %dx \ +LOW-PRIO %dx\n\n", limit_count, prio_count); if(ip6prefix) diff --git a/prometheus.c b/prometheus.c index 279da9b..c3ae02c 100644 --- a/prometheus.c +++ b/prometheus.c @@ -7,7 +7,7 @@ /* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* Modified by: xChaos, 20131118 +/* Modified by: xChaos, 20131119 ludva, 20080415 Prometheus QoS is free software; you can redistribute it and/or @@ -1130,7 +1130,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /* packet limits - this will be optional in future, hardcoded for now */ if(ip->pps_limit) { - sprintf(limit_pkts, "-m limit --limit %d/s ", ip->pps_limit); + sprintf(limit_pkts, "-m limit --limit %d/s --limit-burst %d ", + ip->pps_limit, ip->pps_limit); } else { -- 2.30.2