X-Git-Url: https://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=htmlandlogs.c;h=f16580adbb597adf97499255bc9280316255ce89;hp=73a3d0f3f682270e99c28213202c77bcfbfd2a2b;hb=ca6f7e80f4ce05259df01ec965beb7a4907b8540;hpb=e48d46c959233c89ccd6ccd411b31704610abb71
diff --git a/htmlandlogs.c b/htmlandlogs.c
index 73a3d0f..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 */
@@ -30,14 +31,18 @@ void append_log(struct IP *self) /*using global variables*/
FILE *f;
date(d); /* this is typical cll1.h macro - prints current date */
- string(str,STRLEN);
- sprintf(str,"%s/%s.log", log_dir, self->name);
- f=fopen(str,"a");
+ string(str, STRLEN);
+ sprintf(str, "%s/%s.log", log_dir, self->name);
+
+ /*-----------------------------------------------------------------*/
+ printf("Writing traffic log %s ...\n", str);
+ /*-----------------------------------------------------------------*/
+ f = fopen(str, "a");
if(f > 0)
{
- fprintf(f,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",
- time(NULL), self->name, self->traffic, self->direct, self->proxy,
- self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/
+ fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",
+ time(NULL), self->name, self->traffic, self->direct, self->proxy,
+ self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/
fclose(f);
}
else
@@ -50,7 +55,7 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
{
int i;
char *str;
- FILE *f=fopen(html,"w");
+ FILE *f=fopen(html, "w");
string(str,STRLEN);
if(f > 0)
@@ -58,10 +63,6 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
int count=1;
i=0;
- /*-----------------------------------------------------------------*/
- printf("Writing statistics summary into HTML page %s ...\n", html);
- /*-----------------------------------------------------------------*/
-
if(use_jquery_popups)
{
fprintf(f,"\n", jquery_url);
@@ -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,18 +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))
+
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
+ {
+ 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\n", log_url, sharedip->name, sharedip->name);
+ 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);
@@ -232,8 +243,12 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
fprintf(f,"%Lu", ip->direct);
if(use_jquery_popups)
{
- fprintf(f,"",i);
- for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing))
+ fprintf(f,"", i);
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
+ {
+ fprintf(f," %Lu", sharedip->direct);
+ }
+ for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
{
fprintf(f," %Lu", sharedip->direct);
}
@@ -250,8 +265,12 @@ void write_htmlandlogs(char *html, char *d, int total, int just_preview)
fprintf(f," | %Lu", ip->upload);
if(use_jquery_popups)
{
- fprintf(f,"",i);
- for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))
+ fprintf(f,"", i);
+ for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
+ {
+ fprintf(f," %Lu", sharedip->upload);
+ }
+ for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
{
fprintf(f," %Lu", sharedip->upload);
}
@@ -301,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("IP protocols usage\n",f);
+ fprintf(f, "%sTotal IPv4 | %Lu MB (%.2f %%) | %Lu packets (%d %%) | \n",
+ tr_odd_even(), bytes4, (float)(100*bytes4)/(bytes4+bytes6), pkts4, (float)(100*pkts4)/(pkts4+pkts6));
+ fprintf(f, "%sTotal IPv6 | %Lu MB (%.2f %%) | %Lu packets (%d %%) | \n",
+ tr_odd_even(), bytes6, (float)(100*bytes6)/(bytes4+bytes6), pkts6, (float)(100*pkts6)/(pkts4+pkts6));
+ fputs("
\n", f);
+ }
+
row_odd_even = 0;
if(active_classes>10)
{