-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_info.lua
More file actions
50 lines (40 loc) · 1.01 KB
/
system_info.lua
File metadata and controls
50 lines (40 loc) · 1.01 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
local system = require("system")
local json = require("json")
local function call(arguments)
local info = {}
local mem, mem_err = system.memory.stats()
if mem then
info.memory = mem
else
info.memory_error = tostring(mem_err)
end
local goroutines, gr_err = system.runtime.goroutines()
if goroutines then
info.goroutines = goroutines
end
local cpus, cpu_err = system.runtime.cpu_count()
if cpus then
info.cpus = cpus
end
local max_procs, mp_err = system.runtime.max_procs()
if max_procs then
info.max_procs = max_procs
end
local hostname, h_err = system.process.hostname()
if hostname then
info.hostname = hostname
end
local pid, p_err = system.process.pid()
if pid then
info.pid = pid
end
local mods, m_err = system.modules()
if mods then
info.modules = mods
end
return json.encode({
success = true,
info = info
})
end
return { call = call }