From 4300741747d8cee2589d236c9c89b45ca20a3834 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 8 Jul 2009 04:32:02 +0100 Subject: mod_console: server:version() and server:uptime() commands --- plugins/mod_console.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 9d47cbc6..0d6b5e41 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -161,6 +161,24 @@ function def_env.server:reload() return true, "Server reloaded"; end +function def_env.server:version() + return true, tostring(prosody.version or "unknown"); +end + +function def_env.server:uptime() + local t = os.time()-prosody.start_time; + local seconds = t%60; + t = (t - seconds)/60; + local minutes = t%60; + t = (t - minutes)/60; + local hours = t%24; + t = (t - hours)/24; + local days = t; + return true, string.format("This server has been running for %d day%s, %d hour%s and %d minute%s (since %s)", + days, (days ~= 1 and "s") or "", hours, (hours ~= 1 and "s") or "", + minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time)); +end + def_env.module = {}; local function get_hosts_set(hosts, module) -- cgit v1.2.3