Changeset

1496:4fa337035f46

mod_console: server:version() and server:uptime() commands
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Jul 2009 04:32:02 +0100
parents 1495:6c745a108e68
children 1497:4c2c403ca04b
files plugins/mod_console.lua
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_console.lua	Wed Jul 08 04:22:45 2009 +0100
+++ b/plugins/mod_console.lua	Wed Jul 08 04:32:02 2009 +0100
@@ -161,6 +161,24 @@
 	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)