char *name;\r
long traffic;\r
long guaranted;\r
+ long avg;\r
+ time_t logged_time;\r
int i;\r
int lmsid;\r
long l;\r
long traffic=0l, traffic_month, total=0, guaranted;\r
int col, col2, y_ok, m_ok, accept_month, i=1, any_month=0, lmsid;\r
char mstr[4], ystr[5];\r
+ long log_timestamp, log_started = 0, log_ended = 0;\r
FILE *f; \r
string(str,STRLEN);\r
string(filename,STRLEN);\r
/* sorry... next release of C<<1 header file will include for_path_files(name,path) { } macro */\r
sprintf(str,"%s %s/",ls,log_dir);\r
shell(str);\r
+ /* for_each(file, str, dir, log_dir) */\r
input(str,STRLEN) \r
{\r
if(strstr(str,".log"))\r
{\r
ptr=strrchr(str,'\n');\r
if(ptr) *ptr='\0';\r
- sprintf(filename,"%s/%s",log_dir,str);\r
- printf("Parsing %s ...",filename);\r
+ sprintf(filename,"%s/%s", log_dir,str);\r
+ printf("Parsing %s ...", filename);\r
accept_month=0;\r
traffic_month=0;\r
guaranted=0;\r
y_ok=m_ok=0; \r
valid_columns(ptr,_,'\t',col) switch(col)\r
{\r
+ case 1: log_timestamp = atol(ptr); break;\r
case 2: name = ptr;break;\r
case 3: traffic = atol(ptr);break;\r
/* column number - was 7, now 11...*/\r
if(y_ok && m_ok) \r
{\r
traffic_month += traffic;\r
+ if(log_started == 0)\r
+ {\r
+ log_started = log_timestamp;\r
+ }\r
accept_month = 1;\r
}\r
+ else if (log_started != 0 && log_ended == 0)\r
+ {\r
+ log_ended = log_timestamp;\r
+ }\r
}\r
done; /* ugly macro end */ \r
\r
if(accept_month)\r
{\r
+ if(log_ended == 0)\r
+ {\r
+ log_ended = time(NULL);\r
+ }\r
+ \r
create(iplog,IpLog);\r
iplog->name = name;\r
iplog->guaranted = guaranted;\r
- iplog->traffic = traffic_month;\r
+ iplog->avg = traffic_month * 8 / (log_ended - log_started); /* Mbps */\r
+ iplog->logged_time = (log_ended - log_started);\r
+ iplog->traffic = traffic_month; /* MB */\r
iplog->lmsid = lmsid;\r
insert(iplog,iplogs,desc_order_by,traffic);\r
printf(" %ld MB\n",iplog->traffic);\r
f=fopen(str,"w");\r
if(f > 0)\r
{\r
+ time_t max_logged_time = 0;\r
+\r
fprintf(f, "<table class=\"decorated last\"><thead>\n\\r
<tr><th colspan=\"2\">%s %s</th>\n\\r
<th style=\"text-align: right\">lms</th>\n\\r
<th colspan=\"2\">Data transfers</th>\n\\r
<th style=\"text-align: right\">Min.speed</th>\n\\r
+<th style=\"text-align: right\">Avg.speed</th>\n\\r
</tr></thead><tbody>\n ",\r
month, year);\r
\r
row_odd_even = 0;\r
for_each(iplog, iplogs)\r
{\r
+ if(iplog->logged_time > max_logged_time)\r
+ {\r
+ max_logged_time = iplog->logged_time;\r
+ }\r
+\r
if(iplog->traffic)\r
{\r
fprintf(f, "%s<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: left\"><a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</td>\n\\r
+<td style=\"text-align: left\">\\r
+<a class=\"blue\" target=\"_blank\" href=\"%s%s.log\">%s</td>\n\\r
<td style=\"text-align: right\">", \r
tr_odd_even(), i++, log_url, iplog->name, iplog->name); \r
+\r
if(iplog->lmsid > 0)\r
{\r
/*base URL will be configurable soon ... */\r
}\r
else if(iplog->lmsid == 0)\r
{\r
- fputs("-------",f);\r
+ fputs("------",f);\r
} \r
fprintf(f, "<td style=\"text-align: right\">%ld MB</td>\n\\r
- <td style=\"text-align: right\"><strong>%ld GB</strong></td>\n\\r
- <td style=\"text-align: right\">%ld kb/s</th></tr>\n",\r
- iplog->traffic, iplog->traffic>>10, iplog->guaranted);\r
+<td style=\"text-align: right\"><strong>%ld GB</strong></td>\n\\r
+<td style=\"text-align: right\">%ld kb/s</th>\\r
+<td style=\"text-align: right\">%ld Mb/s</th>\\r
+</tr>\n",\r
+ iplog->traffic, iplog->traffic>>10, iplog->guaranted, iplog->avg);\r
total+=iplog->traffic>>10;\r
iplog->i=i;\r
iplog->l=total;\r
}\r
}\r
fprintf(f,"</tbody><thead><tr>\\r
- <th colspan=\"3\" style=\"text-align: left\">Total:</th>\\r
- <th colspan=\"2\" style=\"text-align: right\"><strong>%ld GB</strong></th>\\r
- <th style=\"text-align: right\"><strong>%Ld kb/s</strong></th></tr>\n", total, line);\r
+<th colspan=\"3\" style=\"text-align: left\">Total:</th>\\r
+<th colspan=\"2\" style=\"text-align: right\"><strong>%ld GB</strong></th>\\r
+<th style=\"text-align: right\"><strong>%Ld kb/s</strong></th>\\r
+<th style=\"text-align: right\"><strong>%Ld kb/s</strong></th></tr>\\r
+\n", total, line, (8*(total<<20))/max_logged_time/i);\r
fputs("</thead></table>\n", f);\r
\r
row_odd_even = 0;\r
/* Prometheus QoS - you can "steal fire" from your ISP */\r
/* "fair-per-IP" quality of service (QoS) utility */\r
/* requires Linux 2.4.x or 2.6.x with HTB support */\r
-/* Copyright(C) 2005-2014 Michael Polak, Arachne Aerospace */\r
+/* Copyright(C) 2005-2015 Michael Polak, Arachne Aerospace */\r
/* iptables-restore support Copyright(C) 2007-2008 ludva */\r
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-/* Modified by: xChaos, 20140812\r
+/* Modified by: xChaos, 20150315\r
ludva, 20080415\r
\r
Prometheus QoS is free software; you can redistribute it and/or\r
#include "cll1-0.6.2.h"\r
#include "ipstruct.h"\r
\r
-const char *version = "0.8.5-b";\r
+const char *version = "0.8.5-c";\r
\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
/* Versions: 0.8.3 is development release, 0.8.4 will be "stable" */\r
/* Warning: unofficial Github mirror is not supported by author! */\r
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */\r
\r
-const char *stats_html_signature = "<span class=\"small\">Statistics generated by Prometheus QoS version %s<br />GPL+Copyright(C)2005-2014 Michael Polak, <a target=\"_blank\" href=\"http://www.arachne.cz/\">Arachne Labs</a></span>\n";\r
+const char *stats_html_signature = "<span class=\"small\">Statistics generated by Prometheus QoS version %s<br />GPL+Copyright(C)2005-2015 Michael Polak, <a target=\"_blank\" href=\"http://www.arachne.cz/\">Arachne Labs</a></span>\n";\r
\r
#define STRLEN 512\r
#undef DEBUG\r
\r
printf("\n\\r
Prometheus QoS - \"fair-per-IP\" Quality of Service setup utility.\n\\r
-Version %s - Copyright (C)2005-2014 Michael Polak, Arachne Labs\n\\r
+Version %s - Copyright (C)2005-2015 Michael Polak, Arachne Labs\n\\r
iptables-restore & burst tunning & classify modification by Ludva\n\\r
Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);\r
\r