Mercurial > prosody-modules
annotate mod_statistics/prosodytop.lua @ 2318:3e5828e3f17f
mod_server_contact_info: Log error when no addresses or admins are set
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 01 Oct 2016 17:15:03 +0200 |
parents | 54b93cf0f631 |
children |
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"; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 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
|
6 |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local top = require "top"; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 function main() |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 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
|
11 --stdscr:clear(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local view = top.new({ |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 stdscr = stdscr; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 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
|
15 conn_list = {}; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 }); |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
1085
diff
changeset
|
17 |
1072
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 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
|
19 local ch = stdscr:getch(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 if ch then |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 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
|
22 view:resized(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 else |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 curses.ungetch(ch); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 end |
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 return 0.2; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 end); |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
1085
diff
changeset
|
29 |
1072
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 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
|
31 view:draw(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 return 1; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 end); |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
1085
diff
changeset
|
34 |
1072
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 --[[ |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 posix.signal(28, function () |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 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
|
38 --view:draw(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 ]] |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
1085
diff
changeset
|
41 |
1072
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 -- 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
|
43 local stdin = { |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 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
|
45 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
|
46 settimeout = function () end; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 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
|
48 close = function () end; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 receive = function (_, patt) |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 local ch = stdscr:getch(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 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
|
52 return string.char(ch); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 elseif ch == 410 then |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 view:resized(); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 else |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 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
|
57 end |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 return ""; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 end |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 }; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 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
|
62 -- TODO: Handle keypresses |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 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
|
64 end |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 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
|
66 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
|
67 }, "*a"); |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
1085
diff
changeset
|
68 |
1072
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 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
|
70 local e = { |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 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
|
72 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
|
73 end end; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 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
|
75 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
|
76 end end end; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 }; |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 local chunk = assert(loadstring(line)); |
4dbdb1b465e8
mod_statistics: Initial version, and a rough 'prosodyctl mod_statistics top'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 setfenv(chunk, e); |
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 }; |