From: xchaos Date: Thu, 11 Oct 2012 22:18:46 +0000 (+0000) Subject: separate mega-module htmlandlogs.c X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=commitdiff_plain;h=9a56ab25128074e581fa5f69bac8afa2fb939c82 separate mega-module htmlandlogs.c git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@203 251d49ef-1d17-4917-a970-b30cf55b089b --- diff --git a/Makefile b/Makefile index 439c7ac..a47818e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ prefix=/usr mandir=$(prefix)/share/man sbindir=$(prefix)/sbin sysconfdir=/etc -OBJECTS=parsehosts.o parselogs.o ipv4subnets.o json.o prometheus.o +OBJECTS=parsehosts.o parselogs.o ipv4subnets.o json.o htmlandlogs.o prometheus.o HEADERS=cll1-0.6.2.h ipstruct.h main: prometheus diff --git a/htmlandlogs.c b/htmlandlogs.c new file mode 100644 index 0000000..f624a48 --- /dev/null +++ b/htmlandlogs.c @@ -0,0 +1,433 @@ +#include "cll1-0.6.2.h" +#include "ipstruct.h" +#define STRLEN 512 + +extern int row_odd_even; +extern int use_jquery_popups; +extern struct IP *ips, *ip, *sharedip; +extern struct Group *groups, *group; +extern struct Keyword *keyword, *defaultkeyword, *keywords; +extern const int highest_priority; +extern const char *version; +extern const char *stats_html_signature; +extern char *jquery_url; +extern int keywordcount; +extern long long int line; +extern int dry_run; +extern int qos_proxy; +extern char *title; +extern char *log_url; +extern int found_lmsid; +extern char *lms_url; +extern char *log_dir; + +const char *tr_odd_even(void); +/* implemented in prometheus.c, shared with parselogs.c */ + +void append_log(struct IP *self) /*using global variables*/ +{ + char *d, *str; + 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"); + 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*/ + fclose(f); + } + else + { + perror(str); + } +} + +void write_htmlandlogs(char *html, char *d, int total, int just_preview) +{ + int i; + char *str; + FILE *f=fopen(html,"w"); + + string(str,STRLEN); + if(f > 0) + { + int count=1; + i=0; + + /*-----------------------------------------------------------------*/ + printf("Writing statistics summary into HTML page %s ...\n", html); + /*-----------------------------------------------------------------*/ + + if(use_jquery_popups) + { + fprintf(f,"\n", jquery_url); + } + fputs("\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n",f); + fprintf(f,"\n", keywordcount); + fputs("\n",f); + + row_odd_even = 0; + for_each(group, groups) + { +#ifdef DEBUG + printf("%d kb/s group: %d bandwidth requested: %d kb/s\n",group->min,group->count,group->desired); +#endif + fprintf(f, "%s", + tr_odd_even(), count, group->min); + fprintf(f, "", + group->count, group->desired); + + for_each(keyword, keywords) if(keyword->ip_count) + { + fprintf(f,"", + keyword->html_color, group->min*keyword->data_limit); + } + i += group->desired; + total += group->count; + count++; + } +#ifdef DEBUG + printf("Total groups: %d Total bandwidth requested: %d kb/s\nAGGREGATION: 1/%d\n", + count, i, i/line); +#endif + fprintf(f,"\n\ +\n\ +",keyword->ip_count); + } + fprintf(f,"\n", (int)(0.5+i/line)); + fprintf(f,"\n", keywordcount, total); + + fputs("
Bandwidth classes
#groupIPsrequesteddata limits
%d%d kb/s%d%d kb/s%d MB
Line %Ld kb/s",line); + fprintf(f,"%d%d kb/s",total,i); + + for_each(keyword, keywords) if(keyword->ip_count) + { + fprintf(f,"%d IPs
Aggregation 1/%d%d traffic classes
\n",f); + } + else + { + perror(html); + } + + i=0; + if(f > 0) + { + unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0; + int active_classes=0; + int colspan=12; + struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL; + int limit_count=0, prio_count=0; + int popup_button=0; + + if(qos_proxy) + { + colspan++; + } + + fprintf(f,"

