b6f9cb66602c080c23b220dd177cd2076a95df98
[svn/Prometheus-QoS/.git] / htmlandlogs.c
1 /* Modified by: xChaos, 20131119 */
2
3 #include "cll1-0.6.2.h"
4 #include "ipstruct.h"
5 #define STRLEN 512
6
7 extern int row_odd_even;
8 extern int use_jquery_popups;
9 extern struct IP *ips, *ip, *sharedip;
10 extern struct Group *groups, *group;
11 extern struct Keyword *keyword, *defaultkeyword, *keywords;
12 extern const int highest_priority;
13 extern const char *version;
14 extern const char *stats_html_signature;
15 extern char *jquery_url;
16 extern int keywordcount;
17 extern int dry_run;
18 extern int qos_proxy;
19 extern char *title;
20 extern char *log_url;
21 extern int found_lmsid;
22 extern char *lms_url;
23 extern char *log_dir;
24 extern char *ip6prefix;
25
26 const char *tr_odd_even(void);
27 /* implemented in prometheus.c, shared with parselogs.c */
28
29 void append_log(struct IP *self) /*using global variables*/
30 {
31 char *d, *str;
32 FILE *f;
33
34 date(d); /* this is typical cll1.h macro - prints current date */
35 string(str, STRLEN);
36 sprintf(str, "%s/%s.log", log_dir, self->name);
37
38 /*-----------------------------------------------------------------*/
39 printf("Writing traffic log %s ...\n", str);
40 /*-----------------------------------------------------------------*/
41 f = fopen(str, "a");
42 if(f > 0)
43 {
44 fprintf(f, "%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",
45 time(NULL), self->name, self->traffic, self->direct, self->proxy,
46 self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/
47 fclose(f);
48 }
49 else
50 {
51 perror(str);
52 }
53 }
54
55 void write_htmlandlogs(char *html, char *d, int total, int just_preview)
56 {
57 int i;
58 char *str;
59 FILE *f=fopen(html, "w");
60
61 string(str,STRLEN);
62 if(f > 0)
63 {
64 int count=1;
65 i=0;
66
67 if(use_jquery_popups)
68 {
69 fprintf(f,"<script type=\"text/javascript\" src=\"%s\"></script>\n", jquery_url);
70 }
71 fputs("<table class=\"decorated last\">\n\
72 <caption>Bandwidth classes</caption>\n\
73 <thead><tr>\n\
74 <th style=\"text-align: right\">#</th>\n\
75 <th style=\"text-align: right\">group</th>\n\
76 <th style=\"text-align: right\">IPs</th>\n\
77 <th style=\"text-align: right\">requested</th>\n",f);
78 fprintf(f,"<th colspan=\"%d\">data limits</th>\n", keywordcount);
79 fputs("</tr></thead><tbody>\n",f);
80
81 row_odd_even = 0;
82 for_each(group, groups)
83 {
84 #ifdef DEBUG
85 printf("%d kb/s group: %d bandwidth requested: %d kb/s\n",group->min,group->count,group->desired);
86 #endif
87 fprintf(f, "%s<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d&nbsp;kb/s</td>",
88 tr_odd_even(), count, group->min);
89 fprintf(f, "<td style=\"text-align: right\">%d</td><td style=\"text-align: right\">%d&nbsp;kb/s</td>",
90 group->count, group->desired);
91
92 for_each(keyword, keywords) if(keyword->ip_count)
93 {
94 fprintf(f, "<td style=\"text-align: right\"><span style=\"color:#%s\">%d&nbsp;MB</span></td>",
95 keyword->html_color, group->min*keyword->data_limit);
96 }
97 i += group->desired;
98 total += group->count;
99 count++;
100 }
101 #ifdef DEBUG
102 printf("Total groups: %d Total bandwidth requested: %d kb/s\n",
103 count, i, i);
104 #endif
105 fprintf(f,"</tr></tbody>\n\
106 <thead><tr>\n\
107 <th colspan=\"2\" style=\"text-align: left\"></td>");
108 fprintf(f,"<th style=\"text-align: right\">%d</td><th style=\"text-align: right\">%d kb/s</td>",total,i);
109
110 for_each(keyword, keywords) if(keyword->ip_count)
111 {
112 fprintf(f,"<th style=\"text-align: right\">%d IPs</th>",keyword->ip_count);
113 }
114 fprintf(f,"</tr><tr><th colspan=\"4\"></th>\n");
115 fprintf(f,"<th colspan=\"%d\">%d traffic classes</th></tr>\n", keywordcount, total);
116
117 fputs("</thead></table>\n",f);
118 }
119 else
120 {
121 perror(html);
122 }
123
124 i=0;
125 if(f > 0)
126 {
127 unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum = 0;
128 unsigned long long total_pktup = 0, total_pktdown = 0;
129 int active_classes = 0;
130 // int colspan = 14;
131 struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums = NULL;
132 int agreg_count = 0, limit_count = 0, prio_count = 0;
133 int popup_button = 0;
134 /* IPv6 vs. IPv4 stats */
135 unsigned long long pkts4 =0, pkts6 = 0, bytes4 = 0, bytes6 = 0;
136 int count4 = 0, count6 = 0;
137 int mpkts;
138 double perc6;
139
140 /*
141 if(qos_proxy)
142 {
143 colspan++;
144 }
145 */
146 if(use_jquery_popups)
147 {
148 fprintf(f,"<script type=\"text/javascript\">\
149 function show_section(n) {\
150 $(\'#sharing_\'+n).show();\
151 $(\'#download_'+n).show();\
152 $(\'#pktsdown_\'+n).show();\
153 $(\'#upload_'+n).show();\
154 $(\'#pktsup_\'+n).show();\
155 } </script>");
156 }
157
158 fprintf(f,"<p><table class=\"decorated last\">\n<caption>%s",title);
159 fprintf(f," (%s)</caption>\n", d);
160 fputs("<thead><tr>\n<th colspan=\"3\">&nbsp;</th>\n",f);
161 fputs("<th style=\"text-align: right\">cred.</th>\n\
162 <th style=\"text-align: right\">FUP</th>\n\
163 <th style=\"text-align: right\">total</th>\n\
164 <th style=\"text-align: center\" colspan=\"2\">upload</th>\n",f);
165 /*
166 if(qos_proxy)
167 {
168 fputs("<th style=\"text-align: right\">proxy</th>\n",f);
169 }
170 */
171 fputs("<th style=\"text-align: center\" colspan=\"2\">download</th>\n\
172 <th style=\"text-align: right\">min</th>\n\
173 <th style=\"text-align: right\">max</th>\n\
174 <th style=\"text-align: right\">limit</th>\n\
175 <th>&nbsp;</th>\n\
176 </tr><tr>\n\
177 <th style=\"text-align: right\">#</th>\n\
178 <th>hostname [+sharing]</th>\n\
179 <th style=\"text-align: right\">LMS</th>\n\
180 <th style=\"text-align: right\">MB</th>\n\
181 <th style=\"text-align: right\">MB</th>\n\
182 <th style=\"text-align: right\">MB</th>\n\
183 <th style=\"text-align: right\">MB</th>\n\
184 <th style=\"text-align: right\">pkt</th>\n\
185 <th style=\"text-align: right\">MB</th>\n\
186 <th style=\"text-align: right\">pkt</th>\n\
187 <th style=\"text-align: right\">kb/s</th>\n\
188 <th style=\"text-align: right\">kb/s</th>\n\
189 <th style=\"text-align: right\">kb/s</th>\n\
190 <th>!</th>\n\
191 </tr></thead><tbody>\n",f);
192
193 row_odd_even = 0;
194 for_each(ip,ips) if(!use_jquery_popups || !ip->sharing)
195 {
196 char *f1="", *f2="";
197 i++;
198
199 if(ip->aggregated > 1)
200 {
201 f1 = "<span style=\"color:green\">";
202 f2 = "</span>";
203 agreg_count++;
204 }
205 else if(ip->max < ip->desired)
206 {
207 f1 = "<span style=\"color:red\">";
208 f2 = "</span>";
209 limit_count++;
210 }
211 else if(ip->prio > highest_priority+1)
212 {
213 f1 = "<span style=\"color:brown\">";
214 f2 = "</span>";
215 prio_count++;
216 }
217
218 #ifdef DEBUG
219 printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max);
220 #endif
221 /* hostnames -------------------------------------- */
222 fprintf(f,"%s<td style=\"text-align: right\"><a name=\"%s\"></a>%d</td>\
223 <td><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n",
224 tr_odd_even(), ip->name, i, log_url, ip->name, ip->name);
225
226 if(use_jquery_popups)
227 {
228 fprintf(f, "<span id=\"sharing_%d\" style=\"display:none\">",i);
229 popup_button=0;
230
231 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
232 {
233 fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n",
234 log_url, sharedip->name, sharedip->name);
235 popup_button++;
236 }
237
238 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
239 {
240 fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s/%d</a>\n",
241 log_url, sharedip->addr, sharedip->addr, sharedip->mask);
242 popup_button++;
243 }
244
245 fputs("</span>\n",f);
246 if(popup_button)
247 {
248 fprintf(f, "<span>[<a class=\"blue\" href=\"#\" \
249 onClick=\"$(this).parent().hide();show_section(\'%d\');return(false);\" \
250 style=\"cursor: pointer;\">+%d</a>]</span>",
251 i, popup_button);
252 }
253 }
254 fputs("</td>\n",f);
255 /* ----------------------------------------------- */
256
257 if(found_lmsid)
258 {
259 fputs("<td style=\"text-align: right\">",f);
260 if(ip->lmsid > 0)
261 {
262 fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n",
263 lms_url, ip->lmsid, ip->lmsid);
264 }
265 else if(ip->lmsid == 0)
266 {
267 fputs("------",f);
268 }
269 fputs("</td>\n",f);
270 }
271 fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->credit);
272 fprintf(f,"<td style=\"text-align: right\"><span style=\"color:#%s\">%Lu</span></td>",
273 ip->keyword->html_color, ip->realquota);
274 fprintf(f,"<td style=\"text-align: right\">%s%Lu%s</td>", f1, ip->traffic, f2);
275
276 /* upload --------------------------------------- */
277 fprintf(f,"<td style=\"text-align: right\">%Lu", ip->upload);
278 if(use_jquery_popups)
279 {
280 fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">", i);
281 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
282 {
283 fprintf(f,"<br />%Lu", sharedip->upload);
284 }
285 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
286 {
287 fprintf(f,"<br />%Lu", sharedip->upload);
288 }
289 fputs("</span>\n",f);
290 }
291 fputs("</td>\n",f);
292
293 /* pkts up ----------------------------------- */
294 mpkts = ip->pktsup>>20;
295 total_pktup += mpkts;
296 if(mpkts == 0)
297 {
298 mpkts = 1; /* prevent divide by zero*/
299 }
300 fprintf(f,"<td style=\"text-align: right\"><span style=\"color: gray\">%d</span>", ip->upload/mpkts);
301 if(use_jquery_popups)
302 {
303 fprintf(f,"<span id=\"pktsup_%d\" style=\"display:none\">", i);
304 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
305 {
306 mpkts = sharedip->pktsup>>20;
307 if(mpkts == 0)
308 {
309 mpkts = 1; /* prevent divide by zero*/
310 }
311 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->upload/mpkts);
312 }
313 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
314 {
315 mpkts = sharedip->pktsup>>20;
316 if(mpkts == 0)
317 {
318 mpkts = 1; /* prevent divide by zero*/
319 }
320 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->upload/mpkts);
321 }
322 fputs("</span>\n",f);
323 }
324 fputs("</td>\n",f);
325
326 /*
327 if(qos_proxy)
328 {
329 fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->proxy);
330 }
331 */
332 /* download ---------------------------------------- */
333 fprintf(f,"<td style=\"text-align: right\">%Lu", ip->direct);
334 if(use_jquery_popups)
335 {
336 fprintf(f,"<span id=\"download_%d\" style=\"display:none\">", i);
337 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
338 {
339 fprintf(f,"<br />%Lu", sharedip->direct);
340 }
341 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
342 {
343 fprintf(f,"<br />%Lu", sharedip->direct);
344 }
345 fputs("</span>\n",f);
346 }
347 fputs("</td>\n",f);
348
349 /* pkts down ---------------------------------------- */
350 mpkts = ip->pktsdown>>20;
351 total_pktdown += mpkts;
352 if(mpkts == 0)
353 {
354 mpkts = 1; /* prevent divide by zero*/
355 }
356 fprintf(f,"<td style=\"text-align: right\"><span style=\"color: gray\">%d</span>", ip->direct/mpkts);
357 if(use_jquery_popups)
358 {
359 fprintf(f,"<span id=\"pktsdown_%d\" style=\"display:none\">", i);
360 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
361 {
362 mpkts = sharedip->pktsdown>>20;
363 if(mpkts == 0)
364 {
365 mpkts = 1; /* prevent divide by zero*/
366 }
367 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->direct/mpkts);
368 }
369 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
370 {
371 mpkts = sharedip->pktsdown>>20;
372 if(mpkts == 0)
373 {
374 mpkts = 1; /* prevent divide by zero*/
375 }
376 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->direct/mpkts);
377 }
378 fputs("</span>\n",f);
379 }
380 fputs("</td>\n",f);
381 /* ----------------------------------------------- */
382
383 fprintf(f, "<td style=\"text-align: right\">%d</td>\n\
384 <td style=\"text-align: right\">%d</td>\n\
385 <td style=\"text-align: right\">%s%d%s</td>\n\
386 <td>%s%d%s</td></tr>\n",
387 ip->min, ip->desired,
388 f1, ip->max, f2,
389 f1, ip->prio, f2);
390
391 total_traffic+=ip->traffic;
392 total_direct+=ip->direct;
393 total_proxy+=ip->proxy;
394 total_upload+=ip->upload;
395 if(ip->traffic>0)
396 {
397 active_classes++;
398 tmp_sum+=ip->traffic;
399 create(sum,Sum);
400 sum->l=tmp_sum;
401 sum->i=active_classes;
402 insert(sum,sums,order_by,i);
403 }
404
405 if(!just_preview)
406 {
407 append_log(ip);
408 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))
409 {
410 append_log(sharedip);
411 }
412 }
413 }
414 fprintf(f, "</tbody><thead><tr>\n\
415 <th colspan=\"5\" style=\"text-align: left\">%d CLASSES</th>", i);
416 fprintf(f, "<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%Lu</th>\
417 <th style=\"text-align: right\">%d</th>\n",
418 total_traffic, total_upload, total_pktup/i);
419 /*
420 if(qos_proxy)
421 {
422 fprintf(f," <th style=\"text-align: right\">%Lu</th>\n", total_proxy);
423 }
424 */
425 fprintf(f, "<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%d</th>",
426 total_direct, total_pktdown/i);
427 fprintf(f, "<th colspan=\"6\">\
428 <span style=\"color:green\">AGR %dx</span> \
429 <span style=\"color:red\">FUP %dx</span> \
430 <span style=\"color:brown\">PRIO %dx</span></th></tr>\n</thead></table>\n",
431 agreg_count, limit_count, prio_count);
432
433 if(ip6prefix)
434 {
435 for_each(ip, ips)
436 {
437 if(ip->v6)
438 {
439 bytes6 += ip->upload + ip->direct;
440 pkts6 += ip->pktsdown + ip->pktsup;
441 count6++;
442 }
443 else
444 {
445 bytes4 += ip->upload + ip->direct;
446 pkts4 += ip->pktsdown + ip->pktsup;
447 count4++;
448 }
449 }
450
451 perc6=(double)(bytes6)/(bytes4+bytes6)*100;
452 fputs("<p><table class=\"decorated last\"><caption>IP protocols usage</caption>\n",f);
453 fprintf(f, "%s<td>Total %d IPv4 addreses</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",
454 tr_odd_even(), count4, bytes4, (double)(bytes4)/(bytes4+bytes6)*100, pkts4, (float)(100*pkts4)/(pkts4+pkts6));
455 fprintf(f, "%s<td>Total %d IPv6 /64 ranges</td><td style=\"text-align: right\">%Lu MB (%.2f %%)</td><td style=\"text-align: right\">%Lu packets (%.2f %%)</td></tr>\n",
456 tr_odd_even(), count6, bytes6, perc6, pkts6, (float)(100*pkts6)/(pkts4+pkts6));
457 fputs("</table></p>\n", f);
458 }
459
460 row_odd_even = 0;
461 if(active_classes>10)
462 {
463 int top20_count=0,top20_perc1=0;
464 long long top20_perc2=0;
465 unsigned long long top20_sum=0l;
466
467 fputs("<a name=\"erp\"></a><p><table class=\"decorated last\"><caption>Enterprise Resource Planning (ERP)</caption>\n",f);
468 fputs("<thead><tr>\n\
469 <th>Analytic category</th>\n\
470 <th colspan=\"2\" style=\"text-align: center\">Active Classes</th>\n\
471 <th colspan=\"2\" style=\"text-align: center\">Data transfers</th>\n\
472 </tr></thead><tbody>\n",f);
473
474 if_exists(sum,sums,sum->l >= total_traffic/4)
475 {
476 fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());
477 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
478 <td style=\"text-align: right\">%d %%</td>\n\
479 <td style=\"text-align: right\">%Lu MB</td>\n\
480 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
481 sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
482 }
483
484 if_exists(sum,sums,sum->i == 10)
485 {
486 fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());
487 fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\
488 <td style=\"text-align: right\">%d %%</td>\n\
489 <td style=\"text-align: right\">%Lu MB</td>\n\
490 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
491 (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
492 }
493
494 if_exists(sum,sums,sum->l >= total_traffic/2)
495 {
496 fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());
497 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
498 <td style=\"text-align: right\">%d %%</td>\n\
499 <td style=\"text-align: right\">%Lu MB</td>\n\
500 <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",
501 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
502 }
503
504 if_exists(sum,sums,sum->l >= 4*total_traffic/5)
505 {
506 fprintf(f,"%s<td>Top 80%% of traffic</td>\n", tr_odd_even());
507 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
508 <td style=\"text-align: right\">%d %%</td>\n\
509 <td style=\"text-align: right\">%Lu MB</td>\n\
510 <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",
511 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
512 }
513
514 if_exists(sum,sums,sum->i >= (active_classes+1)/5)
515 {
516 fprintf(f,"%s<td>Top 20%% downloaders</td>\n", tr_odd_even());
517 top20_count=sum->i;
518 top20_perc1=(100*sum->i+50)/active_classes;
519 top20_sum=sum->l;
520 top20_perc2=(100*sum->l+50)/total_traffic;
521 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
522 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\
523 <td style=\"text-align: right\">%Lu MB</td>\n\
524 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
525 top20_count,top20_perc1,top20_sum,top20_perc2);
526 }
527
528 if_exists(sum,sums,sum->i >= (active_classes+1)/4)
529 {
530 fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());
531 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
532 <td style=\"text-align: right\">%d %%</td>\n\
533 <td style=\"text-align: right\">%Lu MB</td>\n\
534 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
535 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
536 }
537
538 if_exists(sum,sums,sum->i>=(active_classes+1)/2)
539 {
540 fprintf(f,"%s<td>Top 50%% downloaders</td>\n", tr_odd_even());
541 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
542 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\
543 <td style=\"text-align: right\">%Lu MB</td>\n\
544 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
545 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
546 }
547
548 if_exists(sum,sums,sum->i >= 4*(active_classes+1)/5)
549 {
550 fprintf(f,"%s<td>Top 80%% downloaders</td>\n", tr_odd_even());
551 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
552 <td style=\"text-align: right\">%d %%</td>\n\
553 <td style=\"text-align: right\">%Lu MB</td>\n\
554 <td style=\"text-align: right\">%Ld %%</td></tr></tbody>\n",
555 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
556 }
557
558 fprintf(f,"<thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);
559 fprintf(f,"<th style=\"text-align: right\">%d</th>\n\
560 <th style=\"text-align: right\">100 %%</th>\n\
561 <th style=\"text-align: right\">%Lu MB</th>\n\
562 <th style=\"text-align: right\">100 %%</th></tr>\n",active_classes,total_traffic);
563 fputs("</thead></table></p>\n", f);
564
565 /* write basic ERP data to log directory */
566 if(!just_preview)
567 {
568 FILE *iplog;
569 sprintf(str,"%s/ERP.log",log_dir);
570 iplog=fopen(str,"a");
571 if(iplog)
572 {
573 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\tIPv6 %Lu M\t%.2f %%\t%s",
574 time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2,
575 active_classes, total_traffic, i, limit_count, prio_count,
576 bytes6, perc6, d); /* d = date*/
577 fclose(iplog);
578 }
579 else
580 {
581 perror(str);
582 }
583 }
584 }
585
586 fprintf(f, stats_html_signature, version);
587 fclose(f);
588 }
589 }
This page took 1.195357 seconds and 3 git commands to generate.