ReconLib

Regroups useful functionality used by recon when dealing with data from the node. The functions in this module allow quick runtime access to fancier behaviour than what would be done using recon module itself.

Summary

Functions

Takes a list of terms, and counts how often each of them appears in the list. The list returned is in no particular order

Returns the attributes (Recon.inet_attrs/0) of all inet ports (UDP, SCTP, TCP) of the node

Returns the attributes required for a given inet port (UDP, SCTP, TCP). This form of attributes is standard for most comparison functions for processes in recon

Returns a list of all the open ports in the VM, coupled with one of the properties desired from :erlang.port_info/1 and :erlang.port_info/2

Returns a list of all the open ports in the VM, but only if the attr’s resulting value matches val. attr must be a property accepted by :erlang.port_info/2

Returns the attributes (Recon.proc_attrs/0) of all processes of the node, except the caller

Returns the attributes of a given process. This form of attributes is standard for most comparison functions for processes in recon

Runs a fun once, waits ms, runs the fun again, and returns both results

Diffs two runs of :erlang.statistics(scheduler_wall_time) and returns usage metrics in terms of cores and 0..1 percentages

Compare two samples and return a list based on some key. The type mentioned for the structure is diff() ({key, val, other}), which is compatible with the Recon.proc_attrs() type

Transforms a given term to a pid

Transforms a given term to a port

Calls a given function every interval milliseconds and supports a fold-like interface (each result is modified and accumulated)

Calls a given function every interval milliseconds and supports a map-like interface (each result is modified and returned)

Equivalent of pid(x, y, z) in the Elixir’s iex shell

Types

interval_ms :: non_neg_integer
milliseconds :: non_neg_integer
sched_time :: {scheduler_id, active_time :: non_neg_integer, total_time :: non_neg_integer}
scheduler_id :: pos_integer

Functions

count(terms)

Specs

count([term]) :: [{term, count :: integer}]

Takes a list of terms, and counts how often each of them appears in the list. The list returned is in no particular order.

inet_attrs(attr_name)

Specs

inet_attrs(term) :: [Recon.inet_attrs]

Returns the attributes (Recon.inet_attrs/0) of all inet ports (UDP, SCTP, TCP) of the node.

inet_attrs(attr, port)

Specs

inet_attrs(Recon.inet_attri_name, port) ::
  {:ok, Recon.inet_attrs} |
  {:error, term}

Returns the attributes required for a given inet port (UDP, SCTP, TCP). This form of attributes is standard for most comparison functions for processes in recon.

port_list(attr)

Specs

port_list(attr :: atom) :: [{port, term}]

Returns a list of all the open ports in the VM, coupled with one of the properties desired from :erlang.port_info/1 and :erlang.port_info/2

port_list(attr, val)

Specs

port_list(attr :: atom, term) :: [port]

Returns a list of all the open ports in the VM, but only if the attr’s resulting value matches val. attr must be a property accepted by :erlang.port_info/2.

proc_attrs(attr_name)

Specs

proc_attrs(term) :: [Recon.proc_attrs]

Returns the attributes (Recon.proc_attrs/0) of all processes of the node, except the caller.

proc_attrs(attr_name, pid)

Specs

proc_attrs(term, pid) ::
  {:ok, Recon.proc_attrs} |
  {:error, term}

Returns the attributes of a given process. This form of attributes is standard for most comparison functions for processes in recon.

A special attribute is binary_memory, which will reduce the memory used by the process for binary data on the global heap.

sample(delay, fun)

Specs

sample(milliseconds, (() -> term)) :: {first :: term, second :: term}

Runs a fun once, waits ms, runs the fun again, and returns both results.

scheduler_usage_diff(first, last)

Specs

scheduler_usage_diff(sched_time, sched_time) :: [{scheduler_id, usage :: number}]

Diffs two runs of :erlang.statistics(scheduler_wall_time) and returns usage metrics in terms of cores and 0..1 percentages.

sliding_window(first, last)

Specs

sliding_window(first :: diff, last :: diff) :: diff

Compare two samples and return a list based on some key. The type mentioned for the structure is diff() ({key, val, other}), which is compatible with the Recon.proc_attrs() type.

term_to_pid(term)

Specs

term_to_pid(Recon.pid_term) :: pid

Transforms a given term to a pid.

term_to_port(term)

Specs

term_to_port(Recon.port_term) :: port

Transforms a given term to a port.

time_fold(n, interval, fun, state, fold_fun, init)

Specs

time_fold(n :: non_neg_integer, interval_ms, fun :: (state :: term -> {term, state :: term}), initial_state :: term, foldfun :: (term, acc0 :: term -> acc1 :: term), initial_acc :: term) :: [term]

Calls a given function every interval milliseconds and supports a fold-like interface (each result is modified and accumulated)

time_map(n, interval, fun, state, map_fun)

Specs

time_map(n :: non_neg_integer, interval_ms, fun :: (state :: term -> {term, state :: term}), initial_state :: term, mapfun :: (term -> term)) :: [term]

Calls a given function every interval milliseconds and supports a map-like interface (each result is modified and returned)

triple_to_pid(x, y, z)

Specs

triple_to_pid(non_neg_integer, non_neg_integer, non_neg_integer) :: pid

Equivalent of pid(x, y, z) in the Elixir’s iex shell.