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