comparison mod_statistics/mod_statistics.lua @ 1074:cccd9f6a628d

mod_statistics: Better detection of when running under prosody vs prosodyctl
author Kim Alvefur <zash@zash.se>
date Sat, 15 Jun 2013 20:36:23 +0100
parents 4dbdb1b465e8
children 7dbde05b48a9
comparison
equal deleted inserted replaced
1073:fe57e9332e52 1074:cccd9f6a628d
93 function listener.ondisconnect(conn) 93 function listener.ondisconnect(conn)
94 sessions[conn] = nil; 94 sessions[conn] = nil;
95 end 95 end
96 96
97 function module.load() 97 function module.load()
98 if not(prosody and prosody.full_sessions) then return; end --FIXME: hack, need a proper flag 98 if not(prosody and prosody.arg) then
99 return;
100 end
99 filters.add_filter_hook(stats.filter_hook); 101 filters.add_filter_hook(stats.filter_hook);
100 102
101 module:add_timer(1, function () 103 module:add_timer(1, function ()
102 for stat_name, stat in pairs(available_stats) do 104 for stat_name, stat in pairs(available_stats) do
103 if stat.get then 105 if stat.get then
113 active_sessions[session] = nil; 115 active_sessions[session] = nil;
114 push_session_to_all(session, session_stats); 116 push_session_to_all(session, session_stats);
115 end 117 end
116 return 1; 118 return 1;
117 end); 119 end);
118 module:provides("net", { 120
119 default_port = 5782;
120 listener = listener;
121 });
122 end 121 end
123 function module.unload() 122 function module.unload()
124 filters.remove_filter_hook(stats.filter_hook); 123 filters.remove_filter_hook(stats.filter_hook);
125 end 124 end
126 function module.command( args ) 125 function module.command( args )
130 package.path = dir.."/?.lua;"..dir.."/?.lib.lua;"..package.path; 129 package.path = dir.."/?.lua;"..dir.."/?.lib.lua;"..package.path;
131 local prosodytop = require "prosodytop"; 130 local prosodytop = require "prosodytop";
132 prosodytop.run(); 131 prosodytop.run();
133 end 132 end
134 end 133 end
134
135 if prosody and prosody.arg then
136 module:provides("net", {
137 default_port = 5782;
138 listener = listener;
139 private = true;
140 });
141 end