Lines 905-911
Link Here
|
905 |
path = ["stats"], |
905 |
path = ["stats"], |
906 |
q = Query, |
906 |
q = Query, |
907 |
lang = Lang} = Request) -> |
907 |
lang = Lang} = Request) -> |
908 |
Res = get_stats(Host, Lang), |
908 |
Res = case whereis(ejabberd_mod_statsdx) of |
|
|
909 |
undefined -> get_stats(Host, Lang); |
910 |
_ -> get_statsdx(Host, Lang) |
911 |
end, |
909 |
make_xhtml([?XCT("h1", "ejabberd stats")] ++ Res, Host, Lang); |
912 |
make_xhtml([?XCT("h1", "ejabberd stats")] ++ Res, Host, Lang); |
910 |
|
913 |
|
911 |
process_admin(Host, |
914 |
process_admin(Host, |
Lines 1397-1402
Link Here
|
1397 |
])]. |
1400 |
])]. |
1398 |
|
1401 |
|
1399 |
|
1402 |
|
|
|
1403 |
get_statsdx(global, Lang) -> |
1404 |
[ |
1405 |
?XC("h3", "Accounts"), |
1406 |
?XAE("table", [], |
1407 |
[?XE("tbody", [ |
1408 |
do_stat(global, Lang, "registeredusers") |
1409 |
]) |
1410 |
]), |
1411 |
?XC("h3", "Roster"), |
1412 |
?XAE("table", [], |
1413 |
[?XE("tbody", [ |
1414 |
do_stat(global, Lang, "totalrosteritems"), |
1415 |
do_stat(global, Lang, "meanitemsinroster") |
1416 |
]) |
1417 |
]), |
1418 |
?XC("h3", "Users"), |
1419 |
?XAE("table", [], |
1420 |
[?XE("tbody", [ |
1421 |
do_stat(global, Lang, "authusers"), |
1422 |
do_stat(global, Lang, "onlineusers"), |
1423 |
do_stat(global, Lang, "offlinemsg"), |
1424 |
do_stat(global, Lang, "vcards") |
1425 |
]) |
1426 |
]), |
1427 |
?XC("h3", "MUC"), |
1428 |
?XAE("table", [], |
1429 |
[?XE("tbody", [ |
1430 |
do_stat(global, Lang, "totalmucrooms"), |
1431 |
do_stat(global, Lang, "permmucrooms"), |
1432 |
do_stat(global, Lang, "regmucrooms") |
1433 |
]) |
1434 |
]), |
1435 |
?XC("h3", "Pub/Sub"), |
1436 |
?XAE("table", [], |
1437 |
[?XE("tbody", [ |
1438 |
do_stat(global, Lang, "regpubsubnodes") |
1439 |
]) |
1440 |
]), |
1441 |
?XC("h3", "IRC"), |
1442 |
?XAE("table", [], |
1443 |
[?XE("tbody", [ |
1444 |
do_stat(global, Lang, "ircconns") |
1445 |
]) |
1446 |
]), |
1447 |
?XC("h3", "Ratios"), |
1448 |
?XAE("table", [], |
1449 |
[?XE("tbody", [ |
1450 |
]) |
1451 |
]), |
1452 |
?XC("h3", "Sessions: " ++ get_stat_n("client")), |
1453 |
?XAE("table", [], |
1454 |
[?XE("tbody", |
1455 |
do_stat_table(global, Lang, "client", server) |
1456 |
) |
1457 |
]), |
1458 |
?XC("h3", "Sessions: " ++ get_stat_n("os")), |
1459 |
?XAE("table", [], |
1460 |
[?XE("tbody", |
1461 |
do_stat_table(global, Lang, "os", server) |
1462 |
) |
1463 |
]), |
1464 |
?XC("h3", "Sessions: " ++ get_stat_n("client") ++ "/" ++ get_stat_n("os")), |
1465 |
?XAE("table", [], |
1466 |
[?XE("tbody", |
1467 |
do_stat_table(global, Lang, "client_os", server) |
1468 |
) |
1469 |
]), |
1470 |
?XC("h3", "Sessions: " ++ get_stat_n("languages")), |
1471 |
?XAE("table", [], |
1472 |
[?XE("tbody", |
1473 |
do_stat_table(global, Lang, "languages", server) |
1474 |
) |
1475 |
]) |
1476 |
]; |
1477 |
|
1478 |
get_statsdx(Host, Lang) -> |
1479 |
[ |
1480 |
?XC("h2", Host), |
1481 |
?XC("h3", "Accounts"), |
1482 |
?XAE("table", [], |
1483 |
[?XE("tbody", [ |
1484 |
do_stat(global, Lang, "registeredusers", Host) |
1485 |
]) |
1486 |
]), |
1487 |
?XC("h3", "Roster"), |
1488 |
?XAE("table", [], |
1489 |
[?XE("tbody", [ |
1490 |
do_stat(global, Lang, "totalrosteritems", Host), |
1491 |
do_stat(global, Lang, "meanitemsinroster", Host) |
1492 |
]) |
1493 |
]), |
1494 |
?XC("h3", "Users"), |
1495 |
?XAE("table", [], |
1496 |
[?XE("tbody", [ |
1497 |
do_stat(global, Lang, "authusers", Host), |
1498 |
do_stat(global, Lang, "onlineusers", Host), |
1499 |
do_stat(global, Lang, "offlinemsg", Host), |
1500 |
do_stat(global, Lang, "vcards", Host) |
1501 |
]) |
1502 |
]), |
1503 |
?XC("h3", "Connections"), |
1504 |
?XAE("table", [], |
1505 |
[?XE("tbody", [ |
1506 |
do_stat(global, Lang, "s2sconnections", Host) |
1507 |
]) |
1508 |
]), |
1509 |
?XC("h3", "MUC"), |
1510 |
?XAE("table", [], |
1511 |
[?XE("tbody", [ |
1512 |
do_stat(global, Lang, "totalmucrooms", Host), |
1513 |
do_stat(global, Lang, "permmucrooms", Host), |
1514 |
do_stat(global, Lang, "regmucrooms", Host) |
1515 |
]) |
1516 |
]), |
1517 |
?XC("h3", "IRC"), |
1518 |
?XAE("table", [], |
1519 |
[?XE("tbody", [ |
1520 |
do_stat(global, Lang, "ircconns", Host) |
1521 |
]) |
1522 |
]), |
1523 |
%?XC("h3", "Pub/Sub"), |
1524 |
%?XAE("table", [], |
1525 |
% [?XE("tbody", [ |
1526 |
% do_stat(global, Lang, "regpubsubnodes", Host) |
1527 |
% ]) |
1528 |
%]), |
1529 |
?XC("h3", "Ratios"), |
1530 |
?XAE("table", [], |
1531 |
[?XE("tbody", [ |
1532 |
]) |
1533 |
]), |
1534 |
?XC("h3", "Sessions: " ++ get_stat_n("client")), |
1535 |
?XAE("table", [], |
1536 |
[?XE("tbody", |
1537 |
do_stat_table(global, Lang, "client", Host) |
1538 |
) |
1539 |
]), |
1540 |
?XC("h3", "Sessions: " ++ get_stat_n("os")), |
1541 |
?XAE("table", [], |
1542 |
[?XE("tbody", |
1543 |
do_stat_table(global, Lang, "os", Host) |
1544 |
) |
1545 |
]), |
1546 |
?XC("h3", "Sessions: " ++ get_stat_n("client") ++ "/" ++ get_stat_n("os")), |
1547 |
?XAE("table", [], |
1548 |
[?XE("tbody", |
1549 |
do_stat_table(global, Lang, "client_os", Host) |
1550 |
) |
1551 |
]), |
1552 |
?XC("h3", "Sessions: " ++ get_stat_n("languages")), |
1553 |
?XAE("table", [], |
1554 |
[?XE("tbody", |
1555 |
do_stat_table(global, Lang, "languages", Host) |
1556 |
) |
1557 |
]) |
1558 |
]. |
1559 |
|
1560 |
|
1400 |
list_online_users(Host, _Lang) -> |
1561 |
list_online_users(Host, _Lang) -> |
1401 |
Users = [{S, U} || {U, S, R} <- ejabberd_sm:get_vh_session_list(Host)], |
1562 |
Users = [{S, U} || {U, S, R} <- ejabberd_sm:get_vh_session_list(Host)], |
1402 |
SUsers = lists:usort(Users), |
1563 |
SUsers = lists:usort(Users), |
Lines 2013-2018
Link Here
|
2013 |
]; |
2174 |
]; |
2014 |
|
2175 |
|
2015 |
get_node(global, Node, ["stats"], Query, Lang) -> |
2176 |
get_node(global, Node, ["stats"], Query, Lang) -> |
|
|
2177 |
Res = case whereis(ejabberd_mod_statsdx) of |
2178 |
undefined -> get_node(global, Node, ["statslight"], Query, Lang); |
2179 |
_ -> get_node(global, Node, ["statsdx"], Query, Lang) |
2180 |
end; |
2181 |
|
2182 |
get_node(global, Node, ["statslight"], Query, Lang) -> |
2016 |
UpTime = rpc:call(Node, erlang, statistics, [wall_clock]), |
2183 |
UpTime = rpc:call(Node, erlang, statistics, [wall_clock]), |
2017 |
UpTimeS = io_lib:format("~.3f", [element(1, UpTime)/1000]), |
2184 |
UpTimeS = io_lib:format("~.3f", [element(1, UpTime)/1000]), |
2018 |
CPUTime = rpc:call(Node, erlang, statistics, [runtime]), |
2185 |
CPUTime = rpc:call(Node, erlang, statistics, [runtime]), |
Lines 2055-2064
Link Here
|
2055 |
]) |
2222 |
]) |
2056 |
])]; |
2223 |
])]; |
2057 |
|
2224 |
|
|
|
2225 |
get_node(global, Node, ["statsdx"], Query, Lang) -> |
2226 |
TransactionsCommited = |
2227 |
rpc:call(Node, mnesia, system_info, [transaction_commits]), |
2228 |
TransactionsAborted = |
2229 |
rpc:call(Node, mnesia, system_info, [transaction_failures]), |
2230 |
TransactionsRestarted = |
2231 |
rpc:call(Node, mnesia, system_info, [transaction_restarts]), |
2232 |
TransactionsLogged = |
2233 |
rpc:call(Node, mnesia, system_info, [transaction_log_writes]), |
2234 |
|
2235 |
[?XC("h1", io_lib:format(?T("~p statistics"), [Node])), |
2236 |
?XC("h3", "Connections"), |
2237 |
?XAE("table", [], |
2238 |
[?XE("tbody", [ |
2239 |
do_stat(global, Lang, "authusers"), |
2240 |
do_stat(Node, Lang, "httppollusers"), |
2241 |
do_stat(Node, Lang, "s2sconnections"), |
2242 |
do_stat(Node, Lang, "s2sservers") |
2243 |
]) |
2244 |
]), |
2245 |
?XC("h3", "Erlang"), |
2246 |
?XAE("table", [], |
2247 |
[?XE("tbody", [ |
2248 |
do_stat(Node, Lang, "operatingsystem"), |
2249 |
do_stat(Node, Lang, "erlangmachine"), |
2250 |
do_stat(Node, Lang, "erlangmachinetarget"), |
2251 |
do_stat(Node, Lang, "maxprocallowed"), |
2252 |
do_stat(Node, Lang, "procqueue"), |
2253 |
do_stat(Node, Lang, "totalerlproc") |
2254 |
]) |
2255 |
]), |
2256 |
?XC("h3", "Times"), |
2257 |
?XAE("table", [], |
2258 |
[?XE("tbody", [ |
2259 |
do_stat(Node, Lang, "uptime"), |
2260 |
do_stat(Node, Lang, "uptimehuman"), |
2261 |
do_stat(Node, Lang, "lastrestart"), |
2262 |
do_stat(Node, Lang, "cputime") |
2263 |
]) |
2264 |
]), |
2265 |
?XC("h3", "CPU"), |
2266 |
?XAE("table", [], |
2267 |
[?XE("tbody", [ |
2268 |
do_stat(Node, Lang, "cpu_avg1"), |
2269 |
do_stat(Node, Lang, "cpu_avg5"), |
2270 |
do_stat(Node, Lang, "cpu_avg15"), |
2271 |
do_stat(Node, Lang, "cpu_nprocs")%, |
2272 |
%do_stat(Node, Lang, "cpu_util_user"), |
2273 |
%do_stat(Node, Lang, "cpu_nice_user"), |
2274 |
%do_stat(Node, Lang, "cpu_kernel"), |
2275 |
%do_stat(Node, Lang, "cpu_idle"), |
2276 |
%do_stat(Node, Lang, "cpu_wait") |
2277 |
]) |
2278 |
]), |
2279 |
%?XC("h3", "RAM"), |
2280 |
%?XAE("table", [], |
2281 |
% [?XE("tbody", [ |
2282 |
%do_stat(Node, Lang, "memsup_system"), |
2283 |
%do_stat(Node, Lang, "memsup_free"), |
2284 |
%do_stat(Node, Lang, "reductions") |
2285 |
% ]) |
2286 |
% ]), |
2287 |
?XC("h3", "Database"), |
2288 |
?XAE("table", [], |
2289 |
[?XE("tbody", [ |
2290 |
?XE("tr", [?XCT("td", "Transactions commited"), |
2291 |
?XAC("td", [{"class", "alignright"}], |
2292 |
integer_to_list(TransactionsCommited))]), |
2293 |
?XE("tr", [?XCT("td", "Transactions aborted"), |
2294 |
?XAC("td", [{"class", "alignright"}], |
2295 |
integer_to_list(TransactionsAborted))]), |
2296 |
?XE("tr", [?XCT("td", "Transactions restarted"), |
2297 |
?XAC("td", [{"class", "alignright"}], |
2298 |
integer_to_list(TransactionsRestarted))]), |
2299 |
?XE("tr", [?XCT("td", "Transactions logged"), |
2300 |
?XAC("td", [{"class", "alignright"}], |
2301 |
integer_to_list(TransactionsLogged))]) |
2302 |
]) |
2303 |
])]; |
2304 |
|
2058 |
get_node(Host, Node, NPath, Query, Lang) -> |
2305 |
get_node(Host, Node, NPath, Query, Lang) -> |
2059 |
[?XCT("h1", "Not found")]. |
2306 |
[?XCT("h1", "Not found")]. |
2060 |
|
2307 |
|
|
|
2308 |
do_table_element(Lang, L, N) -> |
2309 |
?XE("tr", [ |
2310 |
?XCT("td", L), |
2311 |
?XAC("td", [{"class", "alignright"}], |
2312 |
N) |
2313 |
]). |
2061 |
|
2314 |
|
|
|
2315 |
do_stat_table(global, Lang, Stat, Host) -> |
2316 |
Os = mod_statsdx:get(global, [Stat, Host]), |
2317 |
lists:map( |
2318 |
fun({L, N}) -> |
2319 |
do_table_element(Lang, L, io_lib:format("~p", [N])) |
2320 |
end, |
2321 |
Os |
2322 |
). |
2323 |
|
2324 |
do_stat(Node, Lang, Stat) -> |
2325 |
?XE("tr", [ |
2326 |
?XCT("td", get_stat_n(Stat)), |
2327 |
?XAC("td", [{"class", "alignright"}], |
2328 |
get_stat_v(Node, [Stat]))]). |
2329 |
|
2330 |
do_stat(Node, Lang, Stat, Host) -> |
2331 |
%[Res] = get_stat_v(Node, [Stat, Host]), |
2332 |
%do_table_element(Lang, get_stat_n(Stat), Res). |
2333 |
do_table_element(Lang, get_stat_n(Stat), get_stat_v(Node, [Stat, Host])). |
2334 |
|
2335 |
% Get a stat name |
2336 |
get_stat_n(Stat) -> |
2337 |
mod_statsdx:get(foo, [Stat, title]). |
2338 |
% Get a stat value |
2339 |
get_stat_v(Node, Stat) -> get_stat_v2(mod_statsdx:get(Node, Stat)). |
2340 |
get_stat_v2(Value) when is_list(Value) -> Value; |
2341 |
get_stat_v2(Value) when is_float(Value) -> io_lib:format("~.4f", [Value]); |
2342 |
get_stat_v2(Value) -> io_lib:format("~p", [Value]). |
2343 |
|
2062 |
node_parse_query(Node, Query) -> |
2344 |
node_parse_query(Node, Query) -> |
2063 |
case lists:keysearch("restart", 1, Query) of |
2345 |
case lists:keysearch("restart", 1, Query) of |
2064 |
{value, _} -> |
2346 |
{value, _} -> |