summaryrefslogtreecommitdiffstats
path: root/src/civetweb/test/page_status.lua
blob: 3c9b0eb74955f71b53b27bb1baf927b84c15b10c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mg.write("HTTP/1.0 200 OK\r\n")

-- MIME type: https://www.ietf.org/rfc/rfc4627.txt, chapter 6
mg.write("Content-Type: application/json\r\n")

mg.write("\r\n")

num_threads = mg.get_option("num_threads")
num_threads = tonumber(num_threads)


function n(s) 
  if ((type(s) == "string") and (#s > 0)) then 
    return s 
  else 
    return "null" 
  end
end


mg.write("{\r\n\"system\" :\r\n")

mg.write(n(mg.get_info("system")))

mg.write(",\r\n\"summary\" :\r\n")
mg.write(n(mg.get_info("context")))
mg.write(",\r\n\"common\" :\r\n")
mg.write(n(mg.get_info("common")))
mg.write(",\r\n\"connections\" :\r\n[\r\n")

  mg.write(n(mg.get_info("connection", 1)))

for i=2,num_threads do
  mg.write(",\r\n")
  mg.write(n(mg.get_info("connection", i)))
end
mg.write("]\r\n}\r\n")