}\r
}\r
sprintf(str,"%s/%s-%s.html",html_log_dir,year,month);\r
- printf("Writing %s ...",str);\r
+ printf("Writing %s ... ",str);\r
f=fopen(str,"w");\r
if(f)\r
{\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
+ char *d, *str;\r
+ FILE *f; \r
+\r
+ date(d); /* this is typical cll1.h macro - prints current date */ \r
+ string(str,STRLEN); \r
+ sprintf(str,"%s/%s.log", log_dir, self->name);\r
+ f=fopen(str,"a");\r
+ if(f)\r
+ {\r
+ fprintf(f,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",\r
+ time(NULL), self->name, self->traffic, self->direct, self->proxy,\r
+ self->upload, self->min, self->max, self->desired, self->lmsid, d); /* d = date*/\r
+ fclose(f);\r
+ }\r
+ else\r
+ {\r
+ perror(str);\r
+ }\r
}\r
\r
+\r
/*-----------------------------------------------------------------*/\r
/* Are you looking for int main(int argc, char **argv) ? :-)) */\r
/*-----------------------------------------------------------------*/\r
if(just_flush)\r
{\r
fclose(iptables_file);\r
- if(log_file) fclose(log_file);\r
+ if(log_file)\r
+ { \r
+ fclose(log_file);\r
+ }\r
puts("Just flushed iptables and tc classes - now exiting ...");\r
exit(0);\r
}\r
}\r
else if(!dry_run && !just_flush)\r
{\r
+ const char *previous="/var/run/prometheus.previous";\r
/*-----------------------------------------------------------------*/\r
- printf("Writing data transfer database ...\n");\r
+ printf("Writing data transfer database %s ... ", previous);\r
/*-----------------------------------------------------------------*/\r
- f=fopen("/var/run/prometheus.previous","w");\r
+ f=fopen(previous,"w");\r
if(f)\r
{\r
for_each(ip,ips)\r
}\r
}\r
fclose(f);\r
+ puts(" done.");\r
+ }\r
+ else\r
+ {\r
+ perror(previous);\r
}\r
f=fopen(html,"w");\r
ptr=html;\r
unsigned long long total_traffic=0, total_direct=0, total_proxy=0, total_upload=0, tmp_sum=0;\r
int active_classes=0;\r
int colspan=12;\r
- FILE *iplog;\r
struct Sum {unsigned long long l; int i; list(Sum);} *sum,*sums=NULL;\r
int limit_count=0, prio_count=0;\r
int popup_button=0;\r
for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing))\r
{\r
fprintf(f,"<br />%Lu", sharedip->upload);\r
+ if(!just_preview)\r
+ {\r
+ append_log(sharedip);\r
+ }\r
}\r
fputs("</span>\n",f);\r
}\r
\r
if(!just_preview)\r
{\r
- sprintf(str,"%s/%s.log",log_dir,ip->name);\r
- iplog=fopen(str,"a");\r
- if(iplog)\r
- {\r
- fprintf(iplog,"%ld\t%s\t%Lu\t%Lu\t%Lu\t%Lu\t%d\t%d\t%d\t%d\t%s",\r
- time(NULL), ip->name, ip->traffic, ip->direct, ip->proxy,\r
- ip->upload, ip->min, ip->max, ip->desired, ip->lmsid, d); /* d = date*/\r
- fclose(iplog);\r
- }\r
+ append_log(ip);\r
}\r
}\r
fprintf(f,"</tbody><thead><tr>\n\\r
/* write basic ERP data to log directory */\r
if(!just_preview)\r
{\r
+ FILE *iplog;\r
sprintf(str,"%s/ERP.log",log_dir);\r
iplog=fopen(str,"a");\r
if(iplog)\r
active_classes, total_traffic, i, limit_count, prio_count, d); /* d = date*/\r
fclose(iplog);\r
}\r
+ else\r
+ {\r
+ perror(str);\r
+ }\r
}\r
}\r
\r