Skip to content

Commit

Permalink
V1.6.0 (#70)
Browse files Browse the repository at this point in the history
* 1.hidden schedule usage default;2.format by erlformat;3.add ps -o pcpu,pmem information

* bump to 1.6.0

* update clean/1 spec

* replace recon_alloc:memory/1 stat by active_task/context_switch/port_parallelism

* update system default interval from 1500 to 2000 (cost too many cpu)

* show Gc Words Reclaimed IO GC Total/Increments in Home view

* unuse ++

* adjust code style

* add github action

* update workflows path

* update workflows

* update document
  • Loading branch information
zhongwencool committed Oct 21, 2020
1 parent 2d3c446 commit 7f80ae4
Show file tree
Hide file tree
Showing 22 changed files with 2,289 additions and 1,236 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ otp_release:
- 22.0
- 20.1
- 19.3
- 18.3

env:
- PATH=$HOME/.cache/rebar3/bin/:$PATH
Expand Down
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Visualize Erlang/Elixir Nodes On The Command Line base on [recon](https://github
%% rebar.config
{deps, [observer_cli]}
%% erlang.mk
dep_observer_cli = hex 1.5.4
dep_observer_cli = hex 1.6.0
```
**Elixir**
```elixir
# mix.exs
def deps do
[{:observer_cli, "~> 1.5"}]
[{:observer_cli, "~> 1.6"}]
end
```
------------------
Expand Down Expand Up @@ -74,14 +74,6 @@ _build/dev/rel/example/bin/example rpc ":observer_cli.start"
----------------
### DEMO
<img src="https://user-images.githubusercontent.com/3116225/39091211-55554414-4622-11e8-8b28-bd3b5c7e17a6.jpg" width="100%" alt="Home"> </img>
<img src="https://user-images.githubusercontent.com/3116225/39091212-55870e22-4622-11e8-99e7-8e8c56223765.jpg" width="100%" alt="Network"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091213-55b9aaf8-4622-11e8-91ed-b37c04e20173.jpg" width="100%" alt="System"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091214-55eae91a-4622-11e8-95c2-bc514219b5d9.jpg" width="100%" alt="Ets"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091215-5637b4fc-4622-11e8-9639-99405318fc09.jpg" width="100%" alt="Mnesia"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091216-567ddab8-4622-11e8-8b32-db0f621d6b90.jpg" width="100%" alt="Application"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091217-57258844-4622-11e8-9b21-2a7d661bc623.jpg" width="100%" alt="Document"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091219-66ba0398-4622-11e8-81b1-f489251f111a.jpg" width="100%" alt="Process"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091218-6687caf4-4622-11e8-86c7-190c2106d41e.jpg" width="100%" alt="Port"></img>

### How to write your own plugin?
If you need to customize some of your internal metrics and integrate it into observer_ci,
Expand Down Expand Up @@ -203,6 +195,11 @@ Support F/B to page up/down.

----------------
### Changelog
- 1.6.0
- hidden schedule usage default
- format by erlformat
- add `ps -o pcpu,pmem,rss,vsz` information
- remove recon_alloc:memory/1 from `HOME`(too much cpu usage)
- 1.5.4
- Bump Recon to 2.5.1 for otp23 alloc compat.
- 1.5.2
Expand Down
40 changes: 20 additions & 20 deletions doc/overview.edoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to be used to assist DevOps people diagnose problems in production
nodes, included panels are:

== Home ==
<img src="https://user-images.githubusercontent.com/3116225/39091211-55554414-4622-11e8-8b28-bd3b5c7e17a6.jpg" width="100%" alt="Home"></img>
<img src="https://user-images.githubusercontent.com/3116225/96714573-ede2f280-13d4-11eb-999c-f2aedb0d6ab1.jpg" width="95%" alt="Home"></img>

<a href="http://erlang.org/doc/man/erlang.html#system_info-1" target="_blank" >erlang:system_info/1</a> returns specified information about the current system by below item. When the ratio is greater than 85%, it becomes red.
<table border="2">
Expand All @@ -30,16 +30,13 @@ nodes, included panels are:
<li><b>atom_limit</b>: `erl +t size' sets the maximum number of atoms the virtual machine can handle. Defaults to 1,048,576.</li>
</ul>

<a href="https://github.com/ferd/recon/blob/master/src/recon_alloc.erl#L162" target="_blank" >recon:memory/1</a> reports memory values for the entire node depending on what is to be reported.
<a href="https://man7.org/linux/man-pages/man1/ps.1.html" target="_blank" > PS </a> report a snapshot of the beam process.
<table border="2">
<tr>
<td> allocated </td> <td>the memory that is reserved by the VM,includes the memory used, but also the memory yet-to-be-used but still given by the OS.</td>
<td> ps -o pcpu </td> <td>cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. .</td>
</tr>
<tr>
<td> used </td> <td>the memory that is actively used for allocated Erlang data.</td>
</tr>
<tr>
<td> unused </td> <td>the amount of memory reserved by the VM that is not being allocated. Equivalent to `allocated - used'.</td>
<td> ps -o pmem </td> <td>ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage.</td>
</tr>
</table>

Expand Down Expand Up @@ -68,19 +65,22 @@ nodes, included panels are:
<a href="http://erlang.org/doc/man/erlang.html#statistics-1" target="_blank" >erlang:statistics/1</a>
<table border="2">
<tr>
<td> reductions </td> <td>Reductions Since Last Call, The reductions of growth during the refresh interval.</td>
<td> active task </td> <td> returns the same as statistics(active_tasks_all) with the exception that no information about the dirty IO run queue and its associated schedulers is part of the result. That is, only tasks that are expected to be CPU bound are part of the result. </td>
</tr>
<tr>
<td> context switches </td> <td> returns the total number of context switches since the system started. </td>
</tr>
<tr>
<td> run_queue </td> <td>The total length of all normal run-queues. That is, the number of processes and ports that are ready to run on all available normal run-queues. Dirty run queues are not part of the result.</td>
<td> reductions(total/sinceLastCall) </td> <td>total reductions/reductions since last call.</td>
</tr>
<tr>
<td> io </td> <td>The receive/send bytes through ports of growth during the refresh interval. It's different from `erlang:statistcs(io)' which is the total number of bytes received/send through ports.</td>
<td> io </td> <td>The total number of bytes received/send through ports and the receive/send bytes through ports of growth during the refresh interval.</td>
</tr>
<tr>
<td> garbage_collection </td> <td>The `{Number_of_GCs, Words_Reclaimed}' of growth during the refresh interval. It's different from `erlang:statistcs(garbage_collection)' which is return total value.</td>
<td> garbage_collection </td> <td>`erlang:statistcs(garbage_collection)' which is return total value and the `{Number_of_GCs, Words_Reclaimed}' of growth during the refresh interval.</td>
</tr>
<tr>
<td> ErrorLoggerQueue </td> <td>The `error_logger' process message queue length. it will take its sweet time to log things to disk or over the network, and will do so much more slowly than errors can be generated.</td>
<td>run_queue</td> <td>The total length of all normal run-queues. That is, the number of processes and ports that are ready to run on all available normal run-queues. Dirty run queues are not part of the result.</td>
</tr>
</table>
Increments are values that are mostly useful when compared to a previous
Expand Down Expand Up @@ -111,7 +111,7 @@ ratio.
When looking for high memory usage, for example it's interesting to be able to list all
of a node's processes and find the top N consumers. Enter `m' then press `Enter' will use the
`recon:proc_count(memory, N)' function, we can get:
<img src="https://user-images.githubusercontent.com/3116225/39963461-0e3e0dfe-569e-11e8-879a-5d652a79df54.jpg" width="100%" alt="Top"> </img>
<img src="https://user-images.githubusercontent.com/3116225/96717499-25539e00-13d9-11eb-85af-fdde633da098.jpg" width="95%" alt="Top"> </img>
<a href="http://ferd.github.io/recon/recon.html#proc_count-2" target="_blank" >recon:proc_count/2</a>
and <a href="http://ferd.github.io/recon/recon.html#proc_window-3" target="_blank" >recon:proc_window/3</a>
are to be used when you require information about processes in a larger sense:
Expand All @@ -123,7 +123,7 @@ More detail about sliding time windows see <a href="http://ferd.github.io/recon/
When an abnormal process is found, enter the suspected process sequence(Integer) then press `Enter' will use
<a href="http://erlang.org/doc/man/erlang.html#process_info-2" target="_blank" > erlang:process_info/2</a> to show
a lot of information available(which is safe to use in production) about processes.
<img src="https://user-images.githubusercontent.com/3116225/39091219-66ba0398-4622-11e8-81b1-f489251f111a.jpg" width="100%" alt="Process"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091219-66ba0398-4622-11e8-81b1-f489251f111a.jpg" width="95%" alt="Process"></img>
<ul>
<li>
<b>registered_name</b>: if the process has a name (as registered with `erlang:register/2'), it is given here.
Expand Down Expand Up @@ -186,7 +186,7 @@ a lot of information available(which is safe to use in production) about process

== Network ==

<img src="https://user-images.githubusercontent.com/3116225/39091212-55870e22-4622-11e8-99e7-8e8c56223765.jpg" width="100%" alt="Network"></img>
<img src="https://user-images.githubusercontent.com/3116225/96717492-2389da80-13d9-11eb-9795-0f77ee441329.jpg" width="95%" alt="Network"></img>
<ul>
<li>
<b>Byte input/output</b>: The byte of growth input/output during the refresh interval.
Expand Down Expand Up @@ -218,7 +218,7 @@ When find out who is slowly but surely eating up all your bandwidth,
enter the suspected port sequence(Integer) then press `Enter' will use
<a href="http://ferd.github.io/recon/recon.html#port_info-2" target="_blank"> recon:port_info/2</a>
to show a lot of information available about port.
<img src="https://user-images.githubusercontent.com/3116225/39091218-6687caf4-4622-11e8-86c7-190c2106d41e.jpg" width="100%" alt="Port"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091218-6687caf4-4622-11e8-86c7-190c2106d41e.jpg" width="95%" alt="Port"></img>
<ul>
<li>
<b>id</b>: internal index of a port. Of no particular use except to differentiate ports.
Expand Down Expand Up @@ -256,7 +256,7 @@ a list of all local address/port number pairs for a socket.

== System ==

<img src="https://user-images.githubusercontent.com/3116225/39091213-55b9aaf8-4622-11e8-91ed-b37c04e20173.jpg" width="100%" alt="System"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091213-55b9aaf8-4622-11e8-91ed-b37c04e20173.jpg" width="95%" alt="System"></img>

<ul>
<li>
Expand All @@ -273,7 +273,7 @@ Cache can be tweaked using three VM flags: `+MMmcs', `+MMrmcbf', and `+MMamcbf'.

== ETS ==

<img src="https://user-images.githubusercontent.com/3116225/39091214-55eae91a-4622-11e8-95c2-bc514219b5d9.jpg" width="100%" alt="Ets"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091214-55eae91a-4622-11e8-95c2-bc514219b5d9.jpg" width="95%" alt="Ets"></img>
ETS tables are never garbage collected, and will maintain their memory usage as long as
records will be left undeleted in a table. Only removing records manually (or deleting the
table) will reclaim memory.
Expand All @@ -282,13 +282,13 @@ Top N list sort by memory size, all items defined in <a href="http://erlang.org/

== Mnesia ==

<img src="https://user-images.githubusercontent.com/3116225/39091215-5637b4fc-4622-11e8-9639-99405318fc09.jpg" width="100%" alt="Mnesia"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091215-5637b4fc-4622-11e8-9639-99405318fc09.jpg" width="95%" alt="Mnesia"></img>

Top N list sort by memory size, all items defined in <a href="http://erlang.org/doc/man/mnesia.html#table_info-2" target="_blank">mnesia:table_info/2</a>

== Application ==

<img src="https://user-images.githubusercontent.com/3116225/39091216-567ddab8-4622-11e8-8b32-db0f621d6b90.jpg" width="100%" alt="Application"></img>
<img src="https://user-images.githubusercontent.com/3116225/39091216-567ddab8-4622-11e8-8b32-db0f621d6b90.jpg" width="95%" alt="Application"></img>

Find application debug information by
<a href="https://github.com/erlang/otp/blob/master/lib/kernel/src/application_controller.erl#L280" target="_blank"> application_controller:info()</a>.
Expand Down
61 changes: 30 additions & 31 deletions include/observer_cli.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,71 @@

-define(MIN_INTERVAL, 1000).
-define(DEFAULT_INTERVAL, 1500).
-define(DISABLE, disable).
-define(ENABLE, enable).

-record(home, {func = proc_count :: atom(),
-record(home, {
func = proc_count :: atom(),
type = memory :: atom(),
cur_page = 1 :: pos_integer(),
pages = [{1,1}] :: list(),
interval = ?DEFAULT_INTERVAL :: pos_integer()}).
pages = [{1, 1}] :: list(),
interval = ?DEFAULT_INTERVAL :: pos_integer(),
scheduler_usage = application:get_env(observer_cli, scheduler_usage, ?DISABLE) ::
?DISABLE | ?ENABLE
}).

-record(ets, {
interval = 2000 :: integer(),
attr = memory :: atom(),
cur_page = 1 :: integer()}).
-record(system, {interval = ?DEFAULT_INTERVAL :: integer()}).
cur_page = 1 :: integer()
}).

-record(system, {interval = 2000 :: integer()}).

-record(db, {
interval = ?DEFAULT_INTERVAL :: integer(),
hide_sys = true :: boolean(),
cur_page = 1 :: integer(),
attr = memory :: atom()
}).
}).

