3820ae462297c5a5059e84c07fabd8c7e3632ff7
[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 long long int line;
18 extern int dry_run;
19 extern int qos_proxy;
20 extern char *title;
21 extern char *log_url;
22 extern int found_lmsid;
23 extern char *lms_url;
24 extern char *log_dir;
25 extern char *ip6prefix;
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\nAGGREGATION: 1/%d\n",
104 count, i, i/line);
105 #endif
106 fprintf(f,"</tr></tbody>\n\
107 <thead><tr>\n\
108 <th colspan=\"2\" style=\"text-align: left\">Line %Ld kb/s</td>",line);
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\">Aggregation 1/%d</th>\n", (int)(0.5+i/line));
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 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->max < ip->desired)
201 {
202 f1 = "<span style=\"color:red\">";
203 f2 = "</span>";
204 limit_count++;
205 }
206 else if(ip->prio > highest_priority+1)
207 {
208 f1 = "<span style=\"color:brown\">";
209 f2 = "</span>";
210 prio_count++;
211 }
212
213 #ifdef DEBUG
214 printf("%03d. %-22s %10Lu (%d/%d)\n",i ,ip->name, ip->traffic, ip->min, ip->max);
215 #endif
216 /* hostnames -------------------------------------- */
217 fprintf(f,"%s<td style=\"text-align: right\"><a name=\"%s\"></a>%d</td>\
218 <td><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n",
219 tr_odd_even(), ip->name, i, log_url, ip->name, ip->name);
220
221 if(use_jquery_popups)
222 {
223 fprintf(f, "<span id=\"sharing_%d\" style=\"display:none\">",i);
224 popup_button=0;
225
226 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
227 {
228 fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</a>\n",
229 log_url, sharedip->name, sharedip->name);
230 popup_button++;
231 }
232
233 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
234 {
235 fprintf(f, "<br /><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s/%d</a>\n",
236 log_url, sharedip->addr, sharedip->addr, sharedip->mask);
237 popup_button++;
238 }
239
240 fputs("</span>\n",f);
241 if(popup_button)
242 {
243 fprintf(f, "<span>[<a class=\"blue\" href=\"#\" \
244 onClick=\"$(this).parent().hide();show_section(\'%d\');return(false);\" \
245 style=\"cursor: pointer;\">+%d</a>]</span>",
246 i, popup_button);
247 }
248 }
249 fputs("</td>\n",f);
250 /* ----------------------------------------------- */
251
252 if(found_lmsid)
253 {
254 fputs("<td style=\"text-align: right\">",f);
255 if(ip->lmsid > 0)
256 {
257 fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n",
258 lms_url, ip->lmsid, ip->lmsid);
259 }
260 else if(ip->lmsid == 0)
261 {
262 fputs("-------",f);
263 }
264 fputs("</td>\n",f);
265 }
266 fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->credit);
267 fprintf(f,"<td style=\"text-align: right\"><span style=\"color:#%s\">%Lu</span></td>",
268 ip->keyword->html_color, ip->realquota);
269 fprintf(f,"<td style=\"text-align: right\">%s%Lu%s</td>", f1, ip->traffic, f2);
270
271 /* upload --------------------------------------- */
272 fprintf(f,"<td style=\"text-align: right\">%Lu", ip->upload);
273 if(use_jquery_popups)
274 {
275 fprintf(f,"<span id=\"upload_%d\" style=\"display:none\">", i);
276 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
277 {
278 fprintf(f,"<br />%Lu", sharedip->upload);
279 }
280 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
281 {
282 fprintf(f,"<br />%Lu", sharedip->upload);
283 }
284 fputs("</span>\n",f);
285 }
286 fputs("</td>\n",f);
287
288 /* pkts up ----------------------------------- */
289 mpkts = ip->pktsup>>20;
290 total_pktup += mpkts;
291 if(mpkts == 0)
292 {
293 mpkts = 1; /* prevent divide by zero*/
294 }
295 fprintf(f,"<td style=\"text-align: right\"><span style=\"color: gray\">%d</span>", ip->upload/mpkts);
296 if(use_jquery_popups)
297 {
298 fprintf(f,"<span id=\"pktsup_%d\" style=\"display:none\">", i);
299 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
300 {
301 mpkts = sharedip->pktsup>>20;
302 if(mpkts == 0)
303 {
304 mpkts = 1; /* prevent divide by zero*/
305 }
306 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->upload/mpkts);
307 }
308 for_each(sharedip, ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
309 {
310 mpkts = sharedip->pktsup>>20;
311 if(mpkts == 0)
312 {
313 mpkts = 1; /* prevent divide by zero*/
314 }
315 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->upload/mpkts);
316 }
317 fputs("</span>\n",f);
318 }
319 fputs("</td>\n",f);
320
321 /*
322 if(qos_proxy)
323 {
324 fprintf(f,"<td style=\"text-align: right\">%Lu</td>\n", ip->proxy);
325 }
326 */
327 /* download ---------------------------------------- */
328 fprintf(f,"<td style=\"text-align: right\">%Lu", ip->direct);
329 if(use_jquery_popups)
330 {
331 fprintf(f,"<span id=\"download_%d\" style=\"display:none\">", i);
332 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
333 {
334 fprintf(f,"<br />%Lu", sharedip->direct);
335 }
336 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
337 {
338 fprintf(f,"<br />%Lu", sharedip->direct);
339 }
340 fputs("</span>\n",f);
341 }
342 fputs("</td>\n",f);
343
344 /* pkts down ---------------------------------------- */
345 mpkts = ip->pktsdown>>20;
346 total_pktdown += mpkts;
347 if(mpkts == 0)
348 {
349 mpkts = 1; /* prevent divide by zero*/
350 }
351 fprintf(f,"<td style=\"text-align: right\"><span style=\"color: gray\">%d</span>", ip->direct/mpkts);
352 if(use_jquery_popups)
353 {
354 fprintf(f,"<span id=\"pktsdown_%d\" style=\"display:none\">", i);
355 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && !sharedip->v6) /* IPv4 only */
356 {
357 mpkts = sharedip->pktsdown>>20;
358 if(mpkts == 0)
359 {
360 mpkts = 1; /* prevent divide by zero*/
361 }
362 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->direct/mpkts);
363 }
364 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing) && sharedip->v6) /* IPv6 only */
365 {
366 mpkts = sharedip->pktsdown>>20;
367 if(mpkts == 0)
368 {
369 mpkts = 1; /* prevent divide by zero*/
370 }
371 fprintf(f,"<br /><span style=\"color: gray\">%d</span>", sharedip->direct/mpkts);
372 }
373 fputs("</span>\n",f);
374 }
375 fputs("</td>\n",f);
376 /* ----------------------------------------------- */
377
378 fprintf(f, "<td style=\"text-align: right\">%d</td>\n\
379 <td style=\"text-align: right\">%d</td>\n\
380 <td style=\"text-align: right\">%s%d%s</td>\n\
381 <td>%s%d%s</td></tr>\n",
382 ip->min, ip->desired,
383 f1, ip->max, f2,
384 f1, ip->prio, f2);
385
386 total_traffic+=ip->traffic;
387 total_direct+=ip->direct;
388 total_proxy+=ip->proxy;
389 total_upload+=ip->upload;
390 if(ip->traffic>0)
391 {
392 active_classes++;
393 tmp_sum+=ip->traffic;
394 create(sum,Sum);
395 sum->l=tmp_sum;
396 sum->i=active_classes;
397 insert(sum,sums,order_by,i);
398 }
399
400 if(!just_preview)
401 {
402 append_log(ip);
403 for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))
404 {
405 append_log(sharedip);
406 }
407 }
408 }
409 fprintf(f, "</tbody><thead><tr>\n\
410 <th colspan=\"5\" style=\"text-align: left\">%d CLASSES</th>", i);
411 fprintf(f, "<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%Lu</th>\
412 <th style=\"text-align: right\">%d</th>\n",
413 total_traffic, total_upload, total_pktup/i);
414 /*
415 if(qos_proxy)
416 {
417 fprintf(f," <th style=\"text-align: right\">%Lu</th>\n", total_proxy);
418 }
419 */
420 fprintf(f, "<th style=\"text-align: right\">%Lu</th><th style=\"text-align: right\">%d</th>",
421 total_direct, total_pktdown/i);
422 fprintf(f, "<th colspan=\"6\"><span style=\"color:red\">LIMIT %dx</span> \
423 <span style=\"color:brown\">LOW-PRIO %dx</span></th></tr>\n</thead></table>\n",
424 limit_count, prio_count);
425
426 if(ip6prefix)
427 {
428 for_each(ip, ips)
429 {
430 if(ip->v6)
431 {
432 bytes6 += ip->upload + ip->direct;
433 pkts6 += ip->pktsdown + ip->pktsup;
434 count6++;
435 }
436 else
437 {
438 bytes4 += ip->upload + ip->direct;
439 pkts4 += ip->pktsdown + ip->pktsup;
440 count4++;
441 }
442 }
443
444 perc6=(double)(bytes6)/(bytes4+bytes6)*100;
445 fputs("<p><table class=\"decorated last\"><caption>IP protocols usage</caption>\n",f);
446 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",
447 tr_odd_even(), count4, bytes4, (double)(bytes4)/(bytes4+bytes6)*100, pkts4, (float)(100*pkts4)/(pkts4+pkts6));
448 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",
449 tr_odd_even(), count6, bytes6, perc6, pkts6, (float)(100*pkts6)/(pkts4+pkts6));
450 fputs("</table></p>\n", f);
451 }
452
453 row_odd_even = 0;
454 if(active_classes>10)
455 {
456 int top20_count=0,top20_perc1=0;
457 long long top20_perc2=0;
458 unsigned long long top20_sum=0l;
459
460 fputs("<a name=\"erp\"></a><p><table class=\"decorated last\"><caption>Enterprise Resource Planning (ERP)</caption>\n",f);
461 fputs("<thead><tr>\n\
462 <th>Analytic category</th>\n\
463 <th colspan=\"2\" style=\"text-align: center\">Active Classes</th>\n\
464 <th colspan=\"2\" style=\"text-align: center\">Data transfers</th>\n\
465 </tr></thead><tbody>\n",f);
466
467 if_exists(sum,sums,sum->l >= total_traffic/4)
468 {
469 fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());
470 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
471 <td style=\"text-align: right\">%d %%</td>\n\
472 <td style=\"text-align: right\">%Lu MB</td>\n\
473 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
474 sum->i, (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
475 }
476
477 if_exists(sum,sums,sum->i == 10)
478 {
479 fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());
480 fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\
481 <td style=\"text-align: right\">%d %%</td>\n\
482 <td style=\"text-align: right\">%Lu MB</td>\n\
483 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
484 (100*sum->i+50)/active_classes, sum->l, (100*sum->l+50)/total_traffic);
485 }
486
487 if_exists(sum,sums,sum->l >= total_traffic/2)
488 {
489 fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());
490 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
491 <td style=\"text-align: right\">%d %%</td>\n\
492 <td style=\"text-align: right\">%Lu MB</td>\n\
493 <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",
494 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
495 }
496
497 if_exists(sum,sums,sum->l >= 4*total_traffic/5)
498 {
499 fprintf(f,"%s<td>Top 80%% of traffic</td>\n", tr_odd_even());
500 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
501 <td style=\"text-align: right\">%d %%</td>\n\
502 <td style=\"text-align: right\">%Lu MB</td>\n\
503 <td style=\"text-align: right\"><strong>%Ld %%</strong></td></tr>\n",
504 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
505 }
506
507 if_exists(sum,sums,sum->i >= (active_classes+1)/5)
508 {
509 fprintf(f,"%s<td>Top 20%% downloaders</td>\n", tr_odd_even());
510 top20_count=sum->i;
511 top20_perc1=(100*sum->i+50)/active_classes;
512 top20_sum=sum->l;
513 top20_perc2=(100*sum->l+50)/total_traffic;
514 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
515 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\
516 <td style=\"text-align: right\">%Lu MB</td>\n\
517 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
518 top20_count,top20_perc1,top20_sum,top20_perc2);
519 }
520
521 if_exists(sum,sums,sum->i >= (active_classes+1)/4)
522 {
523 fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());
524 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
525 <td style=\"text-align: right\">%d %%</td>\n\
526 <td style=\"text-align: right\">%Lu MB</td>\n\
527 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
528 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
529 }
530
531 if_exists(sum,sums,sum->i>=(active_classes+1)/2)
532 {
533 fprintf(f,"%s<td>Top 50%% downloaders</td>\n", tr_odd_even());
534 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
535 <td style=\"text-align: right\"><strong>%d %%</strong></td>\n\
536 <td style=\"text-align: right\">%Lu MB</td>\n\
537 <td style=\"text-align: right\">%Ld %%</td></tr>\n",
538 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
539 }
540
541 if_exists(sum,sums,sum->i >= 4*(active_classes+1)/5)
542 {
543 fprintf(f,"%s<td>Top 80%% downloaders</td>\n", tr_odd_even());
544 fprintf(f,"<td style=\"text-align: right\">%d</td>\n\
545 <td style=\"text-align: right\">%d %%</td>\n\
546 <td style=\"text-align: right\">%Lu MB</td>\n\
547 <td style=\"text-align: right\">%Ld %%</td></tr></tbody>\n",
548 sum->i,(100*sum->i+50)/active_classes,sum->l,(100*sum->l+50)/total_traffic);
549 }
550
551 fprintf(f,"<thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);
552 fprintf(f,"<th style=\"text-align: right\">%d</th>\n\
553 <th style=\"text-align: right\">100 %%</th>\n\
554 <th style=\"text-align: right\">%Lu MB</th>\n\
555 <th style=\"text-align: right\">100 %%</th></tr>\n",active_classes,total_traffic);
556 fputs("</thead></table></p>\n", f);
557
558 /* write basic ERP data to log directory */
559 if(!just_preview)
560 {
561 FILE *iplog;
562 sprintf(str,"%s/ERP.log",log_dir);
563 iplog=fopen(str,"a");
564 if(iplog)
565 {
566 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",
567 time(NULL), top20_count, top20_perc1, top20_sum, top20_perc2,
568 active_classes, total_traffic, i, limit_count, prio_count,
569 bytes6, perc6, d); /* d = date*/
570 fclose(iplog);
571 }
572 else
573 {
574 perror(str);
575 }
576 }
577 }
578
579 fprintf(f, stats_html_signature, version);
580 fclose(f);
581 }
582 }
This page took 0.670768 seconds and 3 git commands to generate.