From 9aa195f64e0eaadd020095b675008ea851595062 Mon Sep 17 00:00:00 2001 From: xchaos Date: Thu, 10 May 2012 12:33:52 +0000 Subject: [PATCH] css formatovani tabulek git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@161 251d49ef-1d17-4917-a970-b30cf55b089b --- prometheus.c | 113 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 46 deletions(-) diff --git a/prometheus.c b/prometheus.c index 6d8e049..5152fe4 100644 --- a/prometheus.c +++ b/prometheus.c @@ -65,6 +65,20 @@ 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 row_odd_even = 0; /* */ + +const char *tr_odd_even(void) +{ + row_odd_even = 1 - row_odd_even; + if(row_odd_even) + { + return "\n"; + } + else + { + return "\n"; + } +} /* ======= Help screen is hopefuly self-documenting part of code :-) ======= */ @@ -846,15 +860,16 @@ void parse_ip_log(int argc, char **argv) f=fopen(str,"w"); if(f) { - fprintf(f, "\n ", + fprintf(f, "
%s %slmsData transfersMin.speed
\n ", month, year); + row_odd_even = 0; for_each(iplog, iplogs) { if(iplog->traffic) { - fprintf(f, "\n", total, line); - fputs("
%s %slmsData transfersMin.speed
%d%s", - i++, log_url, iplog->name, iplog->name); + fprintf(f, "%s%d%s", + tr_odd_even(), i++, log_url, iplog->name, iplog->name); if(iplog->lmsid > 0) { /*base URL will be configurable soon ... */ @@ -871,66 +886,67 @@ void parse_ip_log(int argc, char **argv) iplog->l=total; } } - fprintf(f,"
Total:%ld GB%Ld kbps
\n", f); + fprintf(f,"Total:%ld GB%Ld kbps\n", total, line); + fputs("\n", f); + row_odd_even = 0; if(i>10) { - fputs("

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

Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
\n",f); + fputs("\n",f); + fputs("\n\n",f); if_exists(iplog,iplogs,iplog->l>=total/4) { - fprintf(f,"\n"); + 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)); } if_exists(iplog,iplogs,iplog->i==10) { - fprintf(f,"\n"); + fprintf(f,"%s\n", tr_odd_even()); fprintf(f,"\n",(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total)); } if_exists(iplog,iplogs,iplog->l>=total/2) { - fprintf(f,"\n"); + 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)); } if_exists(iplog,iplogs,iplog->l>=4*total/5) { - fprintf(f,"\n"); + 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)); } if_exists (iplog,iplogs,iplog->i>=i/5) { - fprintf(f,"\n"); + 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)); } if_exists(iplog,iplogs,iplog->i>=i/4) { - fprintf(f,"\n"); + 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)); } if_exists(iplog,iplogs,iplog->i>=i/2) { - fprintf(f,"\n"); + 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)); } if_exists(iplog,iplogs,iplog->i>=4*i/5) { - fprintf(f,"\n"); + 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"); + fprintf(f,"\n"); fprintf(f,"\n",i-1,total); - fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 25%% of trafficTop 25%% of traffic%d%d %%%ld G%d %%
Top 10 downloadersTop 10 downloaders10%d %%%ld G%d %%
Top 50%% of trafficTop 50%% of traffic%d%d %%%ld G%d %%
Top 80%% of trafficTop 80%% of traffic%d%d %%%ld G%d %%
Top 20%% downloadersTop 20%% downloaders%d%d %%%ld G%d %%
Top 25%% downloadersTop 25%% downloaders%d%d %%%ld G%d %%
Top 50%% downloadersTop 50%% downloaders%d%d %%%ld G%d %%
Top 80%% downloadersTop 80%% downloaders%d%d %%%ld G%d %%
All users, all traffic
All users, all traffic%d100 %%%ld G100 %%
\n", f); + fputs("\n", f); } fprintf(f, stats_html_signature, version); @@ -1527,19 +1543,20 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); { fprintf(f,"\n", jquery_url); } - fputs("\n\n",f); + fputs("
#groupIPsrequested
\n\n",f); fprintf(f,"\n", keywordcount); - fputs("\n",f); + fputs("\n",f); + row_odd_even = 0; for_each(group, groups) { #ifdef DEBUG printf("%d k group: %d bandwidth requested: %d k\n",group->min,group->count,group->desired); #endif - fprintf(f,"", - count, group->min); - fprintf(f,"", - group->count, group->desired); + fprintf(f, "%s", + tr_odd_even(), count, group->min); + fprintf(f, "", + group->count, group->desired); for_each(keyword, keywords) { @@ -1554,7 +1571,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); printf("Total groups: %d Total bandwidth requested: %d k\nAGGREGATION: 1/%d\n", count, i, i/line); #endif - fprintf(f,"\n", (int)(0.5+i/line)); fprintf(f,"\n", keywordcount, total); - fputs("
#groupIPsrequesteddata limits
%d%d k%d%d k%d%d k%d%d k
Line %Ld k",line); + fprintf(f,"
Line %Ld k",line); fprintf(f,"%d%d k",total,i); for_each(keyword, keywords) @@ -1564,7 +1581,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); fprintf(f,"
Aggregation 1/%d%d traffic classes
\n",f); + fputs("\n",f); } else if(!dry_run && !just_flush) { @@ -1591,9 +1608,9 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); colspan++; } - fprintf(f,"

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

%s",colspan,title); - fprintf(f," (%s)
#hostname
\n\n", d); + fputs("",f); if(found_lmsid) { fputs("\n",f); @@ -1610,8 +1627,10 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); \ \ \ -\n",f); +\n\ +\n",f); + row_odd_even = 0; for_each(ip,ips) if(!use_jquery_popups || !ip->sharing) { char *f1="", *f2=""; @@ -1634,7 +1653,8 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); #endif /* hostnames -------------------------------------- */ - fprintf(f,"", colspan-7, i); + fprintf(f,"", 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)
#hostnamelmsminimumdesiredmaximumprio
prio
%d%s\n", ip->name, i, log_url, ip->name, ip->name); + fprintf(f,"%s%d%s\n", + tr_odd_even(), ip->name, i, log_url, ip->name, ip->name); if(use_jquery_popups) { fprintf(f,"",i); @@ -1736,52 +1756,53 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); } } } - fprintf(f,"
%d CLASSES
%d CLASSES%Lu M%Lu M%Lu M%Lu MFUP-LIMIT %dx LOW-PRIO %dx
\n",limit_count,prio_count); + fprintf(f,"FUP-LIMIT %dx LOW-PRIO %dx\n\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",f); - fputs("\n",f); + fputs("

Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
\n",f); + fputs("\n",f); + fputs("\n",f); if_exists(sum,sums,sum->l>=total_traffic/4) { - fprintf(f,"\n"); + 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); } if_exists(sum,sums,sum->i==10) { - fprintf(f,"\n"); + fprintf(f,"%s\n", tr_odd_even()); fprintf(f,"\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,"\n"); + 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); } if_exists(sum,sums,sum->l>=4*total_traffic/5) { - fprintf(f,"\n"); + 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); } if_exists(sum,sums,sum->i>=(active_classes+1)/5) { - fprintf(f,"\n"); + fprintf(f,"%s\n", tr_odd_even()); top20_count=sum->i; top20_perc1=(100*sum->i+50)/active_classes; top20_sum=sum->l; @@ -1791,25 +1812,25 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); if_exists(sum,sums,sum->i>=(active_classes+1)/4) { - fprintf(f,"\n"); + 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); } if_exists(sum,sums,sum->i>=(active_classes+1)/2) { - fprintf(f,"\n"); + 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); } if_exists(sum,sums,sum->i>=4*(active_classes+1)/5) { - fprintf(f,"\n"); + 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", log_url); + fprintf(f,"\n", log_url); fprintf(f,"\n",active_classes,total_traffic); - fputs("
Enterprise Resource Planning (ERP)
Analytic categoryActive ClassesData transfers
Top 25%% of trafficTop 25%% of traffic%d%d %%%Lu M%Ld %%
Top 10 downloadersTop 10 downloaders10%d %%%Lu M%Ld %%
Top 50%% of trafficTop 50%% of traffic%d%d %%%Lu M%Ld %%
Top 80%% of trafficTop 80%% of traffic%d%d %%%Lu M%Ld %%
Top 20%% downloadersTop 20%% downloaders
Top 25%% downloadersTop 25%% downloaders%d%d %%%Lu M%Ld %%
Top 50%% downloadersTop 50%% downloaders%d%d %%%Lu M%Ld %%
Top 80%% downloadersTop 80%% downloaders%d%d %%%Lu M%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