Etop behaviour (Etop v0.7.0)
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.stopConfiguration
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.
Test if Etop is running.
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 log 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, &3}
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.
alive?()
Specs
alive?() :: boolean()
Test if Etop is running.
iex> Etop.alive?()
false
iex> Etop.start()
iex> Etop.alive?()
true child_spec(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 log 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, &3}
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, &3}
iex> Etop.monitor(:summary, [:load, :sys], 10.0, callback)
iex> Etop.monitors() == [{:summary, [:load, :sys], 10.0, callback}]
true noreply(state)
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, &3}))
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, &3}))
iex> Etop.remove_monitors()
iex> Etop.monitors()
[] reply(state, reply)
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 _, _, state -> %{state | reporting: true} end
iex> disable_callback = fn _, value, state ->
...> if value < 40.0, do: %{state | 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 \\ [])
Specs
start(keyword()) :: GenServer.on_start()
Start Etop Reporting.
statistics(item)
status()
Get the status of the server
status!()
stop()
Stop Etop Reporting.
Link to this section Callbacks
add_monitor(monitor_type, monitor_fields, any, monitor_callback)
Specs
add_monitor(monitor_type(), monitor_fields(), any(), monitor_callback()) :: no_return()
alive?()
Specs
alive?() :: boolean()
monitor(monitor_type, monitor_fields, any, monitor_callback)
Specs
monitor(monitor_type(), monitor_fields(), any(), monitor_callback()) :: no_return()
monitors()
Specs
monitors() :: [tuple()]
remove_monitors()
Specs
remove_monitors() :: any()
start(keyword)
Specs
start(keyword()) :: GenServer.on_start()
stop()
Specs
stop() :: any()