more information in json output (for mailing system)
[svn/Prometheus-QoS/.git] / json.c
CommitLineData
05a90809 1/* Modified by: xChaos, 20121011 */\r
2\r
3#include "cll1-0.6.2.h"\r
4#include "ipstruct.h"\r
5\r
6extern struct IP *ips, *ip;\r
7\r
8void write_json_traffic(char *json)\r
9{\r
10 FILE *f=fopen(json, "w");\r
11 if(f > 0)\r
12 {\r
13 int jsoncount=0;\r
14 fprintf(f, "{\n");\r
15 for_each(ip, ips)\r
16 {\r
17 if( ip->lmsid > 0 \r
18 and (ip->traffic or ip->direct or ip->proxy or ip->upload))\r
19 {\r
20 if(jsoncount)\r
21 {\r
22 fprintf(f, ",\n");\r
23 }\r
e48d46c9 24 fprintf(f, " \"%s\":{ \"lms\": %d, \"ip\":\"%s\", \"total\":%Lu, \"down\":%Lu, \"proxy\":%Lu, \"up\":%Lu,\\r
25 \"min\":%d, \"max\":%d, \"limit\":%d, \"realquota\":%Lu, \"credit\":%Lu, \"dailyquota\":%ld }",\r
26 ip->name, ip->lmsid, ip->addr, ip->traffic, ip->direct, ip->proxy, ip->upload, \r
27 ip->min, ip->desired, ip->max, ip->realquota, ip->credit, \r
28 (ip->min*ip->keyword->data_limit+(ip->keyword->fixed_limit<<20)));\r
05a90809 29 jsoncount++;\r
30 }\r
31 }\r
32 fprintf(f, "}\n");\r
33 fclose(f);\r
34 puts("done.");\r
35 }\r
36 else\r
37 {\r
38 perror(json);\r
39 }\r
40}
This page took 0.126061 seconds and 4 git commands to generate.