diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-12 15:30:26 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-10-12 15:30:26 +0200 |
commit | 934919ff6ad143eb585943799f6685a34bd403b0 (patch) | |
tree | c920d13567cb64fd5ae209ca4e5ee08d8513b0fd /pingu.lua | |
parent | c2af879f64bac393df12e593b1bf16cd56517095 (diff) | |
download | pingu-934919ff6ad143eb585943799f6685a34bd403b0.tar.bz2 pingu-934919ff6ad143eb585943799f6685a34bd403b0.tar.xz |
pingu_adm: implement host-status and gateway-status
Diffstat (limited to 'pingu.lua')
-rw-r--r-- | pingu.lua | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -2,20 +2,28 @@ module(..., package.seeall) -local function status(self) - self.handle:write("status\n") +local function run_command(self, cmd) + self.handle:write(cmd.."\n") self.handle:flush() local t = {} local line = self.handle:read("*line") while line ~= "" do - local host, status = string.match(line, "^(.*): (.*)$") - t[host] = status + local key, value = string.match(line, "^(.*): (.*)$") + t[key] = value line = self.handle:read("*line") end return t end +local function host_status(self) + return self:run_command("host-status") +end + +local function gateway_status(self) + return self:run_command("gateway-status") +end + local function close(self) return self.handle:close() end @@ -31,7 +39,9 @@ function connect(socket_path) end return { ["handle"] = fh, - ["status"] = status, + ["run_command"] = run_command, + ["host_status"] = host_status, + ["gateway_status"] = gateway_status, ["close"] = close } end |