-record(help, {interval = ?DEFAULT_INTERVAL :: integer()}).
-record(inet, {
interval = ?DEFAULT_INTERVAL :: integer(),
func = inet_count :: atom(),
type = cnt :: atom(),
cur_page = 1 :: pos_integer(),
pages = [{1,1}] :: list()}).
pages = [{1, 1}] :: list()
}).

-record(process, {interval = ?DEFAULT_INTERVAL :: integer()}).

%% [%{
%% module => atom(),
%% title => string(),
%% width => pos_integer(),
%% shortcut => string(),
%% interval => pos_integer(),
%% cur_page => pos_integer(),
%% sort_row => pos_integer()
%% }]
-record(plug, {cur_index = 1 ::pos_integer(), plugs = [] ::map()|[]}).

-record(view_opts, {home = #home{} :: home(),
-record(plug, {cur_index = 1 :: pos_integer(), plugs = [] :: map() | []}).

-record(view_opts, {
home = #home{} :: home(),
ets = #ets{} :: ets(),
sys = #system{} :: system(),
db = #db{} :: db(),
help = #help{} :: help(),
inet = #inet{} :: inet(),
process = #process{} :: process(),
port = ?DEFAULT_INTERVAL :: pos_integer(),
plug = #plug{} ::plug(),
plug = #plug{} :: plug(),
auto_row = true :: boolean()
}).

-export_type([view_opts/0]).

-type(view_opts() :: #view_opts{}).
-type(home() :: #home{}).
-type(system() :: #system{}).
-type(ets() :: #ets{}).
-type(db() :: #db{}).
-type(help() :: #help{}).
-type(inet() :: #inet{}).
-type(process() :: #process{}).
-type(plug() :: #plug{}).
-type view_opts() :: #view_opts{}.
-type home() :: #home{}.
-type system() :: #system{}.
-type ets() :: #ets{}.
-type db() :: #db{}.
-type help() :: #help{}.
-type inet() :: #inet{}.
-type process() :: #process{}.
-type plug() :: #plug{}.

-define(CURSOR_TOP, <<"\e[H">>).
-define(CLEAR, <<"\e[H\e[J">>).
Expand Down Expand Up @@ -97,5 +98,3 @@
-define(render(_FA_), observer_cli_lib:render(_FA_)).
-define(output(_F_, _A_), io:format(iolist_to_binary(_F_), _A_)).
-define(output(_L_), ?output(_L_, [])).


2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ObserverCli.MixProject do
def project do
[
app: :observer_cli,
version: "1.5.4",
version: "1.6.0",
language: :erlang,
description: "observer in shell",
deps: [
Expand Down
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%{
"recon": {:hex, :recon, "2.5.1", "430ffa60685ac1efdfb1fe4c97b8767c92d0d92e6e7c3e8621559ba77598678a", [:mix, :rebar3], [], "hexpm"},
}
7 changes: 7 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@
{escript_emu_args, "%%! -escript main observer_cli_escriptize -hidden -proto_dist inet6_tcp +sbtu +A0 -elixir ansi_enabled true\n"}
]}
]}.

{project_plugins, [rebar3_format, erlfmt]}.
{format, [
{files, ["src/*.erl", "include/*.hrl"]},
{formatter, erlfmt_formatter}, %% The erlfmt formatter interface.
{options, #{print_width => 100, ignore_pragma => true}} %% ...or no options at all.
]}.
6 changes: 4 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{"1.1.0",
{"1.2.0",
[{<<"recon">>,{pkg,<<"recon">>,<<"2.5.1">>},0}]}.
[
{pkg_hash,[
{<<"recon">>, <<"430FFA60685AC1EFDFB1FE4C97B8767C92D0D92E6E7C3E8621559BA77598678A">>}]}
{<<"recon">>, <<"430FFA60685AC1EFDFB1FE4C97B8767C92D0D92E6E7C3E8621559BA77598678A">>}]},
{pkg_hash_ext,[
{<<"recon">>, <<"5721C6B6D50122D8F68CCCAC712CAA1231F97894BAB779EFF5FF0F886CB44648">>}]}
].
61 changes: 32 additions & 29 deletions src/observer_cli.app.src
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
{application, observer_cli,
[
{description, "Visualize Erlang Nodes On The Command Line"},
{vsn, "1.5.4"},
{modules, [
observer_cli
]},
{registered, []},
{applications, [
kernel,
stdlib,
recon
]},
{files, ["include",
[
{description, "Visualize Erlang Nodes On The Command Line"},
{vsn, "1.6.0"},
{modules, [
observer_cli
]},
{registered, []},
{applications, [
kernel,
stdlib,
recon
]},
{files, ["include",
"LICENSE*",
"mix.exs",
"mix.lock",
"README.md",
"rebar.config",
"rebar.lock",
"src"]},
{build_tools, ["mix", "rebar3"]},
{env, [{plugins,
[
%% module - Specific module implements plugin behavior. It's mandatory.
%% title - Menu title. It's mandatory.
%% shortcut - Switch plugin by shortcut. It's mandatory.
%% interval - Refresh interval ms. It's options. default is 1500ms.
%% sort_column - Sort the sheet by this index. It's options default is 2.

%% #{module => observer_cli_plug_1, title => "Example-1", interval => 1500, shortcut => "S", sort_column => 3},
%% #{module => observer_cli_plug_2, title => "Example-2", interval => 1600, shortcut => "D", sort_column => 2}
]}
]},
{licenses, ["MIT"]},
{links, [{"Github", "https://github.com/zhongwencool/observer_cli"}]}
]}.
{build_tools, ["mix", "rebar3"]},
{env, [
{scheduler_usage, disable},
{plugins,
[
%% module - Specific module implements plugin behavior. It's mandatory.
%% title - Menu title. It's mandatory.
%% shortcut - Switch plugin by shortcut. It's mandatory.
%% interval - Refresh interval ms. It's options. default is 1500ms.
%% sort_column - Sort the sheet by this index. It's options default is 2.

%% #{module => observer_cli_plug_1, title => "Example-1", interval => 1500, shortcut => "S", sort_column => 3},
%% #{module => observer_cli_plug_2, title => "Example-2", interval => 1600, shortcut => "D", sort_column => 2}
]}
]},
{licenses, ["MIT"]},
{links, [{"Github", "https://github.com/zhongwencool/observer_cli"}]}
]}.
Loading

0 comments on commit 7f80ae4

Please sign in to comment.