Permalink
Browse files

improve daemon status output (capflam)

Improve the output of the "yaws --status" command by adding session
and connection counters for each group of virtual servers.
  • Loading branch information...
1 parent e014400 commit f64b24d2b98ad7bb2c106352295bda0b8fa53c78 @capflam capflam committed with vinoski May 3, 2011
Showing with 17 additions and 19 deletions.
  1. +10 −18 src/yaws_ctl.erl
  2. +7 −1 src/yaws_server.erl
View
@@ -244,24 +244,16 @@ a_status() ->
try
{UpTime, L} = yaws_server:stats(),
{Days, {Hours, Minutes, _Secs}} = UpTime,
- H = f("~n Uptime: ~w Days, ~w Hours, ~w Minutes ~n",
- [Days, Hours, Minutes]),
-
- T =lists:map(
- fun({Host,IP,Hits}) ->
- L1= f("stats for ~p at ~p ~n",
- [Host,IP]),
- T = "\n"
- "URL Number of hits\n",
- L2=lists:map(
- fun({Url, Hits2}) ->
- f("~-30s ~-7w ~n",
- [Url, Hits2])
- end, Hits),
- END = "\n",
- [L1, T, L2, END]
- end, L),
- [H, T]
+ UpStr = f("~n Uptime: ~w Days, ~w Hours, ~w Minutes ~n",
+ [Days, Hours, Minutes]),
+
+ Header = f("IP Port Connections Sessions Requests~n", []),
+ Lines = lists:map(fun({IP0, Port, Conns, Sess, Reqs}) ->
+ IP = format_ip(IP0),
+ f("~s ~p ~p ~p ~p~n",
+ [IP, Port, Conns, Sess, Reqs])
+ end, L),
+ [Header, Lines, UpStr]
catch
_:Err ->
io_lib:format("Cannot get status ~p~n", [Err])
View
@@ -96,7 +96,13 @@ getconf() ->
stats() ->
{_S, Time} = status(),
Diff = calendar:time_difference(Time, calendar:local_time()),
- {Diff, []}.
+ L = [begin
+ SC = hd(GS#gs.group),
+ {SC#sconf.listen, SC#sconf.port,
+ GS#gs.connections, GS#gs.sessions, GS#gs.reqs}
+ end || GS <- gs_status()],
+ {Diff, L}.
+
l2a(L) when is_list(L) -> list_to_atom(L);
l2a(A) when is_atom(A) -> A.

0 comments on commit f64b24d

Please sign in to comment.