1mg.write("HTTP/1.0 200 OK\r\n")
2
3-- MIME type: https://www.ietf.org/rfc/rfc4627.txt, chapter 6
4mg.write("Content-Type: application/json\r\n")
5
6mg.write("\r\n")
7
8num_threads = mg.get_option("num_threads")
9num_threads = tonumber(num_threads)
10
11
12function n(s)
13  if ((type(s) == "string") and (#s > 0)) then
14    return s
15  else
16    return "null"
17  end
18end
19
20
21mg.write("{\r\n\"system\" :\r\n")
22
23mg.write(n(mg.get_info("system")))
24
25mg.write(",\r\n\"summary\" :\r\n")
26mg.write(n(mg.get_info("context")))
27mg.write(",\r\n\"common\" :\r\n")
28mg.write(n(mg.get_info("common")))
29mg.write(",\r\n\"connections\" :\r\n[\r\n")
30
31  mg.write(n(mg.get_info("connection", 1)))
32
33for i=2,num_threads do
34  mg.write(",\r\n")
35  mg.write(n(mg.get_info("connection", i)))
36end
37mg.write("]\r\n}\r\n")
38
39