Etop (Etop v0.5.3)
A Top like implementation for Elixir Applications.
Usage
# Start with default options
ex> Etop.start()
# Temporarily pause/stop
ex> Etop.pause()
# Restart when paused
ex> Etop.start
# Start logging to an exs file
ex> Etop.start file: "/tmp/etop.exs"
# Load the current exs file
ex> data = Etop.load
# Start then change number of processes and interval between collecting results
ex> Etop.start
ex> Etop.set_opts nprocs: 15, interval: 15_000
# or
ex> Etop.start
ex> Etop.pause
ex> Etop.start nprocs: 15, interval: 15_000
# Stop Etop, killing its GenServer
ex> Etop.stop
Configuration
file
- Save the output to a file.format
- the output file format. Values [:text, :exs]interval (5000)
- the time (ms) between each runnprocs (10)
- the number of processes to listsort (reds_diff)
- the field to sort the process list. Values [:memory, :msgq, :reds, :reds_diff, :status, :default]
Link to this section Summary
Functions
Add a new monitor.
Add a new monitor to an Etop state map.
Returns a specification to start this module under a supervisor.
Restart Etop if its halted.
Callback implementation for GenServer.init/1
.
Load the current exs log file.
Load the given .exs file.
Set a monitor.
Get the current monitors.
Pause a running Etop session.
Remove a monitor.
Remove all monitors.
Enable or disable reporting.
Set Etop settings
Start Etop Reporting.
Get the status of the server
Stop Etop Reporting.
Link to this section Types
monitor()
Specs
monitor() :: {monitor_type(), monitor_fields(), any(), monitor_callback()}
monitor_callback()
Specs
monitor_fields()
Specs
monitor_type()
Specs
monitor_type() :: :process | :summary
monitors()
Specs
monitors() :: [monitor()]
Link to this section Functions
add_monitor(type, field, threshold, callback)
Specs
add_monitor(monitor_type(), monitor_fields(), any(), monitor_callback()) :: no_return()
Add a new monitor.
Adds the given monitor to any existing monitors.
Examples
iex> Etop.start()
iex> callback = &{&1, &2}
iex> Etop.monitor(:summary, [:load, :sys], 10.0, callback)
iex> Etop.add_monitor(:process, :reductions, 1000, callback)
iex> Etop.monitors() ==
...> [
...> {:process, :reductions, 1000, callback},
...> {:summary, [:load, :sys], 10.0, callback}
...> ]
true
add_monitor(state, type, field, threshold, callback)
Specs
add_monitor( %{monitors: monitors()}, monitor_type(), monitor_fields(), any(), monitor_callback() ) :: %{monitors: monitors()}
Add a new monitor to an Etop state map.
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
continue(opts \\ [])
Restart Etop if its halted.
init(opts)
Callback implementation for GenServer.init/1
.
load()
Load the current exs log file.
load(path)
Load the given .exs file.
monitor(type, field, threshold, callback)
Specs
monitor(monitor_type(), monitor_fields(), any(), monitor_callback()) :: no_return()
Set a monitor.
Replaces any existing monitors with the given monitor.
Examples
iex> Etop.start()
iex> callback = &{&1, &2}
iex> Etop.monitor(:summary, [:load, :sys], 10.0, callback)
iex> Etop.monitors() == [{:summary, [:load, :sys], 10.0, callback}]
true
monitor(state, type, field, threshold, callback)
Specs
monitor( %{monitors: monitors()}, monitor_type(), monitor_fields(), any(), monitor_callback() ) :: %{monitors: monitors()}
monitors()
Specs
monitors() :: [tuple()]
Get the current monitors.
Examples
iex> Etop.start()
iex> callback = &{&1, &2}
iex> Etop.monitor(:summary, [:load, :sys], 10.0, callback)
iex> Etop.monitors() == [{:summary, [:load, :sys], 10.0, callback}]
true
pause()
Pause a running Etop session.
remove_monitor(type, field, threshold)
Specs
remove_monitor(monitor_type(), monitor_fields(), any()) :: :ok | :not_found
Remove a monitor.
Examples
iex> Etop.start()
iex> Etop.monitor(:summary, [:load, :total], 10.0, &IO.inspect({&1, &2}))
iex> response = Etop.remove_monitor(:summary, [:load, :total], 10.0)
iex> {response, Etop.monitors()}
{:ok, []}
remove_monitors()
Remove all monitors.
Examples
iex> Etop.start()
iex> Etop.monitor(:summary, [:load, :total], 10.0, &IO.inspect({&1, &2}))
iex> Etop.remove_monitors()
iex> Etop.monitors()
[]
reporting(enable?)
Specs
reporting(boolean()) :: :ok | :already_reporting | :no_reporting
Enable or disable reporting.
Disabling reporting stops reporting printing or logging reports but keeps the Etop collecting data. This option can be used with a monitor to toggle logging when a threshold is reached.
Examples
iex> Etop.start()
iex> Etop.reporting(false)
:ok
iex> Etop.start()
iex> enable_callback = fn _, _ -> Etop.reporting(true) end
iex> disable_callback = fn _, value ->
...> if value < 40.0, do: Etop.reporting(false)
...> end
iex> Etop.monitor(:summary, [:load, :total], 50.0, enable_callback)
iex> Etop.add_monitor(:summary, [:load, :total], 40.0, disable_callback)
:ok
sanitize_info_result(info)
sanitize_stats(state, stats)
set_opts(opts)
Set Etop settings
start(opts \\ [])
Start Etop Reporting.
statistics(item)
status()
Get the status of the server
status!()
stop()
Stop Etop Reporting.