From: xchaos Date: Thu, 24 Jan 2013 13:29:23 +0000 (+0000) Subject: ip protocol usage statistics and more X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=ca6f7e80f4ce05259df01ec965beb7a4907b8540;p=svn%2FPrometheus-QoS%2F.git ip protocol usage statistics and more git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@217 251d49ef-1d17-4917-a970-b30cf55b089b --- diff --git a/htmlandlogs.c b/htmlandlogs.c index c0d5648..f16580a 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -20,6 +20,7 @@ extern char *log_url; extern int found_lmsid; extern char *lms_url; extern char *log_dir; +extern char *ip6prefix; const char *tr_odd_even(void); /* implemented in prometheus.c, shared with parselogs.c */ @@ -89,8 +90,8 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) for_each(keyword, keywords) if(keyword->ip_count) { - fprintf(f,"%d MB", - keyword->html_color, group->min*keyword->data_limit); + fprintf(f, "%d MB", + keyword->html_color, group->min*keyword->data_limit); } i += group->desired; total += group->count; @@ -172,15 +173,15 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) i++; if(ip->max < ip->desired) - { - f1 = ""; + { + f1 = ""; f2 = ""; limit_count++; - } - else if(ip->prio > highest_priority+1) - { - f1 = ""; - f2 = ""; + } + else if(ip->prio > highest_priority+1) + { + f1 = ""; + f2 = ""; prio_count++; } @@ -193,23 +194,28 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) if(use_jquery_popups) { - fprintf(f,"",i); + fprintf(f, "",i); popup_button=0; + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */ { - fprintf(f,"
%s\n", log_url, sharedip->name, sharedip->name); + fprintf(f, "
%s\n", + log_url, sharedip->name, sharedip->name); popup_button++; } + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */ { - fprintf(f,"
%s/64\n", log_url, sharedip->addr, sharedip->addr); + fprintf(f, "
%s/64\n", + log_url, sharedip->addr, sharedip->addr); popup_button++; } + fputs("
\n",f); if(popup_button) { - fprintf(f,"[+%d]", - i, i, i, popup_button); + fprintf(f, "[+%d]", + i, i, i, popup_button); } } fputs("\n",f); @@ -237,7 +243,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) 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->direct); @@ -259,7 +265,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) 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->upload); @@ -314,6 +320,31 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview) fprintf(f,"%Lu", total_upload); fprintf(f,"LIMIT %dx LOW-PRIO %dx\n\n",limit_count,prio_count); + if(ip6prefix) + { + unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0; + for_each(ip, ips) + { + if(ip->v6) + { + bytes6 += ip->traffic; + pkts6 += ip->pktsdown+ip->pktsup; + } + else + { + bytes4 += ip->traffic; + pkts4 += ip->pktsdown+ip->pktsup; + } + } + + fputs("

\n",f); + fprintf(f, "%s\n", + tr_odd_even(), bytes4, (float)(100*bytes4)/(bytes4+bytes6), pkts4, (float)(100*pkts4)/(pkts4+pkts6)); + fprintf(f, "%s\n", + tr_odd_even(), bytes6, (float)(100*bytes6)/(bytes4+bytes6), pkts6, (float)(100*pkts6)/(pkts4+pkts6)); + fputs("
IP protocols usage
Total IPv4%Lu MB (%.2f %%)%Lu packets (%d %%)
Total IPv6%Lu MB (%.2f %%)%Lu packets (%d %%)
\n", f); + } + row_odd_even = 0; if(active_classes>10) { diff --git a/parsehosts.c b/parsehosts.c index cbd2d48..92ee23a 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -57,7 +57,7 @@ parse_ip(char *str) if(ptr && ptr-str > 4) { ptr -= 4; - duplicate(ptr,ip6range); + duplicate(ptr, ip6range); ptr = strstr(ip6range, "::"); if(ptr) { diff --git a/prometheus.c b/prometheus.c index b5f610b..20a7603 100644 --- a/prometheus.c +++ b/prometheus.c @@ -630,8 +630,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { perror(cmdlog); exit(-1); - } - + } sprintf(str,"%s qdisc del dev %s root 2>/dev/null",tc,lan); safe_run(str);