char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */\r
char *html = "/var/www/traffic.html"; /* hall of fame - html version */\r
char *preview = "/var/www/preview.html"; /* hall of fame preview - html version */\r
-char *json = "/var/www/logs/traffic.json"; /* hall of fame - json version */\r
+char *json_traffic = "/var/www/logs/traffic.json"; /* hall of fame - json version */\r
char *json_preview = "/var/www/logs/preview.json"; /* hall of fame preview - json version */\r
char *cmdlog = "/var/log/prometheuslog"; /* command log filename */\r
char *log_dir = "/var/www/logs/"; /* log directory pathname, ended with slash */\r
struct Keyword *keyword, *defaultkeyword=NULL, *keywords=NULL;\r
\r
void parse_ip_log(int argc, char **argv);\r
-/* implementid in parselog.c */\r
+/* implemented in parselog.c */\r
\r
void parse_hosts(char *hosts);\r
-/* implementid in parsehosts.c */\r
+/* implemented in parsehosts.c */\r
+\r
+void write_json_traffic(char *json);\r
+/* implemented in json.c */\r
\r
const char *tr_odd_even(void)\r
{\r
ioption("hall-of-fame-enable",hall_of_fame);\r
option("hall-of-fame-title",title);\r
option("hall-of-fame-filename",html);\r
- option("json-filename",json);\r
+ option("json-filename",json_traffic);\r
option("hall-of-fame-preview",preview);\r
option("json-preview",json_preview);\r
option("log-filename",cmdlog);\r
done; /* ugly macro end */\r
}\r
html=preview;\r
- json=json_preview;\r
+ json_traffic=json_preview;\r
}\r
\r
if(!dry_run && !just_flush)\r
{\r
/*-----------------------------------------------------------------*/\r
- printf("Writing json overview %s ... ", json);\r
+ printf("Writing json traffic overview %s ... ", json_traffic);\r
/*-----------------------------------------------------------------*/\r
- f=fopen(json, "w");\r
- if(f > 0)\r
- {\r
- int jsoncount=0;\r
- fprintf(f, "{\n");\r
- for_each(ip, ips)\r
- {\r
- if( ip->lmsid > 0 \r
- && (ip->traffic || ip->direct || ip->proxy || ip->upload))\r
- {\r
- if(jsoncount)\r
- {\r
- fprintf(f, ",\n");\r
- }\r
- fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu, \"min\":%d, \"max\":%d, \"limit\":%d }",\r
- ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, ip->min, ip->desired, ip->max);\r
- jsoncount++;\r
- }\r
- }\r
- fprintf(f, "}\n");\r
- fclose(f);\r
- puts("done.");\r
- }\r
- else\r
- {\r
- perror(json);\r
- }\r
+ write_json_traffic(json_traffic);\r
}\r
\r
f=fopen(html,"w");\r