18 lines
729 B
Lua
Executable File
18 lines
729 B
Lua
Executable File
#!/usr/bin/env lua
|
|
local rquri = "http://localhost:5280/serverinfo"
|
|
|
|
local http = require "socket.http"
|
|
local socket = require "socket"
|
|
|
|
local hostname = os.getenv("COLLECTD_HOSTNAME") or os.getenv("HOSTNAME") or "lain.church"
|
|
local interval = os.getenv("COLLECTD_INTERVAL") or 60
|
|
|
|
while true do
|
|
socket.sleep(interval)
|
|
local request = {http.request(rquri)}
|
|
local online,registered = request[1]:match('{"connected":(%d+),"registered":(%d+)}')
|
|
online,registered = tonumber(online),tonumber(registered)
|
|
print(string.format("PUTVAL %s/exec-prosody/prosody_connected interval=%d N:%d",hostname,interval,online))
|
|
print(string.format("PUTVAL %s/exec-prosody/prosody_registered interval=%d N:%d",hostname,interval,registered))
|
|
end
|