\n\n", d); + fputs("\n\n",f); + fputs("\n\ +\n\ +\n\ +\n",f); + if(qos_proxy) + { + fputs("\n",f); + } + fputs("\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n",f); + + row_odd_even = 0; + for_each(ip,ips) if(!use_jquery_popups || !ip->sharing) + { + char *f1="", *f2=""; + i++; + + if(ip->max < ip->desired) + { + f1 = ""; + f2 = ""; + limit_count++; + } + else if(ip->prio > highest_priority+1) + { + f1 = ""; + f2 = ""; + prio_count++; + } + +#ifdef DEBUG + printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); +#endif + /* hostnames -------------------------------------- */ + fprintf(f,"%s\n",f); + /* ----------------------------------------------- */ + + if(found_lmsid) + { + fputs("\n",f); + } + fprintf(f,"\n", ip->credit); + fprintf(f,"", + ip->keyword->html_color, + ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))); + fprintf(f,"\n",f); + /* ----------------------------------------------- */ + + if(qos_proxy) + { + fprintf(f,"\n", ip->proxy); + } + /* upload ---------------------------------------- */ + fprintf(f,"\n",f); + /* ----------------------------------------------- */ + + fprintf(f,"\n\ +\n\ +\n\ +\n", + ip->min, ip->desired, + f1, ip->max, f2, + f1, ip->prio, f2); + + total_traffic+=ip->traffic; + total_direct+=ip->direct; + total_proxy+=ip->proxy; + total_upload+=ip->upload; + if(ip->traffic>0) + { + active_classes++; + tmp_sum+=ip->traffic; + create(sum,Sum); + sum->l=tmp_sum; + sum->i=active_classes; + insert(sum,sums,order_by,i); + } + + if(!just_preview) + { + append_log(ip); + for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) + { + append_log(sharedip); + } + } + } + fprintf(f,"\n\ +", colspan-7, i); + fprintf(f,"\n", total_traffic, total_direct); + if(qos_proxy) + { + fprintf(f,"\n", total_proxy); + } + fprintf(f,"", total_upload); + fprintf(f,"\n
%s",title); + fprintf(f," (%s)
 creditFUPtotaldownproxyupminmaxlimit 
#hostname [+sharing]LMSMBMBMBMBMBkb/skb/skb/sprio
%d%s\n", + tr_odd_even(), ip->name, i, log_url, ip->name, ip->name); + + if(use_jquery_popups) + { + fprintf(f,"",i); + popup_button=0; + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing)) + { + fprintf(f,"
%s\n", log_url, sharedip->name, sharedip->name); + popup_button++; + } + fputs("
\n",f); + if(popup_button) + { + fprintf(f,"[+%d]", + i, i, i, popup_button); + } + } + fputs("
",f); + if(ip->lmsid > 0) + { + fprintf(f,"%04d\n", lms_url, ip->lmsid, ip->lmsid); + } + else if(ip->lmsid == 0) + { + fputs("-------",f); + } + fputs("%Lu%Lu%s%Lu%s", f1, ip->traffic, f2); + + /* download --------------------------------------- */ + fprintf(f,"%Lu", ip->direct); + if(use_jquery_popups) + { + fprintf(f,"",i); + for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing)) + { + fprintf(f,"
%Lu", sharedip->direct); + } + fputs("
\n",f); + } + fputs("
%Lu%Lu", ip->upload); + if(use_jquery_popups) + { + fprintf(f,"",i); + for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) + { + fprintf(f,"
%Lu", sharedip->upload); + } + fputs("
\n",f); + } + fputs("
%d%d%s%d%s%s%d%s
%d CLASSES%Lu%Lu%Lu%LuLIMIT %dx LOW-PRIO %dx
\n",limit_count,prio_count); + + row_odd_even = 0; + if(active_classes>10) + { + int top20_count=0,top20_perc1=0; + long long top20_perc2=0; + unsigned long long top20_sum=0l; + + fputs("

