From 3ece65814820dcc61e151a512dfbd6de5688cd9e Mon Sep 17 00:00:00 2001 From: xchaos Date: Fri, 11 May 2012 18:14:54 +0000 Subject: [PATCH] hall of fame formatting git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@164 251d49ef-1d17-4917-a970-b30cf55b089b --- prometheus.c | 216 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 141 insertions(+), 75 deletions(-) diff --git a/prometheus.c b/prometheus.c index ba52a1a..26d6b08 100644 --- a/prometheus.c +++ b/prometheus.c @@ -925,9 +925,9 @@ void parse_ip_log(int argc, char **argv) { fputs("-------",f); } - fprintf(f, "%ld M\n\ - %ld G\n\ - %ld kbps\n", + fprintf(f, "%ld MB\n\ + %ld GB\n\ + %ld kb/s\n", iplog->traffic, iplog->traffic>>10, iplog->guaranted); total+=iplog->traffic>>10; iplog->i=i; @@ -936,18 +936,20 @@ void parse_ip_log(int argc, char **argv) } fprintf(f,"\ Total:\ - %ld GB\ - %Ld kbps\n", total, line); + %ld GB\ + %Ld kb/s\n", total, line); fputs("\n", f); row_odd_even = 0; if(i>10) { - fputs("

