| 1 | #include "cll1-0.6.2.h"\r |
| 2 | #include "ipstruct.h"\r |
| 3 | #define STRLEN 512\r |
| 4 | \r |
| 5 | extern int row_odd_even;\r |
| 6 | extern int use_jquery_popups;\r |
| 7 | extern struct IP *ips, *ip, *sharedip;\r |
| 8 | extern struct Group *groups, *group;\r |
| 9 | extern struct Keyword *keyword, *defaultkeyword, *keywords;\r |
| 10 | extern const int highest_priority;\r |
| 11 | extern const char *version;\r |
| 12 | extern const char *stats_html_signature;\r |
| 13 | extern char *jquery_url;\r |
| 14 | extern int keywordcount;\r |
| 15 | extern long long int line;\r |
| 16 | extern int dry_run;\r |
| 17 | extern int qos_proxy;\r |
| 18 | extern char *title;\r |
| 19 | extern char *log_url;\r |
| 20 | extern int found_lmsid;\r |
| 21 | extern char *lms_url;\r |
| 22 | extern char *log_dir;\r |
| 23 | \r |
| 24 | const char *tr_odd_even(void);\r |
| 25 | /* implemented in prometheus.c, shared with parselogs.c */\r |
| 26 | \r |
| 27 | void append_log(struct IP *self) /*using global variables*/\r |
| 28 | {\r |
| 29 | char *d, *str;\r |
| 30 | FILE *f; \r |
| 31 | \r |
| 32 | date(d); /* this is typical cll1.h macro - prints current date */ \r |
| 33 | string(str, STRLEN); \r |
| 34 | sprintf(str, "%s/%s.log", log_dir, self->name);\r |
| 35 | \r |
| 36 | /*-----------------------------------------------------------------*/\r |
| 37 | printf("Writing traffic log %s ...\n", str);\r |
| 38 | /*-----------------------------------------------------------------*/\r |
| 39 | f = fopen(str, "a");\r |
| 40 | if(f > 0)\r |
| 41 | {\r |
| 42 | fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",\r |
| 43 | time(NULL), self->name, self->traffic, self->direct, self->proxy,\r |
| 44 | self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/\r |
| 45 | fclose(f);\r |
| 46 | }\r |
| 47 | else\r |
| 48 | {\r |
| 49 | perror(str);\r |
| 50 | }\r |
| 51 | }\r |
| 52 | \r |
| 53 | void write_htmlandlogs(char *html, char *d, int total, int just_preview)\r |
| 54 | {\r |
| 55 | int i;\r |
| 56 | char *str;\r |
| 57 | FILE *f=fopen(html, "w");\r |
| 58 | \r |
| 59 | string(str,STRLEN); \r |
| 60 | if(f > 0)\r |
| 61 | {\r |
| 62 | int count=1;\r |
| 63 | i=0;\r |
| 64 | \r |
| 65 | if(use_jquery_popups)\r |
| 66 | {\r |
| 67 | fprintf(f,"<script type=\"text/javascript\" src=\"%s\"></script>\n", jquery_url);\r |
| 68 | }\r |
| 69 | fputs("<table class=\"decorated last\">\n\\r |
| 70 | <caption>Bandwidth classes</caption>\n\\r |
| 71 | <thead><tr>\n\\r |
| 72 | <th style=\"text-align: right\">#</th>\n\\r |
| 73 | <th style=\"text-align: right\">group</th>\n\\r |
| 74 | <th style=\"text-align: right\">IPs</th>\n\\r |
| 75 | <th style=\"text-align: right\">requested</th>\n",f);\r |
| 76 | fprintf(f,"<th colspan=\"%d\">data limits</th>\n", keywordcount);\r |
| 77 | fputs("</tr></thead><tbody>\n",f);\r |
| 78 | \r |
| 79 | row_odd_even = 0;\r |
| 80 | for_each(group, groups) \r |
| 81 | { \r |
| 82 | #ifdef DEBUG\r |
| 83 | printf("%d kb/s group: %d bandwidth requested: %d kb/s\n",group->min,group->count,group->desired);\r |
| 84 | #endif\r |
| 85 | fprintf(f, "%s<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d kb/s</td>",\r |
| 86 | tr_odd_even(), count, group->min);\r |
| 87 | fprintf(f, "<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d kb/s</td>",\r |
| 88 | group->count, group->desired);\r |
| 89 | \r |
| 90 | for_each(keyword, keywords) if(keyword->ip_count)\r |
| 91 | {\r |
| 92 | fprintf(f,"<td style=\"text-align: right\"><span style=\"color:#%s\">%d MB</span></td>",\r |
| 93 | keyword->html_color, group->min*keyword->data_limit);\r |
| 94 | } \r |
| 95 | i += group->desired; \r |
| 96 | total += group->count;\r |
| 97 | count++; \r |
| 98 | }\r |
| 99 | #ifdef DEBUG\r |
| 100 | printf("Total groups: %d Total bandwidth requested: %d kb/s\nAGGREGATION: 1/%d\n",\r |
| 101 | count, i, i/line);\r |
| 102 | #endif\r |
| 103 | fprintf(f,"</tr></tbody>\n\\r |
| 104 | <thead><tr>\n\\r |
| 105 | <th colspan=\"2\" style=\"text-align: left\">Line %Ld kb/s</td>",line);\r |
| 106 | fprintf(f,"<th style=\"text-align: right\">%d</td><th style=\"text-align: right\">%d kb/s</td>",total,i);\r |
| 107 | \r |
| 108 | for_each(keyword, keywords) if(keyword->ip_count)\r |
| 109 | {\r |
| 110 | fprintf(f,"<th style=\"text-align: right\">%d IPs</th>",keyword->ip_count);\r |
| 111 | }\r |
| 112 | fprintf(f,"</tr><tr><th colspan=\"4\">Aggregation 1/%d</th>\n", (int)(0.5+i/line));\r |
| 113 | fprintf(f,"<th colspan=\"%d\">%d traffic classes</th></tr>\n", keywordcount, total);\r |
| 114 | \r |
| 115 | fputs("</thead></table>\n",f);\r |
| 116 | }\r |
| 117 | else\r |
| 118 | {\r |
| 119 | perror(html);\r |
| 120 | }\r |
| 121 | \r |
| 122 | i=0;\r |
| 123 | if(f > 0)\r |
| 124 | {\r |
| 125 | unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;\r |
| 126 | int active_classes=0;\r |
| 127 | int colspan=12;\r |
| 128 | struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL;\r |
| 129 | int limit_count=0, prio_count=0;\r |
| 130 | int popup_button=0;\r |
| 131 | \r |
| 132 | if(qos_proxy)\r |
| 133 | {\r |
| 134 | colspan++;\r |
| 135 | }\r |
| 136 | \r |
| 137 | fprintf(f,"<p><table class=\"decorated last\">\n<caption>%s",title);\r |
| 138 | fprintf(f," (%s)</caption>\n", d);\r |
| 139 | fputs("<thead><tr>\n<th colspan=\"3\"> </th>\n",f);\r |
| 140 | fputs("<th style=\"text-align: right\">credit</th>\n\\r |
| 141 | <th style=\"text-align: right\">FUP</th>\n\\r |
| 142 | <th style=\"text-align: right\">total</th>\n\\r |
| 143 | <th style=\"text-align: right\">down</th>\n",f);\r |
| 144 | if(qos_proxy)\r |
| 145 | {\r |
| 146 | fputs("<th style=\"text-align: right\">proxy</th>\n",f);\r |
| 147 | }\r |
| 148 | fputs("<th style=\"text-align: right\">up</th>\n\\r |
| 149 | <th style=\"text-align: right\">min</th>\n\\r |
| 150 | <th style=\"text-align: right\">max</th>\n\\r |
| 151 | <th style=\"text-align: right\">limit</th>\n\\r |
| 152 | <th> </th>\n\\r |
| 153 | </tr><tr>\n\\r |
| 154 | <th style=\"text-align: right\">#</th>\n\\r |
| 155 | <th>hostname [+sharing]</th>\n\\r |
| 156 | <th style=\"text-align: right\">LMS</th>\n\\r |
| 157 | <th style=\"text-align: right\">MB</th>\n\\r |
| 158 | <th style=\"text-align: right\">MB</th>\n\\r |
| 159 | <th style=\"text-align: right\">MB</th>\n\\r |
| 160 | <th style=\"text-align: right\">MB</th>\n\\r |
| 161 | <th style=\"text-align: right\">MB</th>\n\\r |
| 162 | <th style=\"text-align: right\">kb/s</th>\n\\r |
| 163 | <th style=\"text-align: right\">kb/s</th>\n\\r |
| 164 | <th style=\"text-align: right\">kb/s</th>\n\\r |
| 165 | <th>prio</th>\n\\r |
| 166 | </tr></thead><tbody>\n",f); \r |
| 167 | \r |
| 168 | row_odd_even = 0;\r |
| 169 | for_each(ip,ips) if(!use_jquery_popups || !ip->sharing)\r |
| 170 | {\r |
| 171 | char *f1="", *f2="";\r |
| 172 | i++;\r |
| 173 | \r |
| 174 | if(ip->max < ip->desired) \r |
| 175 | { \r |
| 176 | f1 = "<span style=\"color:red\">"; \r |
| 177 | f2 = "</span>"; \r |
| 178 | limit_count++; \r |
| 179 | } \r |
| 180 | else if(ip->prio > highest_priority+1) \r |
| 181 | { \r |
| 182 | f1 = "<span style=\"color:brown\">"; \r |
| 183 | f2 = "</span>"; \r |
| 184 | prio_count++; \r |
| 185 | } \r |
| 186 | \r |
| 187 | #ifdef DEBUG\r |
| 188 | printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max); \r |
| 189 | #endif\r |
| 190 | /* hostnames -------------------------------------- */\r |
| 191 | fprintf(f,"%s<td style=\"text-align: right\"><a name=\"%s\"></a>%d</td><td><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", \r |
| 192 | tr_odd_even(), ip->name, i, log_url, ip->name, ip->name);\r |
| 193 | \r |
| 194 | if(use_jquery_popups)\r |
| 195 | {\r |
| 196 | fprintf(f,"<span id=\"sharing_%d\" style=\"display:none\">",i);\r |
| 197 | popup_button=0;\r |
| 198 | for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r |
| 199 | {\r |
| 200 | fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n", log_url, sharedip->name, sharedip->name);\r |
| 201 | popup_button++;\r |
| 202 | }\r |
| 203 | for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */\r |
| 204 | {\r |
| 205 | fprintf(f,"<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s/64</a>\n", log_url, sharedip->addr, sharedip->addr);\r |
| 206 | popup_button++;\r |
| 207 | }\r |
| 208 | fputs("</span>\n",f);\r |
| 209 | if(popup_button)\r |
| 210 | {\r |
| 211 | fprintf(f,"<span>[<a class=\"blue\" href=\"#\" onClick=\"$(this).parent().hide();$(\'#sharing_%d\').show();$(\'#download_%d\').show();$(\'#upload_%d\').show();return(false);\" style=\"cursor: pointer;\">+%d</a>]</span>",\r |
| 212 | i, i, i, popup_button);\r |
| 213 | }\r |
| 214 | }\r |
| 215 | fputs("</td>\n",f);\r |
| 216 | /* ----------------------------------------------- */\r |
| 217 | \r |
| 218 | if(found_lmsid)\r |
| 219 | {\r |
| 220 | fputs("<td style=\"text-align: right\">",f);\r |
| 221 | if(ip->lmsid > 0)\r |
| 222 | {\r |
| 223 | fprintf(f,"<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n", lms_url, ip->lmsid, ip->lmsid);\r |
| 224 | }\r |
| 225 | else if(ip->lmsid == 0)\r |
| 226 | {\r |
| 227 | fputs("-------",f);\r |
| 228 | }\r |
| 229 | fputs("</td>\n",f);\r |
| 230 | }\r |
| 231 | fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->credit);\r |
| 232 | fprintf(f,"<td style=\"text-align: right\"><span style=\"color:#%s\">%Lu</span></td>",\r |
| 233 | ip->keyword->html_color, ip->realquota);\r |
| 234 | fprintf(f,"<td style=\"text-align: right\">%s%Lu%s", f1, ip->traffic, f2);\r |
| 235 | \r |
| 236 | /* download --------------------------------------- */\r |
| 237 | fprintf(f,"</td><td style=\"text-align: right\">%Lu", ip->direct);\r |
| 238 | if(use_jquery_popups)\r |
| 239 | {\r |
| 240 | fprintf(f,"<span id=\"download_%d\" style=\"display:none\">",i);\r |
| 241 | for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r |
| 242 | {\r |
| 243 | fprintf(f,"<br />%Lu", sharedip->direct);\r |
| 244 | }\r |
| 245 | for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */\r |
| 246 | {\r |
| 247 | fprintf(f,"<br />%Lu", sharedip->direct);\r |
| 248 | }\r |
| 249 | fputs("</span>\n",f);\r |
| 250 | }\r |
| 251 | fputs("</td>\n",f);\r |
| 252 | /* ----------------------------------------------- */\r |
| 253 | \r |
| 254 | if(qos_proxy)\r |
| 255 | {\r |
| 256 | fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->proxy);\r |
| 257 | }\r |
| 258 | /* upload ---------------------------------------- */\r |
| 259 | fprintf(f,"<td style=\"text-align: right\">%Lu", ip->upload);\r |
| 260 | if(use_jquery_popups)\r |
| 261 | {\r |
| 262 | fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">",i);\r |
| 263 | for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */\r |
| 264 | {\r |
| 265 | fprintf(f,"<br />%Lu", sharedip->upload);\r |
| 266 | }\r |
| 267 | for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */\r |
| 268 | {\r |
| 269 | fprintf(f,"<br />%Lu", sharedip->upload);\r |
| 270 | }\r |
| 271 | fputs("</span>\n",f);\r |
| 272 | }\r |
| 273 | fputs("</td>\n",f);\r |
| 274 | /* ----------------------------------------------- */\r |
| 275 | \r |
| 276 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 277 | <td style=\"text-align: right\">%d</td>\n\\r |
| 278 | <td style=\"text-align: right\">%s%d%s</td>\n\\r |
| 279 | <td>%s%d%s</td></tr>\n",\r |
| 280 | ip->min, ip->desired, \r |
| 281 | f1, ip->max, f2, \r |
| 282 | f1, ip->prio, f2);\r |
| 283 | \r |
| 284 | total_traffic+=ip->traffic;\r |
| 285 | total_direct+=ip->direct;\r |
| 286 | total_proxy+=ip->proxy;\r |
| 287 | total_upload+=ip->upload;\r |
| 288 | if(ip->traffic>0)\r |
| 289 | {\r |
| 290 | active_classes++;\r |
| 291 | tmp_sum+=ip->traffic;\r |
| 292 | create(sum,Sum);\r |
| 293 | sum->l=tmp_sum;\r |
| 294 | sum->i=active_classes;\r |
| 295 | insert(sum,sums,order_by,i);\r |
| 296 | }\r |
| 297 | \r |
| 298 | if(!just_preview)\r |
| 299 | {\r |
| 300 | append_log(ip);\r |
| 301 | for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))\r |
| 302 | {\r |
| 303 | append_log(sharedip);\r |
| 304 | }\r |
| 305 | }\r |
| 306 | }\r |
| 307 | fprintf(f,"</tbody><thead><tr>\n\\r |
| 308 | <th colspan=\"%d\" style=\"text-align: left\">%d CLASSES</th>", colspan-7, i);\r |
| 309 | fprintf(f,"<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%Lu</th>\n", total_traffic, total_direct);\r |
| 310 | if(qos_proxy)\r |
| 311 | {\r |
| 312 | fprintf(f,"<th style=\"text-align: right\">%Lu</th>\n", total_proxy);\r |
| 313 | }\r |
| 314 | fprintf(f,"<th style=\"text-align: right\">%Lu</th>", total_upload);\r |
| 315 | fprintf(f,"<th colspan=\"4\"><span style=\"color:red\">LIMIT %dx</span> <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</thead></table>\n",limit_count,prio_count);\r |
| 316 | \r |
| 317 | row_odd_even = 0;\r |
| 318 | if(active_classes>10)\r |
| 319 | {\r |
| 320 | int top20_count=0,top20_perc1=0;\r |
| 321 | long long top20_perc2=0;\r |
| 322 | unsigned long long top20_sum=0l;\r |
| 323 | \r |
| 324 | fputs("<a name=\"erp\"></a><p><table class=\"decorated last\"><caption>Enterprise Resource Planning (ERP)</caption>\n",f);\r |
| 325 | fputs("<thead><tr>\n\\r |
| 326 | <th>Analytic category</th>\n\\r |
| 327 | <th colspan=\"2\" style=\"text-align: center\">Active Classes</th>\n\\r |
| 328 | <th colspan=\"2\" style=\"text-align: center\">Data transfers</th>\n\\r |
| 329 | </tr></thead><tbody>\n",f);\r |
| 330 | \r |
| 331 | if_exists(sum,sums,sum->l>=total_traffic/4)\r |
| 332 | {\r |
| 333 | fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r |
| 334 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 335 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 336 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 337 | <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r |
| 338 | sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);\r |
| 339 | }\r |
| 340 | \r |
| 341 | if_exists(sum,sums,sum->i==10)\r |
| 342 | {\r |
| 343 | fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r |
| 344 | fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\\r |
| 345 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 346 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 347 | <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r |
| 348 | (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);\r |
| 349 | }\r |
| 350 | \r |
| 351 | if_exists(sum,sums,sum->l>=total_traffic/2)\r |
| 352 | {\r |
| 353 | fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r |
| 354 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 355 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 356 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 357 | <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",\r |
| 358 | sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r |
| 359 | }\r |
| 360 | \r |
| 361 | if_exists(sum,sums,sum->l>=4*total_traffic/5)\r |
| 362 | {\r |
| 363 | fprintf(f,"%s<td>Top 80%% of traffic</td>\n", tr_odd_even());\r |
| 364 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 365 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 366 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 367 | <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",\r |
| 368 | sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r |
| 369 | }\r |
| 370 | \r |
| 371 | if_exists(sum,sums,sum->i>=(active_classes+1)/5)\r |
| 372 | {\r |
| 373 | fprintf(f,"%s<td>Top 20%% downloaders</td>\n", tr_odd_even());\r |
| 374 | top20_count=sum->i;\r |
| 375 | top20_perc1=(100*sum->i+50)/active_classes;\r |
| 376 | top20_sum=sum->l;\r |
| 377 | top20_perc2=(100*sum->l+50)/total_traffic;\r |
| 378 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 379 | <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r |
| 380 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 381 | <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r |
| 382 | top20_count,top20_perc1,top20_sum,top20_perc2);\r |
| 383 | }\r |
| 384 | \r |
| 385 | if_exists(sum,sums,sum->i>=(active_classes+1)/4)\r |
| 386 | {\r |
| 387 | fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r |
| 388 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 389 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 390 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 391 | <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r |
| 392 | sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r |
| 393 | }\r |
| 394 | \r |
| 395 | if_exists(sum,sums,sum->i>=(active_classes+1)/2)\r |
| 396 | {\r |
| 397 | fprintf(f,"%s<td>Top 50%% downloaders</td>\n", tr_odd_even());\r |
| 398 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 399 | <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r |
| 400 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 401 | <td style=\"text-align: right\">%Ld %%</td></tr>\n",\r |
| 402 | sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r |
| 403 | }\r |
| 404 | \r |
| 405 | if_exists(sum,sums,sum->i>=4*(active_classes+1)/5)\r |
| 406 | {\r |
| 407 | fprintf(f,"%s<td>Top 80%% downloaders</td>\n", tr_odd_even());\r |
| 408 | fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r |
| 409 | <td style=\"text-align: right\">%d %%</td>\n\\r |
| 410 | <td style=\"text-align: right\">%Lu MB</td>\n\\r |
| 411 | <td style=\"text-align: right\">%Ld %%</td></tr></tbody>\n",\r |
| 412 | sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);\r |
| 413 | }\r |
| 414 | \r |
| 415 | fprintf(f,"<thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);\r |
| 416 | fprintf(f,"<th style=\"text-align: right\">%d</th>\n\\r |
| 417 | <th style=\"text-align: right\">100 %%</th>\n\\r |
| 418 | <th style=\"text-align: right\">%Lu MB</th>\n\\r |
| 419 | <th style=\"text-align: right\">100 %%</th></tr>\n",active_classes,total_traffic);\r |
| 420 | fputs("</thead></table>\n", f);\r |
| 421 | \r |
| 422 | /* write basic ERP data to log directory */\r |
| 423 | if(!just_preview)\r |
| 424 | {\r |
| 425 | FILE *iplog;\r |
| 426 | sprintf(str,"%s/ERP.log",log_dir);\r |
| 427 | iplog=fopen(str,"a");\r |
| 428 | if(iplog)\r |
| 429 | {\r |
| 430 | 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",\r |
| 431 | time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2, \r |
| 432 | active_classes, total_traffic, i, limit_count, prio_count, d); /* d = date*/\r |
| 433 | fclose(iplog);\r |
| 434 | }\r |
| 435 | else\r |
| 436 | {\r |
| 437 | perror(str);\r |
| 438 | }\r |
| 439 | }\r |
| 440 | }\r |
| 441 | \r |
| 442 | fprintf(f, stats_html_signature, version);\r |
| 443 | fclose(f);\r |
| 444 | }\r |
| 445 | } |