sysconfdir=/etc
main: prometheus
- $(CC) -o prometheus prometheus.c
+ $(CC) -o prometheus parselog.c prometheus.c
deb: main
debian/prometheus.debian
--- /dev/null
+#include "cll1-0.6.2.h"\r
+#define STRLEN 512\r
+\r
+extern char *log_dir;\r
+extern const char *version;\r
+extern const char *stats_html_signature;\r
+extern const char *ls;\r
+extern char *html_log_dir;\r
+extern int row_odd_even;\r
+extern char *log_url;\r
+extern char *lms_url;\r
+extern long long int line;\r
+\r
+const char *tr_odd_even(void);\r
+/* implemented in prometheus.c */\r
+\r
+struct IpLog\r
+{\r
+ char *name;\r
+ long traffic;\r
+ long guaranted;\r
+ int i;\r
+ int lmsid;\r
+ long l;\r
+ list(IpLog);\r
+} *iplog,*iplogs;\r
+\r
+void parse_ip_log(int argc, char **argv) \r
+{\r
+ char *month, *year, *str, *name="(undefined)", *ptr, *ptr2, *filename;\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
+ FILE *f; \r
+ string(str,STRLEN);\r
+ string(filename,STRLEN);\r
+\r
+ if(argv[1][1]=='l') /* -l */\r
+ {\r
+ if(argc<4)\r
+ {\r
+ puts("Missing parameter(s)!\nUsage: prometheus -l Mmm YYYY (Mmm=Jan-Dec or Year, YYYY=year)");\r
+ exit(-1);\r
+ }\r
+ else\r
+ {\r
+ month=argv[2];\r
+ if(eq(month,"Year")) any_month=1;\r
+ year=argv[3];\r
+ }\r
+ }\r
+ else\r
+ { \r
+ time_t t = time(NULL) - 3600*24 ; /* yesterday's timestamp*/\r
+ struct tm *timep = localtime(&t); \r
+\r
+ if(argv[1][1]=='m') /* -m yestarday - month */\r
+ {\r
+ strftime(mstr, 4, "%b", timep);\r
+ month=mstr;\r
+ strftime(ystr, 5, "%Y", timep);\r
+ year=ystr; \r
+ }\r
+ else /* -y yesterday - year */\r
+ {\r
+ month="Year";\r
+ any_month=1;\r
+ strftime(ystr, 5, "%Y", timep);\r
+ year=ystr;\r
+ }\r
+ }\r
+ printf("Analysing traffic for %s %s ...\n",month,year);\r
+\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
+ 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
+ accept_month=0;\r
+ traffic_month=0;\r
+ guaranted=0;\r
+ lmsid=-1;\r
+ parse(filename)\r
+ {\r
+ y_ok=m_ok=0; \r
+ valid_columns(ptr,_,'\t',col) switch(col)\r
+ {\r
+ case 2: name = ptr;break;\r
+ case 3: traffic = atol(ptr);break;\r
+ /* column number - was 7, now 11...*/\r
+ case 7:\r
+ case 8:\r
+ case 9:\r
+ case 10:\r
+ case 11: if(isalpha(*ptr)) /* character, not numeric string = date, just one*/\r
+ {\r
+ valid_columns(ptr2,ptr,' ',col2) switch(col2)\r
+ {\r
+ case 2: if(any_month || eq(ptr2,month)) m_ok = 1; break;\r
+ case 5: if(eq(ptr2,year)) y_ok = 1; break;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(col == 7) guaranted = atol(ptr);\r
+ if(col == 10) lmsid = atoi(ptr);\r
+ }\r
+ }\r
+ \r
+ if(y_ok && m_ok) \r
+ {\r
+ traffic_month += traffic;\r
+ accept_month = 1;\r
+ }\r
+ }\r
+ done; /* ugly macro end */ \r
+\r
+ if(accept_month)\r
+ {\r
+ create(iplog,IpLog);\r
+ iplog->name = name;\r
+ iplog->guaranted = guaranted;\r
+ iplog->traffic = traffic_month;\r
+ iplog->lmsid = lmsid;\r
+ insert(iplog,iplogs,desc_order_by,traffic);\r
+ printf(" %ld MB\n",iplog->traffic);\r
+ }\r
+ else\r
+ {\r
+ puts(" no records.");\r
+ }\r
+ }\r
+ }\r
+ sprintf(str,"%s/%s-%s.html",html_log_dir,year,month);\r
+ printf("Writing %s ... ",str);\r
+ f=fopen(str,"w");\r
+ if(f > 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
+</tr></thead><tbody>\n ",\r
+ month, year);\r
+\r
+ row_odd_even = 0;\r
+ for_each(iplog, iplogs)\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: right\">", \r
+ tr_odd_even(), i++, log_url, iplog->name, iplog->name); \r
+ if(iplog->lmsid > 0)\r
+ {\r
+ /*base URL will be configurable soon ... */\r
+ fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n", lms_url, iplog->lmsid, iplog->lmsid);\r
+ }\r
+ else if(iplog->lmsid == 0)\r
+ {\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
+ 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
+ fputs("</thead></table>\n", f);\r
+\r
+ row_odd_even = 0;\r
+ if(i>10)\r
+ {\r
+ fputs("<a name=\"erp\"></a><p><table class=\"decorated last\">\n\\r
+<caption>Enterprise Resource Planning (ERP)</caption>\n\\r
+<thead><tr>\n\\r
+<th>Analytic category</th>\n\\r
+<th colspan=\"2\" style=\"text-align: center\">Active Classes</th>\n\\r
+<th colspan=\"2\" style=\"text-align: center\">Data transfers</th>\n\\r
+</tr></thead><tbody>\n",f);\r
+\r
+ if_exists(iplog,iplogs,iplog->l>=total/4)\r
+ {\r
+ fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+ \r
+ if_exists(iplog,iplogs,iplog->i==10)\r
+ {\r
+ fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists(iplog,iplogs,iplog->l>=total/2)\r
+ {\r
+ fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
+ iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists(iplog,iplogs,iplog->l>=4*total/5)\r
+ {\r
+ fprintf(f,"%s<td>Top 80%% of traffic</td>\n",tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists (iplog,iplogs,iplog->i>=i/5)\r
+ {\r
+ fprintf(f,"%s<td>Top 20%% downloaders</td>\n",tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists(iplog,iplogs,iplog->i>=i/4)\r
+ {\r
+ fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists(iplog,iplogs,iplog->i>=i/2)\r
+ {\r
+ fprintf(f,"%s<td>Top 50%% downloaders</td>\n",tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ if_exists(iplog,iplogs,iplog->i>=4*i/5)\r
+ {\r
+ fprintf(f,"%s<td>Top 80%% downloaders</td>\n",tr_odd_even());\r
+ fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
+<td style=\"text-align: right\">%d %%</td>\n\\r
+<td style=\"text-align: right\">%ld GB</td>\n\\r
+<td style=\"text-align: right\">%d %%</td></tr>\n",\r
+ iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
+ }\r
+\r
+ fprintf(f,"</tbody><thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);\r
+ fprintf(f,"<th style=\"text-align: right\">%d</th>\n\\r
+<th style=\"text-align: right\">100 %%</th>\n\\r
+<th style=\"text-align: right\">%ld GB</th>\n\\r
+<th style=\"text-align: right\">100 %%</th></tr>\n",i-1,total);\r
+ fputs("</thead></table>\n", f);\r
+ }\r
+\r
+ fprintf(f, stats_html_signature, version);\r
+ fclose(f);\r
+ puts("done.");\r
+ }\r
+ else\r
+ {\r
+ perror(str);\r
+ }\r
+}\r
\r
GNU General Public License is located in file COPYING */\r
\r
-#define STRLEN 256\r
+#define STRLEN 512\r
#define FIRSTGROUPID 1024\r
#define FIRSTIPCLASS 2048\r
#undef DEBUG\r
int row_odd_even = 0; /*<tr class="odd/even"> */\r
\r
\r
+void parse_ip_log(int argc, char **argv);\r
+/* implementid in parselog.c */\r
+\r
const char *tr_odd_even(void)\r
{\r
row_odd_even = 1 - row_odd_even;\r
}\r
}\r
\r
-struct IpLog\r
-{\r
- char *name;\r
- long traffic;\r
- long guaranted;\r
- int i;\r
- int lmsid;\r
- long l;\r
- list(IpLog);\r
-} *iplog,*iplogs;\r
-\r
-void parse_ip_log(int argc, char **argv) \r
-{\r
- char *month, *year, *str, *name="(undefined)", *ptr, *ptr2, *filename;\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
- FILE *f; \r
- string(str,STRLEN);\r
- string(filename,STRLEN);\r
-\r
- if(argv[1][1]=='l') /* -l */\r
- {\r
- if(argc<4)\r
- {\r
- puts("Missing parameter(s)!\nUsage: prometheus -l Mmm YYYY (Mmm=Jan-Dec or Year, YYYY=year)");\r
- exit(-1);\r
- }\r
- else\r
- {\r
- month=argv[2];\r
- if(eq(month,"Year")) any_month=1;\r
- year=argv[3];\r
- }\r
- }\r
- else\r
- { \r
- time_t t = time(NULL) - 3600*24 ; /* yesterday's timestamp*/\r
- struct tm *timep = localtime(&t); \r
-\r
- if(argv[1][1]=='m') /* -m yestarday - month */\r
- {\r
- strftime(mstr, 4, "%b", timep);\r
- month=mstr;\r
- strftime(ystr, 5, "%Y", timep);\r
- year=ystr; \r
- }\r
- else /* -y yesterday - year */\r
- {\r
- month="Year";\r
- any_month=1;\r
- strftime(ystr, 5, "%Y", timep);\r
- year=ystr;\r
- }\r
- }\r
- printf("Analysing traffic for %s %s ...\n",month,year);\r
-\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
- 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
- accept_month=0;\r
- traffic_month=0;\r
- guaranted=0;\r
- lmsid=-1;\r
- parse(filename)\r
- {\r
- y_ok=m_ok=0; \r
- valid_columns(ptr,_,'\t',col) switch(col)\r
- {\r
- case 2: name = ptr;break;\r
- case 3: traffic = atol(ptr);break;\r
- /* column number - was 7, now 11...*/\r
- case 7:\r
- case 8:\r
- case 9:\r
- case 10:\r
- case 11: if(isalpha(*ptr)) /* character, not numeric string = date, just one*/\r
- {\r
- valid_columns(ptr2,ptr,' ',col2) switch(col2)\r
- {\r
- case 2: if(any_month || eq(ptr2,month)) m_ok = 1; break;\r
- case 5: if(eq(ptr2,year)) y_ok = 1; break;\r
- }\r
- }\r
- else\r
- {\r
- if(col == 7) guaranted = atol(ptr);\r
- if(col == 10) lmsid = atoi(ptr);\r
- }\r
- }\r
- \r
- if(y_ok && m_ok) \r
- {\r
- traffic_month += traffic;\r
- accept_month = 1;\r
- }\r
- }\r
- done; /* ugly macro end */ \r
-\r
- if(accept_month)\r
- {\r
- create(iplog,IpLog);\r
- iplog->name = name;\r
- iplog->guaranted = guaranted;\r
- iplog->traffic = traffic_month;\r
- iplog->lmsid = lmsid;\r
- insert(iplog,iplogs,desc_order_by,traffic);\r
- printf(" %ld MB\n",iplog->traffic);\r
- }\r
- else\r
- {\r
- puts(" no records.");\r
- }\r
- }\r
- }\r
- sprintf(str,"%s/%s-%s.html",html_log_dir,year,month);\r
- printf("Writing %s ... ",str);\r
- f=fopen(str,"w");\r
- if(f > 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
-</tr></thead><tbody>\n ",\r
- month, year);\r
\r
- row_odd_even = 0;\r
- for_each(iplog, iplogs)\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: right\">", \r
- tr_odd_even(), i++, log_url, iplog->name, iplog->name); \r
- if(iplog->lmsid > 0)\r
- {\r
- /*base URL will be configurable soon ... */\r
- fprintf(f, "<a class=\"blue\" target=\"_blank\" href=\"%s%d\">%04d</a>\n", lms_url, iplog->lmsid, iplog->lmsid);\r
- }\r
- else if(iplog->lmsid == 0)\r
- {\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
- 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
- fputs("</thead></table>\n", f);\r
\r
- row_odd_even = 0;\r
- if(i>10)\r
- {\r
- fputs("<a name=\"erp\"></a><p><table class=\"decorated last\">\n\\r
-<caption>Enterprise Resource Planning (ERP)</caption>\n\\r
-<thead><tr>\n\\r
-<th>Analytic category</th>\n\\r
-<th colspan=\"2\" style=\"text-align: center\">Active Classes</th>\n\\r
-<th colspan=\"2\" style=\"text-align: center\">Data transfers</th>\n\\r
-</tr></thead><tbody>\n",f);\r
-\r
- if_exists(iplog,iplogs,iplog->l>=total/4)\r
- {\r
- fprintf(f,"%s<td>Top 25%% of traffic</td>\n", tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
- \r
- if_exists(iplog,iplogs,iplog->i==10)\r
- {\r
- fprintf(f,"%s<td>Top 10 downloaders</td>\n", tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\"><strong>10</strong></td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists(iplog,iplogs,iplog->l>=total/2)\r
- {\r
- fprintf(f,"%s<td>Top 50%% of traffic</td>\n", tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
- iplog->i,(100*iplog->i+50)/i,iplog->l,(int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists(iplog,iplogs,iplog->l>=4*total/5)\r
- {\r
- fprintf(f,"%s<td>Top 80%% of traffic</td>\n",tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\"><strong>%d %%</strong></td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists (iplog,iplogs,iplog->i>=i/5)\r
- {\r
- fprintf(f,"%s<td>Top 20%% downloaders</td>\n",tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists(iplog,iplogs,iplog->i>=i/4)\r
- {\r
- fprintf(f,"%s<td>Top 25%% downloaders</td>\n", tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists(iplog,iplogs,iplog->i>=i/2)\r
- {\r
- fprintf(f,"%s<td>Top 50%% downloaders</td>\n",tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\"><strong>%d %%</strong></td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- if_exists(iplog,iplogs,iplog->i>=4*i/5)\r
- {\r
- fprintf(f,"%s<td>Top 80%% downloaders</td>\n",tr_odd_even());\r
- fprintf(f,"<td style=\"text-align: right\">%d</td>\n\\r
-<td style=\"text-align: right\">%d %%</td>\n\\r
-<td style=\"text-align: right\">%ld GB</td>\n\\r
-<td style=\"text-align: right\">%d %%</td></tr>\n",\r
- iplog->i, (100*iplog->i+50)/i, iplog->l, (int)((100*iplog->l+50)/total));\r
- }\r
-\r
- fprintf(f,"</tbody><thead><tr><th><a class=\"blue\" target=\"_blank\" href=\"%sERP.log\">All users, all traffic</a></th>\n", log_url);\r
- fprintf(f,"<th style=\"text-align: right\">%d</th>\n\\r
-<th style=\"text-align: right\">100 %%</th>\n\\r
-<th style=\"text-align: right\">%ld GB</th>\n\\r
-<th style=\"text-align: right\">100 %%</th></tr>\n",i-1,total);\r
- fputs("</thead></table>\n", f);\r
- }\r
-\r
- fprintf(f, stats_html_signature, version);\r
- fclose(f);\r
- puts("done.");\r
- }\r
- else\r
- {\r
- perror(str);\r
- }\r
-}\r
\r
void append_log(struct IP *self) /*using global variables*/\r
{\r