\n",f); + fputs("\n\ +\n\ +\n\ +\n\ +\n",f); + + if_exists(sum,sums,sum->l>=total_traffic/4) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->i==10) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->l>=total_traffic/2) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->l>=4*total_traffic/5) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->i>=(active_classes+1)/5) + { + fprintf(f,"%s\n", tr_odd_even()); + top20_count=sum->i; + top20_perc1=(100*sum->i+50)/active_classes; + top20_sum=sum->l; + top20_perc2=(100*sum->l+50)/total_traffic; + fprintf(f,"\n\ +\n\ +\n\ +\n", + top20_count,top20_perc1,top20_sum,top20_perc2); + } + + if_exists(sum,sums,sum->i>=(active_classes+1)/4) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->i>=(active_classes+1)/2) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + } + + if_exists(sum,sums,sum->i>=4*(active_classes+1)/5) + { + fprintf(f,"%s\n", tr_odd_even()); + fprintf(f,"\n\ +\n\ +\n\ +\n", + sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + } + + fprintf(f,"\n", log_url); + fprintf(f,"\n\ +\n\ +\n\ +\n",active_classes,total_traffic); + fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 25%% of traffic%d%d %%%Lu MB%Ld %%
Top 10 downloaders10%d %%%Lu MB%Ld %%
Top 50%% of traffic%d%d %%%Lu MB%Ld %%
Top 80%% of traffic%d%d %%%Lu MB%Ld %%
Top 20%% downloaders%d%d %%%Lu MB%Ld %%
Top 25%% downloaders%d%d %%%Lu MB%Ld %%
Top 50%% downloaders%d%d %%%Lu MB%Ld %%
Top 80%% downloaders%d%d %%%Lu MB%Ld %%
All users, all traffic%d100 %%%Lu MB100 %%
\n", f); + + /* write basic ERP data to log directory */ + if(!just_preview) + { + FILE *iplog; + sprintf(str,"%s/ERP.log",log_dir); + 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\t%s", + time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, + active_classes, total_traffic, i, limit_count, prio_count, d); /* d = date*/ + fclose(iplog); + } + else + { + perror(str); + } + } + } + + fprintf(f, stats_html_signature, version); + fclose(f); + } +} \ No newline at end of file diff --git a/prometheus.c b/prometheus.c index 814da9e..e068b8e 100644 --- a/prometheus.c +++ b/prometheus.c @@ -89,7 +89,7 @@ char *html_log_dir = "/var/www/logs/html/"; char *jquery_url = "http://code.jquery.com/jquery-latest.js"; char *lms_url = "/lms/?m=customerinfo&id="; -int use_jquery_popups = 1; +int use_jquery_popups = TRUE; int row_odd_even = 0; /* */ /* === Configuraration file values defaults - stored in global variables ==== */ @@ -97,22 +97,22 @@ int row_odd_even = 0; /* */ int filter_type = 1; /*1 mark, 2 classify*/ char *mark = "MARK"; char *mark_iptables = "MARK --set-mark "; -int dry_run = 0; /* preview - use puts() instead of system() */ +int dry_run = FALSE; /* preview - use puts() instead of system() */ char *iptablespreamble = "*mangle\n:PREROUTING ACCEPT [0:0]\n:POSTROUTING ACCEPT [0:0]\n:INPUT ACCEPT [0:0]\n:OUTPUT ACCEPT [0:0]\n:FORWARD ACCEPT [0:0]"; FILE *iptables_file = NULL; -int enable_credit = 1; /* enable credit file */ -int use_credit = 0; /* use credit file (if enabled)*/ +int enable_credit = TRUE; /* enable credit file */ +int use_credit = FALSE; /* use credit file (if enabled)*/ char *title = "Hall of Fame - Greatest Suckers"; /* hall of fame title */ -int hall_of_fame = 1; /* enable hall of fame */ +int hall_of_fame = TRUE; /* enable hall of fame */ char *lan = "eth0"; /* LAN interface */ char *lan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */ char *wan = "eth1"; /* WAN/ISP interface */ char *wan_medium = "100Mbit"; /* 10Mbit/100Mbit ethernet */ char *qos_leaf = "sfq perturb 5"; /* leaf discipline */ char *qos_free_zone = NULL; /* QoS free zone */ -int qos_proxy = 1; /* include proxy port to QoS */ -int found_lmsid = 0; /* show links to users in LMS information system */ -int include_upload = 1; /* upload+download=total traffic */ +int qos_proxy = TRUE; /* include proxy port to QoS */ +int found_lmsid = FALSE; /* show links to users in LMS information system */ +int include_upload = TRUE; /* upload+download=total traffic */ char *proxy_ip = "192.168.1.1/32"; /* our IP with proxy port */ int proxy_port = 3128; /* proxy port number */ long long int line = 1024; /* WAN/ISP download in kbps */ @@ -128,8 +128,8 @@ int burst_main = 64; int burst_group = 32; int magic_treshold = 8; /* reduce ceil by X*magic_treshhold kbps (hard shaping) */ int keywordcount = 0; -int class_count = 0; -int ip_count = 0; +int class_count = 0; +int ip_count = 0; /* not yet implemented: int fixed_packets = 0; maximum number of pps per IP address (not class!) int packet_limit = 5; maximum number of pps to htn CEIL, not rate !!! @@ -157,6 +157,9 @@ void parse_hosts(char *hosts); void write_json_traffic(char *json); /* implemented in json.c */ +void write_htmlandlogs(char *html, char *d, int total, int just_preview); +/* implemented in htmlandlogs.c */ + const char *tr_odd_even(void) { row_odd_even = 1 - row_odd_even; @@ -568,27 +571,6 @@ char *parse_datafile_line(char *str) } } -void append_log(struct IP *self) /*using global variables*/ -{ - char *d, *str; - 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"); - 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*/ - fclose(f); - } - else - { - perror(str); - } -} /*-----------------------------------------------------------------*/ /* Are you looking for int main(int argc, char **argv) ? :-)) */ @@ -601,14 +583,14 @@ program char *str, *ptr, *d; /* LET A$=B$ :-) */ char *substring; - int parent=1; - int just_flush=FALSE; /* deactivates all previous actions */ - int nodelay=FALSE; - int just_preview=FALSE; /* preview - generate just stats */ - int start_shaping=FALSE; /* apply FUP - requires classmap file */ - int just_logs=FALSE; /* just parse logs */ - int run=FALSE; - int total=0; + int parent = 1; + int just_flush = FALSE; /* deactivates all previous actions */ + int nodelay = FALSE; + int just_preview = FALSE; /* preview - generate just stats */ + int start_shaping = FALSE; /* apply FUP - requires classmap file */ + int just_logs = FALSE; /* just parse logs */ + int run = FALSE; + int total = 0; char *chain_forward, *chain_postrouting; char *althosts=NULL; @@ -1100,384 +1082,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); write_json_traffic(json_traffic); } - f=fopen(html,"w"); - if(f > 0) - { - int count=1; - i=0; - - /*-----------------------------------------------------------------*/ - printf("Sorting data and generating statistics page %s ...\n", html); - /*-----------------------------------------------------------------*/ - - if(use_jquery_popups) - { - fprintf(f,"\n", jquery_url); - } - fputs("\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n",f); - fprintf(f,"\n", keywordcount); - fputs("\n",f); - - row_odd_even = 0; - for_each(group, groups) - { -#ifdef DEBUG - printf("%d kb/s group: %d bandwidth requested: %d kb/s\n",group->min,group->count,group->desired); -#endif - fprintf(f, "%s", - tr_odd_even(), count, group->min); - fprintf(f, "", - group->count, group->desired); - - for_each(keyword, keywords) if(keyword->ip_count) - { - fprintf(f,"", - keyword->html_color, group->min*keyword->data_limit); - } - i += group->desired; - total += group->count; - count++; - } -#ifdef DEBUG - printf("Total groups: %d Total bandwidth requested: %d kb/s\nAGGREGATION: 1/%d\n", - count, i, i/line); -#endif - fprintf(f,"\n\ -\n\ -",keyword->ip_count); - } - fprintf(f,"\n", (int)(0.5+i/line)); - fprintf(f,"\n", keywordcount, total); - - fputs("
Bandwidth classes
#groupIPsrequesteddata limits
%d%d kb/s%d%d kb/s%d MB
Line %Ld kb/s",line); - fprintf(f,"%d%d kb/s",total,i); - - for_each(keyword, keywords) if(keyword->ip_count) - { - fprintf(f,"%d IPs
Aggregation 1/%d%d traffic classes
\n",f); - } - else if(!dry_run && !just_flush) - { - perror(html); - } - - i=0; - if(f > 0) - { - unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0; - int active_classes=0; - int colspan=12; - struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL; - int limit_count=0, prio_count=0; - int popup_button=0; - - if(qos_proxy) - { - colspan++; - } - - fprintf(f,"

\n\n", d); - fputs("\n\n",f); - fputs("\n\ -\n\ -\n\ -\n",f); - if(qos_proxy) - { - fputs("\n",f); - } - fputs("\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n",f); - - row_odd_even = 0; - for_each(ip,ips) if(!use_jquery_popups || !ip->sharing) - { - char *f1="", *f2=""; - i++; - - if(ip->max < ip->desired) - { - f1=""; - f2=""; - limit_count++; - } - else if(ip->prio > highest_priority+1) - { - f1=""; - f2=""; - prio_count++; - } - -#ifdef DEBUG - printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); -#endif - /* hostnames -------------------------------------- */ - fprintf(f,"%s\n",f); - /* ----------------------------------------------- */ - - if(found_lmsid) - { - fputs("\n",f); - } - fprintf(f,"\n", ip->credit); - fprintf(f,"", - ip->keyword->html_color, - ip->credit+(ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20))); - fprintf(f,"\n",f); - /* ----------------------------------------------- */ - - if(qos_proxy) - { - fprintf(f,"\n", ip->proxy); - } - /* upload ---------------------------------------- */ - fprintf(f,"\n",f); - /* ----------------------------------------------- */ - - fprintf(f,"\n\ -\n\ -\n\ -\n", - ip->min, ip->desired, - f1, ip->max, f2, - f1, ip->prio, f2); - - total_traffic+=ip->traffic; - total_direct+=ip->direct; - total_proxy+=ip->proxy; - total_upload+=ip->upload; - if(ip->traffic>0) - { - active_classes++; - tmp_sum+=ip->traffic; - create(sum,Sum); - sum->l=tmp_sum; - sum->i=active_classes; - insert(sum,sums,order_by,i); - } - - if(!just_preview) - { - append_log(ip); - for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) - { - append_log(sharedip); - } - } - } - fprintf(f,"\n\ -", colspan-7, i); - fprintf(f,"\n", total_traffic, total_direct); - if(qos_proxy) - { - fprintf(f,"\n", total_proxy); - } - fprintf(f,"", total_upload); - fprintf(f,"\n
%s",title); - fprintf(f," (%s)
 creditFUPtotaldownproxyupminmaxlimit 
#hostname [+sharing]LMSMBMBMBMBMBkb/skb/skb/sprio
%d%s\n", - tr_odd_even(), ip->name, i, log_url, ip->name, ip->name); - - if(use_jquery_popups) - { - fprintf(f,"",i); - popup_button=0; - for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing)) - { - fprintf(f,"
%s\n", log_url, sharedip->name, sharedip->name); - popup_button++; - } - fputs("
\n",f); - if(popup_button) - { - fprintf(f,"[+%d]", - i, i, i, popup_button); - } - } - fputs("
",f); - if(ip->lmsid > 0) - { - fprintf(f,"%04d\n", lms_url, ip->lmsid, ip->lmsid); - } - else if(ip->lmsid == 0) - { - fputs("-------",f); - } - fputs("%Lu%Lu%s%Lu%s", f1, ip->traffic, f2); - - /* download --------------------------------------- */ - fprintf(f,"%Lu", ip->direct); - if(use_jquery_popups) - { - fprintf(f,"",i); - for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing)) - { - fprintf(f,"
%Lu", sharedip->direct); - } - fputs("
\n",f); - } - fputs("
%Lu%Lu", ip->upload); - if(use_jquery_popups) - { - fprintf(f,"",i); - for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) - { - fprintf(f,"
%Lu", sharedip->upload); - } - fputs("
\n",f); - } - fputs("
%d%d%s%d%s%s%d%s
%d CLASSES%Lu%Lu%Lu%LuLIMIT %dx LOW-PRIO %dx
\n",limit_count,prio_count); - - row_odd_even = 0; - if(active_classes>10) - { - int top20_count=0,top20_perc1=0; - long long top20_perc2=0; - unsigned long long top20_sum=0l; - - fputs("

\n",f); - fputs("\n\ -\n\ -\n\ -\n\ -\n",f); - - if_exists(sum,sums,sum->l>=total_traffic/4) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->i==10) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->l>=total_traffic/2) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->l>=4*total_traffic/5) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->i>=(active_classes+1)/5) - { - fprintf(f,"%s\n", tr_odd_even()); - top20_count=sum->i; - top20_perc1=(100*sum->i+50)/active_classes; - top20_sum=sum->l; - top20_perc2=(100*sum->l+50)/total_traffic; - fprintf(f,"\n\ -\n\ -\n\ -\n", - top20_count,top20_perc1,top20_sum,top20_perc2); - } - - if_exists(sum,sums,sum->i>=(active_classes+1)/4) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->i>=(active_classes+1)/2) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); - } - - if_exists(sum,sums,sum->i>=4*(active_classes+1)/5) - { - fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n\ -\n\ -\n\ -\n", - sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); - } - - fprintf(f,"\n", log_url); - fprintf(f,"\n\ -\n\ -\n\ -\n",active_classes,total_traffic); - fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 25%% of traffic%d%d %%%Lu MB%Ld %%
Top 10 downloaders10%d %%%Lu MB%Ld %%
Top 50%% of traffic%d%d %%%Lu MB%Ld %%
Top 80%% of traffic%d%d %%%Lu MB%Ld %%
Top 20%% downloaders%d%d %%%Lu MB%Ld %%
Top 25%% downloaders%d%d %%%Lu MB%Ld %%
Top 50%% downloaders%d%d %%%Lu MB%Ld %%
Top 80%% downloaders%d%d %%%Lu MB%Ld %%
All users, all traffic%d100 %%%Lu MB100 %%
\n", f); - - /* write basic ERP data to log directory */ - if(!just_preview) - { - FILE *iplog; - sprintf(str,"%s/ERP.log",log_dir); - 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\t%s", - time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, - active_classes, total_traffic, i, limit_count, prio_count, d); /* d = date*/ - fclose(iplog); - } - else - { - perror(str); - } - } - } - - fprintf(f, stats_html_signature, version); - fclose(f); - } + /*-----------------------------------------------------------------*/ + printf("Writing statistics into HTML page %s ...\n", html); + /*-----------------------------------------------------------------*/ + write_htmlandlogs(json_traffic,d,total, just_preview); if(just_preview) {