Skip to content

Commit

Permalink
Merge branch 'release/0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Apr 27, 2016
2 parents d9de719 + cf15775 commit 4a7674f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 56 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ mazen.harake@erlang-solutions.com (The part of code is derived from entop)

Yoshiyuki Kanno
Yosuke Hara
Wilson Li
68 changes: 38 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ $ tar -czf leofs_doctor.tar.gz leofs_doctor
* Deliver ``leofs_doctor.tar.gz`` to users


## How to Use
## How to Use
### Prepare it
* Modify **a cookie for distributed Erlang** in [files/vm.args](https://github.com/leo-project/leofs_doctor/blob/develop/files/vm.args) to be able to connect a target node:

```shell
## Cookie for distributed erlang
-setcookie <COOKIE_FOR_DISTRIBUTED_ERLANG>
```

### Execute it
```shell
$ leofs_doctor --help
Usage: leofs_doctor ## related to connection
-target_node <TARGET_NODE>
## related to entop
[-sort_col <COL_NAME>] [-reverse <yes|no>] [-topn <TOPN>]
[-interval <secs>] [times <times>]
[-interval <SECS>] [-times <TIMES>]
## related to supervisour tree
[-root_sup <SUPERVISOR_NAME>] [-expected_svt <FILENAME>]

Expand All @@ -75,7 +83,7 @@ $ leofs_doctor -target_node manager_0@127.0.0.1 \
-expected_svt ~/dev/erlang/leofs_doctor/files/expected_svt.yml
```

#### Output
### Output

```erlang
- Date: 2016/02/22 17:15:40
Expand Down Expand Up @@ -131,33 +139,33 @@ $ leofs_doctor -target_node manager_0@127.0.0.1 \
[entop]
#1:
Node: 'manager_0@127.0.0.1'
(17/6.4) unix (darwin 15.3.0) CPU:4 SMP +A:32 +K
Sorting on "HSize" (Descending), Retrieved in 3ms
Time: local time 11:39:09, up for 002:21:24:44, 1ms latency,
Processes: total 189 (RQ 0) at 49682 RpI using 14940.6k (14953.8k allocated)
Memory: Sys 37381.4k, Atom 768.5k/774.9k, Bin 59.8k, Code 22852.0k, Ets 8231.8k
Pid Registered Name Initial Call Current Function Reductions MQueue HSize SSize HTotal
<0.1146.0> - proc_lib:init_p/5 gen_server:loop/6 144007 0 121536 9 121536
<0.593.0> rex proc_lib:init_p/5 gen_server:loop/6 267918 0 28690 9 28690
<0.3.0> erl_prim_loader erlang:apply/2 erl_prim_loader:loop/3 114396 0 17731 6 17731
<0.606.0> code_server erlang:apply/2 code_server:loop/1 8386558 0 17731 3 17731
<0.1147.0> - proc_lib:init_p/5 gen_server:loop/6 159510330 0 17731 9 17731
<0.631.0> release_handler proc_lib:init_p/5 gen_server:loop/6 75273 0 10958 9 10958
<0.638.0> tcp_server_sup proc_lib:init_p/5 gen_server:loop/6 66907 0 4185 9 4185
<0.588.0> application_controll erlang:apply/2 gen_server:loop/6 68784 0 2586 7 2586
<0.697.0> leo_rpc_sup proc_lib:init_p/5 gen_server:loop/6 60331 0 2586 9 2586
<0.779.0> - proc_lib:init_p/5 disk_log:loop/1 140856 0 2586 4 2586
<0.31259.12> - erlang:apply/2 shell:get_command1/5 14609 0 2586 16 2586
<0.663.0> - proc_lib:init_p/5 application_master:main_loop/2 56137 0 1598 6 1598
<0.670.0> leo_mq_sup proc_lib:init_p/5 gen_server:loop/6 70811 0 1598 9 1598
<0.673.0> mq_fail_rebalance_me proc_lib:init_p/5 gen_server:loop/6 255121 0 1598 9 1598
<0.680.0> mq_fail_rebalance_me proc_lib:init_p/5 gen_server:loop/6 250290 0 1598 9 1598
<0.681.0> mq_fail_rebalance_me proc_lib:init_p/5 gen_server:loop/6 248238 0 1598 9 1598
<0.692.0> mq_monitor_node_mess proc_lib:init_p/5 gen_server:loop/6 85845 0 1598 9 1598
<0.743.0> disk_log_server proc_lib:init_p/5 gen_server:loop/6 73777 0 1598 9 1598
<0.1124.0> snmpa_supervisor proc_lib:init_p/5 gen_server:loop/6 93614 0 1598 9 1598
<0.0.0> init otp_ring0:start/2 init:loop/1 173667 0 987 2 987
(17/6.4.1.5) unix (darwin 14.5.0) CPU:8 SMP +A:32 +K
Sorting on "Reductions" (Descending), Retrieved in 2ms
Time: local time 13:30:14, up for 000:00:02:42, 0ms latency,
Processes: total 187 (RQ 0) at 2267 RpI using 15153.1k (15163.7k allocated)
Memory: Sys 36775.4k, Atom 707.2k/734.9k, Bin 235.2k, Code 22867.4k, Ets 6320.9k
Pid Registered Name Initial Call Current Function Reductions Reductions+ MQueue HSize SSize HTotal
<0.688.0> leo_redundant_manage proc_lib:init_p/5 gen_server:loop/6 798419 798419 0 17731 9 17731
<0.1157.0> - proc_lib:init_p/5 gen_server:loop/6 556483 556483 0 376 9 376
<0.691.0> leo_membership_clust proc_lib:init_p/5 gen_server:loop/6 423614 423614 0 233 9 233
<0.643.0> - proc_lib:init_p/5 gen_server:loop/6 302428 302428 0 2586 9 2586
<0.640.0> leo_manager_cluster_ proc_lib:init_p/5 gen_server:loop/6 116306 116306 0 610 9 610
<0.689.0> leo_redundant_manage proc_lib:init_p/5 gen_server:loop/6 108178 108178 0 376 9 376
<0.771.0> mnesia_tm proc_lib:init_p/5 mnesia_tm:doit_loop/1 105689 105689 0 376 17 376
<0.769.0> mnesia_locker proc_lib:init_p/5 mnesia_locker:loop/1 94995 94995 0 233 15 233
<0.3.0> erl_prim_loader erlang:apply/2 erl_prim_loader:loop/3 81299 81299 0 17731 6 17731
<0.607.0> code_server erlang:apply/2 code_server:loop/1 77216 77216 0 17731 3 17731
<0.0.0> init otp_ring0:start/2 init:loop/1 68458 68458 0 2586 2 2586
<0.588.0> error_logger proc_lib:init_p/5 gen_event:fetch_msg/5 59318 59318 0 376 8 376
<0.606.0> file_server_2 proc_lib:init_p/5 gen_server:loop/6 57878 57878 0 987 9 987
<0.644.0> tcp_server_cui_3 proc_lib:init_p/5 prim_inet:accept0/2 56433 56433 0 10958 15 10958
<0.785.0> - proc_lib:init_p/5 disk_log:loop/1 46284 46284 0 1598 4 1598
<0.1156.0> - proc_lib:init_p/5 gen_server:loop/6 43796 43796 0 121536 9 121536
<0.645.0> tcp_server_cui_2 proc_lib:init_p/5 prim_inet:accept0/2 43782 43782 0 610 15 610
<0.646.0> tcp_server_cui_1 proc_lib:init_p/5 prim_inet:accept0/2 31013 31013 0 10958 15 10958
<0.669.0> leo_logger_file_e proc_lib:init_p/5 gen_server:loop/6 29422 29422 0 2586 9 2586
<0.690.0> leo_membership_clust proc_lib:init_p/5 gen_server:loop/6 27807 27807 0 610 9 610
[mnesia]
- System Info
Expand Down
2 changes: 1 addition & 1 deletion relx.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%% under the License.
%%
%%======================================================================
{release, {leofs_doctor, "0.4.0"},
{release, {leofs_doctor, "0.4.2"},
[yamerl, leofs_doctor]}.
{overlay, [{mkdir, "log/sasl"},
{mkdir, "etc"},
Expand Down
33 changes: 21 additions & 12 deletions src/entop_format.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
-module(entop_format).

%% Module API
-export([init/1, header/2, row/2]).
-export([init/1, header/2, row/3, row_reductions/1]).
-export([colname_to_idx/1]).

%% Records
Expand All @@ -58,29 +58,34 @@ colname_to_idx("reductions") ->
5;
colname_to_idx("red") ->
5;
colname_to_idx("mqueue") ->
colname_to_idx("reductions+") ->
6;
colname_to_idx("mq") ->
colname_to_idx("red+") ->
6;
colname_to_idx("hsize") ->
colname_to_idx("mqueue") ->
7;
colname_to_idx("hs") ->
colname_to_idx("mq") ->
7;
colname_to_idx("ssize") ->
colname_to_idx("hsize") ->
8;
colname_to_idx("ss") ->
colname_to_idx("hs") ->
8;
colname_to_idx("htotal") ->
colname_to_idx("ssize") ->
9;
colname_to_idx("ss") ->
9;
colname_to_idx("htotal") ->
10;
colname_to_idx("ht") ->
9.
10.

init(Node) ->
Columns = [{"Pid", 16, [{align, right}]},
{"Registered Name", 20, []},
{"Initial Call", 30, []},
{"Current Function", 40, []},
{"Reductions", 12, []},
{"Reductions+", 12, []},
{"MQueue", 6, []},
{"HSize", 12, []},
{"SSize", 6, []},
Expand Down Expand Up @@ -116,9 +121,9 @@ header(SystemInfo, State) ->
{ok, [ lists:flatten(Row) || Row <- [Row1, Row2, Row3, Row4] ], State}.

%% Column Specific Callbacks
row([{pid,_}|undefined], State) ->
row([{pid,_}|undefined], _LastReductions, State) ->
{ok, skip, State};
row(ProcessInfo, State) ->
row(ProcessInfo, LastReductions, State) ->
Pid = proplists:get_value(pid, ProcessInfo),
RegName = case proplists:get_value(registered_name, ProcessInfo) of
[] ->
Expand All @@ -129,11 +134,15 @@ row(ProcessInfo, State) ->
InitialCall = fun2str(proplists:get_value(initial_call, ProcessInfo, 0)),
CurrentFunction = fun2str(proplists:get_value(current_function, ProcessInfo, 0)),
Reductions = proplists:get_value(reductions, ProcessInfo, 0),
ReductionsP = Reductions - LastReductions,
Queue = proplists:get_value(message_queue_len, ProcessInfo, 0),
Heap = proplists:get_value(heap_size, ProcessInfo, 0),
Stack = proplists:get_value(stack_size, ProcessInfo, 0),
HeapTot = proplists:get_value(total_heap_size, ProcessInfo, 0),
{ok, {Pid, RegName, InitialCall, CurrentFunction, Reductions, Queue, Heap, Stack, HeapTot}, State}.
{ok, {Pid, RegName, InitialCall, CurrentFunction, Reductions, ReductionsP, Queue, Heap, Stack, HeapTot}, State}.

row_reductions({Pid, _, _, _, Reductions, _, _, _, _, _} = _Row) ->
{Pid, Reductions}.

fun2str({M, N, A}) ->
lists:append([atom_to_list(M), ":", atom_to_list(N), "/", integer_to_list(A)]).
Expand Down
27 changes: 17 additions & 10 deletions src/entop_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ draw_1(Times, #state{times = Times_1,
NState = load_remote_static_data(State),
remote_load_code(NState#state.remote_module, State#state.node),
NState2 = init_callback(NState),
fetch_and_update(NState2),
State2 = fetch_and_update(NState2),

%% Wait for the next procedure
case (Times_1 > 1) of
Expand All @@ -74,7 +74,7 @@ draw_1(Times, #state{times = Times_1,
false ->
void
end,
draw_1(Times + 1, State).
draw_1(Times + 1, State2).


%% =============================================================================
Expand Down Expand Up @@ -152,7 +152,8 @@ update_screen(Time, HeaderData, RowDataList, State) ->
{RowList, State2} = process_row_data(RowDataList, State1),
SortedRowList = sort(RowList, State),
update_rows(SortedRowList, State2#state.columns,
0, State2#state.topn).
0, State2#state.topn),
State2.

draw_title_bar([], Acc) ->
?PRINT(Acc),
Expand All @@ -179,13 +180,19 @@ process_row_data(RowDataList, State) ->
prd(RowDataList, State, []).

prd([], State, Acc) ->
{Acc, State};
prd([RowData|Rest], State, Acc) ->
case (State#state.callback):row(RowData, State#state.cbstate) of
{ok, skip, NCBState} ->
prd(Rest, State#state{ cbstate = NCBState }, Acc);
{ok, Row, NCBState} ->
prd(Rest, State#state{ cbstate = NCBState }, [Row|Acc])
NLRPL = [(State#state.callback):row_reductions(Row) || Row <- Acc],
{Acc, State#state{last_reductions = NLRPL}};
prd([RowData|Rest], #state{last_reductions = LRPL} = State, Acc) ->
Pid = proplists:get_value(pid, RowData),
LastReductions = case proplists:get_value(Pid, LRPL) of
undefined -> 0;
N -> N
end,
case (State#state.callback):row(RowData, LastReductions, State#state.cbstate) of
{ok, skip, NCBState} ->
prd(Rest, State#state{ cbstate = NCBState }, Acc);
{ok, Row, NCBState} ->
prd(Rest, State#state{ cbstate = NCBState }, [Row|Acc])
end.

sort(ProcList, State) ->
Expand Down
2 changes: 1 addition & 1 deletion src/leofs_doctor.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
%%======================================================================
{application, leofs_doctor,
[{description, "Quick investigation into OTP applications on remote nodes with less operations."},
{vsn, "0.4.0"},
{vsn, "0.4.2"},
{applications, [kernel, stdlib, yamerl, leofs_doctor]},
{mod, {leofs_doctor, []}},
{env, []}]}.
2 changes: 1 addition & 1 deletion src/leofs_doctor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
-export([start/1]).


-define(DEF_SORT_COL, 5).
-define(DEF_SORT_COL, 6).
-define(DEF_REVERSE, true).
-define(DEF_TOPN, 10).
-define(DEF_INTERVAL, 1).
Expand Down
4 changes: 3 additions & 1 deletion src/leofs_doctor.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
interval = 1 :: pos_integer(),
times = 1 :: pos_integer(),
root_sup :: atom(),
expected_svt = [] :: [term()]}).
expected_svt = [] :: [term()],
last_reductions = [] :: list()
}).
%% Defines
-define(PRINT(Str), io:format(user, Str, [])).
-define(PRINTF(FStr, Args), io:format(user, FStr, Args)).

0 comments on commit 4a7674f

Please sign in to comment.