int just_preview=FALSE; /* preview - generate just stats */\r
int just_logs=FALSE; /* just parse logs */\r
int run=FALSE;\r
+ int total=0;\r
\r
char *chain_forward, *chain_postrouting;\r
char *althosts=NULL;\r
\r
if(f)\r
{\r
- int total=0;\r
+\r
int count=1;\r
i=0;\r
\r
i=1;\r
if(f)\r
{\r
- unsigned long long total=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;\r
+ unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;\r
int active_classes=0;\r
int colspan;\r
FILE *iplog;\r
fprintf(f,"<td align=\"right\">%Lu M</td>\n", ip->upload);\r
fprintf(f,"<td align=\"right\">%d k</td><td align=\"right\">%d k</td><td align=\"right\">%s%d k%s</td><td>%s%d%s</td></tr>\n",\r
ip->min,ip->desired,f1,ip->max,f2,f1,ip->prio,f2);\r
- total+=ip->traffic;\r
+ total_traffic+=ip->traffic;\r
total_direct+=ip->direct;\r
total_proxy+=ip->proxy;\r
total_upload+=ip->upload;\r
}\r
fprintf(f,"<tr><th colspan=\"%d\" align=\"left\">SUMMARY:</td>",colspan-7);\r
fprintf(f,"<th align=\"right\">%Lu M</th>\\r
- <th align=\"right\">%Lu M</th>\n", total, total_direct);\r
+ <th align=\"right\">%Lu M</th>\n", total_traffic, total_direct);\r
if(qos_proxy)\r
{\r
fprintf(f,"<th align=\"right\">%Lu M</th>\n", total_proxy);\r
fputs("<tr><td>Analytic category</td>\n",f);\r
fputs("<td colspan=\"2\" align=\"center\">Active Classes</td><td colspan=\"2\" align=\"center\">Data transfers</td></tr>\n",f);\r
\r
- if_exists(sum,sums,sum->l>=total/4)\r
+ if_exists(sum,sums,sum->l>=total_traffic/4)\r
{\r
fprintf(f,"<tr><td>Top 25%% of traffic</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i==10)\r
{\r
fprintf(f,"<tr><td>Top 10 downloaders</td>\n");\r
- fprintf(f,"<th align=\"right\">10</th><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<th align=\"right\">10</th><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
- if_exists(sum,sums,sum->l>=total/2)\r
+ if_exists(sum,sums,sum->l>=total_traffic/2)\r
{\r
fprintf(f,"<tr><td>Top 50%% of traffic</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
- if_exists(sum,sums,sum->l>=4*total/5)\r
+ if_exists(sum,sums,sum->l>=4*total_traffic/5)\r
{\r
fprintf(f,"<tr><td>Top 80%% of traffic</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><th align=\"right\">%Ld %%</th></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/5)\r
top20_count=sum->i;\r
top20_perc1=(100*sum->i+50)/active_classes;\r
top20_sum=sum->l;\r
- top20_perc2=(100*sum->l+50)/total;\r
+ top20_perc2=(100*sum->l+50)/total_traffic;\r
fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",top20_count,top20_perc1,top20_sum,top20_perc2);\r
}\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/4)\r
{\r
fprintf(f,"<tr><td>Top 25%% downloaders</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=(active_classes+1)/2)\r
{\r
fprintf(f,"<tr><td>Top 50%% downloaders</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><th align=\"right\">%d %%</th><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
if_exists(sum,sums,sum->i>=4*(active_classes+1)/5)\r
{\r
fprintf(f,"<tr><td>Top 80%% downloaders</td>\n");\r
- fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total);\r
+ fprintf(f,"<td align=\"right\">%d</td><td align=\"right\">%d %%</td><td align=\"right\">%Lu M</td><td align=\"right\">%Ld %%</td></tr>\n",sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r
}\r
\r
fprintf(f,"<tr><td><a href=\"%sERP.log\">All users, all traffic</a></td>\n", log_url);\r
- fprintf(f,"<th align=\"right\">%d</th><th align=\"right\">100 %%</th><th align=\"right\">%Lu M</th><th align=\"right\">100 %%</th></tr>\n",active_classes,total);\r
+ fprintf(f,"<th align=\"right\">%d</th><th align=\"right\">100 %%</th><th align=\"right\">%Lu M</th><th align=\"right\">100 %%</th></tr>\n",active_classes,total_traffic);\r
fputs("</table>\n", f);\r
\r
/* write basic ERP data to log directory */\r
iplog=fopen(str,"a");\r
if(iplog)\r
{\r
- fprintf(iplog,"%ld\t%d\t%d %%\t%Lu M\t%Ld %%\t%d\t%Lu M\t%s",\r
- time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, active_classes, total, d); /* d = date*/\r
+ fprintf(iplog,"%ld\t%d\t%d %%\t%Lu M\t%Ld %%\t%d\t%Lu M\t%d\t%s",\r
+ time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, active_classes, total_traffic, total, d); /* d = date*/\r
fclose(iplog);\r
}\r
}\r