\n\ -\n\ -\n\ -\n\ -\n\n",f); + fputs("

Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n",f); if_exists(iplog,iplogs,iplog->l>=total/4) { @@ -958,25 +960,41 @@ void parse_ip_log(int argc, char **argv) if_exists(iplog,iplogs,iplog->i==10) { fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n",(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); + fprintf(f,"\n\ +\n\ +\n\ +\n", + (100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists(iplog,iplogs,iplog->l>=total/2) { fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); + fprintf(f,"\n\ +\n\ +\n\ +\n", + iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists(iplog,iplogs,iplog->l>=4*total/5) { fprintf(f,"%s\n",tr_odd_even()); - fprintf(f,"\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); + fprintf(f,"\n\ +\n\ +\n\ +\n", + iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists (iplog,iplogs,iplog->i>=i/5) { fprintf(f,"%s\n",tr_odd_even()); - fprintf(f,"\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); + fprintf(f,"\n\ +\n\ +\n\ +\n", + iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists(iplog,iplogs,iplog->i>=i/4) @@ -988,7 +1006,9 @@ void parse_ip_log(int argc, char **argv) if_exists(iplog,iplogs,iplog->i>=i/2) { fprintf(f,"%s\n",tr_odd_even()); - fprintf(f,"\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); + fprintf(f,"\n\ +\n\ +\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists(iplog,iplogs,iplog->i>=4*i/5) @@ -997,9 +1017,13 @@ void parse_ip_log(int argc, char **argv) fprintf(f,"\n",iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } - fprintf(f,"\n"); - fprintf(f,"\n",i-1,total); - fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 10 downloaders10%d %%%ld G%d %%
10%d %%%ld G%d %%
Top 50%% of traffic%d%d %%%ld G%d %%
%d%d %%%ld G%d %%
Top 80%% of traffic%d%d %%%ld G%d %%
%d%d %%%ld G%d %%
Top 20%% downloaders%d%d %%%ld G%d %%
%d%d %%%ld G%d %%
Top 50%% downloaders%d%d %%%ld G%d %%
%d%d %%%ld G%d %%
%d%d %%%ld G%d %%
All users, all traffic%d100 %%%ld G100 %%
\n", f); + fprintf(f,"\n\ +All users, all traffic\n\ +%d\n\ +100 %%\n\ +%ld G\n\ +100 %%\n",i-1,total); + fputs("\n", f); } fprintf(f, stats_html_signature, version); @@ -1147,7 +1171,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); ip->min = atoi(substring); if(ip->min <= 0) { - printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kbps\n", + printf(" %s: Illegal value of minimum bandwidth 0 kbps, using %d kb/s\n", str, free_min); ip->min = free_min; } @@ -1584,7 +1608,6 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } fclose(f); } - f=fopen(html,"w"); ptr=html; } @@ -1602,8 +1625,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { fprintf(f,"\n", jquery_url); } - fputs("\n\n\ -\n\ + fputs("
#
\n\ +\n\ +\n\ +\n\ \n\ \n\ \n",f); @@ -1614,16 +1639,16 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); for_each(group, groups) { #ifdef DEBUG - printf("%d k group: %d bandwidth requested: %d k\n",group->min,group->count,group->desired); + printf("%d kb/s group: %d bandwidth requested: %d kb/s\n",group->min,group->count,group->desired); #endif - fprintf(f, "%s", + fprintf(f, "%s", tr_odd_even(), count, group->min); - fprintf(f, "", + fprintf(f, "", group->count, group->desired); for_each(keyword, keywords) { - fprintf(f,"", + fprintf(f,"", keyword->html_color, group->min*keyword->data_limit); } i += group->desired; @@ -1631,11 +1656,11 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); count++; } #ifdef DEBUG - printf("Total groups: %d Total bandwidth requested: %d k\nAGGREGATION: 1/%d\n", + printf("Total groups: %d Total bandwidth requested: %d kb/s\nAGGREGATION: 1/%d\n", count, i, i/line); #endif - fprintf(f,"
Bandwidth classes
#groupIPsrequested%d%d k%d%d kb/s%d%d k%d%d kb/s%d M%d Mb/s
Line %Ld k",line); - fprintf(f,"%d%d k",total,i); + fprintf(f,"
Line %Ld kb/s",line); + fprintf(f,"%d%d kb/s",total,i); for_each(keyword, keywords) { @@ -1656,7 +1681,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0; int active_classes=0; - int colspan=11; + int colspan=12; FILE *iplog; struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL; int limit_count=0, prio_count=0; @@ -1666,32 +1691,37 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { colspan++; } - if(found_lmsid) - { - colspan++; - } - fprintf(f,"

\n
%s",title); + fprintf(f,"

\n\n", d); - fputs("",f); - if(found_lmsid) - { - fputs("\n",f); - } - fputs("\ -\ -\ -\n",f); + fputs("\n\n",f); + fputs("\n\ +\n\ +\n\ +\n",f); if(qos_proxy) { fputs("\n",f); } - fputs("\ -\ -\ -\ + fputs("\n\ +\n\ +\n\ +\n\ \n\ -\n",f); +\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) @@ -1718,6 +1748,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); /* hostnames -------------------------------------- */ fprintf(f,"%s\n",f); } - fprintf(f,"\n", ip->credit); - fprintf(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", ip->proxy); + fprintf(f,"\n", ip->proxy); } /* upload ---------------------------------------- */ - fprintf(f,"\n",f); /* ----------------------------------------------- */ - fprintf(f,"\n", - ip->min,ip->desired,f1,ip->max,f2,f1,ip->prio,f2); + 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; @@ -1820,12 +1855,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } } fprintf(f,"", colspan-7, i); - fprintf(f,"\n", total_traffic, total_direct); + fprintf(f,"\n", total_traffic, total_direct); if(qos_proxy) { - fprintf(f,"\n", total_proxy); + fprintf(f,"\n", total_proxy); } - fprintf(f,"", total_upload); + fprintf(f,"", total_upload); fprintf(f,"\n
%s",title); fprintf(f," (%s)
#hostnamelmscreditlimittotaldirect
 creditFUPtotaldownproxyuploadminimumdesiredmaximumupminmaxlimitprio
#hostname [+sharing]LMSMBMBMBMBMBkb/skb/skb/s 
%d%s\n", tr_odd_even(), ip->name, i, log_url, ip->name, ip->name); + if(use_jquery_popups) { fprintf(f,"",i); @@ -1742,7 +1773,6 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); fputs("",f); if(ip->lmsid > 0) { - /*base URL will be configurable soon ... */ fprintf(f,"%04d\n", lms_url, ip->lmsid, ip->lmsid); } else if(ip->lmsid == 0) @@ -1751,20 +1781,20 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } fputs("%Lu M%Lu M%Lu%Lu%s%Lu M%s", f1, ip->traffic, f2); + fprintf(f,"%s%Lu%s", f1, ip->traffic, f2); /* download --------------------------------------- */ - fprintf(f,"%Lu M", ip->direct); + 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 M", sharedip->direct); + fprintf(f,"
%Lu", sharedip->direct); } fputs("
\n",f); } @@ -1773,24 +1803,29 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if(qos_proxy) { - fprintf(f,"
%Lu M%Lu%Lu M", ip->upload); + fprintf(f,"%Lu", ip->upload); if(use_jquery_popups) { fprintf(f,"",i); for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) { - fprintf(f,"
%Lu M", sharedip->upload); + fprintf(f,"
%Lu", sharedip->upload); } fputs("
\n",f); } fputs("
%d k%d k%s%d k%s%s%d%s
%d%d%s%d%s%s%d%s
%d CLASSES%Lu M%Lu M%Lu%Lu%Lu M%Lu%Lu M%LuFUP-LIMIT %dx LOW-PRIO %dx
\n",limit_count,prio_count); row_odd_even = 0; @@ -1835,9 +1870,12 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); long long top20_perc2=0; unsigned long long top20_sum=0l; - fputs("

\n",f); - fputs("\n",f); - fputs("\n",f); + fputs("

Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
\n",f); + fputs("\n\ +\n\ +\n\ +\n\ +\n",f); if_exists(sum,sums,sum->l>=total_traffic/4) { @@ -1848,19 +1886,31 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if_exists(sum,sums,sum->i==10) { fprintf(f,"%s\n", tr_odd_even()); - fprintf(f,"\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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) @@ -1870,33 +1920,49 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); top20_perc1=(100*sum->i+50)/active_classes; top20_sum=sum->l; top20_perc2=(100*sum->l+50)/total_traffic; - fprintf(f,"\n",top20_count,top20_perc1,top20_sum,top20_perc2); + 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",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic); + 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", log_url); fprintf(f,"\n\ \n\ \n\ \n",active_classes,total_traffic); - fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 10 downloaders10%d %%%Lu M%Ld %%
10%d %%%Lu MB%Ld %%
Top 50%% of traffic%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
Top 80%% of traffic%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
Top 25%% downloaders%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
Top 50%% downloaders%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
Top 80%% downloaders%d%d %%%Lu M%Ld %%
%d%d %%%Lu MB%Ld %%
All users, all traffic
All users, all traffic%d100 %%%Lu M100 %%
\n", f); + fputs("

\n", f); /* write basic ERP data to log directory */ if(!just_preview) -- 2.30.2