annotate mod_statistics/prosodytop.lib.lua @ 5815:77c5709bd57a

mod_pubsub_serverinfo: Add explicit xmlns to all pubsub tags This helps when routing between hosts on the same server, where the namespace normalization is not handled by default.
author Matthew Wild <mwild1@gmail.com>
date Mon, 08 Jan 2024 15:53:21 +0000
parents 1962c94e2203
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local curses = require "curses";
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 local server = require "net.server_select";
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local timer = require "util.timer";
3427
8ea7d8f90d25 mod_statistics: top: Use util.envload for 5.2 compatibility
Matthew Wild <mwild1@gmail.com>
parents: 3414
diff changeset
4 local envload = require "util.envload".envload;
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 assert(curses.timeout, "Incorrect version of curses library. Try 'sudo luarocks install luaposix'");
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
3414
66bda434d476 mod_statistics: Update 'top' to (hopefully) work with Prosody 0.11/Lua 5.2
Matthew Wild <mwild1@gmail.com>
parents: 1699
diff changeset
8 local top = module:require "top";
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 function main()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local stdscr = curses.stdscr() -- it's a userdatum
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 --stdscr:clear();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local view = top.new({
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 stdscr = stdscr;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 prosody = { up_since = os.time() };
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 conn_list = {};
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 });
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
18
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 timer.add_task(0.01, function ()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 local ch = stdscr:getch();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 if ch then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 if stdscr:getch() == 410 then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 view:resized();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 else
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 curses.ungetch(ch);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 return 0.2;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 end);
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
30
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 timer.add_task(0, function ()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 view:draw();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 return 1;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 end);
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
35
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 --[[
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 posix.signal(28, function ()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 table.insert(view.conn_list, { jid = "WINCH" });
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 --view:draw();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 end);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 ]]
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
42
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 -- Fake socket object around stdin
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 local stdin = {
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 getfd = function () return 0; end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 dirty = function (self) return false; end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 settimeout = function () end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 send = function (_, d) return #d, 0; end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 close = function () end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 receive = function (_, patt)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 local ch = stdscr:getch();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 if ch >= 0 and ch <=255 then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 return string.char(ch);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 elseif ch == 410 then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 view:resized();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 else
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 table.insert(view.conn_list, { jid = tostring(ch) }); --FIXME
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 return "";
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 };
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 local function on_incoming(stdin, text)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 -- TODO: Handle keypresses
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 if text:lower() == "q" then os.exit(); end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 stdin = server.wrapclient(stdin, "stdin", 0, {
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 onincoming = on_incoming, ondisconnect = function () end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 }, "*a");
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
69
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 local function handle_line(line)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 local e = {
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 STAT = function (name) return function (value)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 view:update_stat(name, value);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 end end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 SESS = function (id) return function (jid) return function (stats)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 view:update_session(id, jid, stats);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 end end end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 };
3428
1962c94e2203 mod_statistics: Fix incorrect parameters to envload (thanks Dan)
Matthew Wild <mwild1@gmail.com>
parents: 3427
diff changeset
79 local chunk = assert(envload(line, "=prosodytop", e));
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 chunk();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
82
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 local stats_listener = {};
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
84
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 function stats_listener.onconnect(conn)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 --stdscr:mvaddstr(6, 0, "CONNECTED");
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
88
1585
64f55bcab9f7 mod_statistics/prosodytop.lua: Simplify and fix buffering and line separation (thanks Ge0rG)
Kim Alvefur <zash@zash.se>
parents: 1343
diff changeset
89 local partial = "";
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 function stats_listener.onincoming(conn, data)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 --print("DATA", data)
1585
64f55bcab9f7 mod_statistics/prosodytop.lua: Simplify and fix buffering and line separation (thanks Ge0rG)
Kim Alvefur <zash@zash.se>
parents: 1343
diff changeset
92 data = partial..data;
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 local lastpos = 1;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 for line, pos in data:gmatch("([^\n]+)\n()") do
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 lastpos = pos;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 handle_line(line);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 end
1585
64f55bcab9f7 mod_statistics/prosodytop.lua: Simplify and fix buffering and line separation (thanks Ge0rG)
Kim Alvefur <zash@zash.se>
parents: 1343
diff changeset
98 partial = data:sub(lastpos);
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
100
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 function stats_listener.ondisconnect(conn, err)
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 stdscr:mvaddstr(6, 0, "DISCONNECTED: "..(err or "unknown"));
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 end
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 1085
diff changeset
104
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 local conn = require "socket".tcp();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 assert(conn:connect("localhost", 5782));
1699
54b93cf0f631 mod_statistics/prosodytop: Use the same port number to connect to as defined in the module
Kim Alvefur <zash@zash.se>
parents: 1585
diff changeset
107 handler = server.wrapclient(conn, "localhost", 5782, stats_listener, "*a");
1072
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 return {
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 run = function ()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 --os.setlocale("UTF-8", "all")
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 curses.initscr()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 curses.cbreak()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 curses.echo(false) -- not noecho !
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 curses.nl(false) -- not nonl !
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 curses.timeout(0);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 local ok, err = pcall(main);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 --while true do stdscr:getch() end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 --stdscr:endwin()
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 if ok then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 ok, err = xpcall(server.loop, debug.traceback);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 curses.endwin();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 --stdscr:refresh();
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 if not ok then
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 print(err);
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 end
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 print"DONE"
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 end;
4dbdb1b465e8 mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 };