X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=htmlandlogs.c;h=f16580adbb597adf97499255bc9280316255ce89;hb=ca6f7e80f4ce05259df01ec965beb7a4907b8540;hp=e11af1abac500b99e2b38d3489a4769a57e1455e;hpb=0b9c3c198771800cc6c5fbacfc0272549626bcfd;p=svn%2FPrometheus-QoS%2F.git
diff --git a/htmlandlogs.c b/htmlandlogs.c
index e11af1a..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
@@ -85,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;
@@ -168,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++;
}
@@ -189,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);
@@ -233,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);
@@ -255,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);
@@ -310,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)
{