Recon

Module recon_lib

Regroups useful functionality used by recon when dealing with data from the node.

Authors: Fred Hebert (mononcqc@ferd.ca) [web site: http://ferd.ca/].

Description

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.

Data Types

diff()

diff() = [recon:proc_attrs() | recon:inet_attrs()]

Function Index

count/1Takes a list of terms, and counts how often each of them appears in the list.
inet_attrs/1Returns the attributes (recon:inet_attrs()) of all inet ports (UDP, SCTP, TCP) of the node.
inet_attrs/2Returns the attributes required for a given inet port (UDP, SCTP, TCP).
port_list/1Returns a list of all the open ports in the VM, coupled with one of the properties desired from erlang:port_info/1-2.
port_list/2Returns a list of all the open ports in the VM, but only if the Attr's resulting value matches Val.
proc_attrs/1Returns the attributes (recon:proc_attrs()) of all processes of the node, except the caller.
proc_attrs/2Returns the attributes of a given process.
sample/2Runs a fun once, waits Ms, runs the fun again, and returns both results.
scheduler_usage_diff/2Diffs two runs of erlang:statistics(scheduler_wall_time) and returns usage metrics in terms of cores and 0..1 percentages.
sliding_window/2Compare two samples and return a list based on some key.
sublist_top_n_attrs/2Returns the top n element of a list of process or inet attributes.
term_to_pid/1Transforms a given term to a pid.
term_to_port/1Transforms a given term to a port.
time_fold/6Calls a given function every Interval milliseconds and supports a fold-like interface (each result is modified and accumulated).
time_map/5Calls a given function every Interval milliseconds and supports a map-like interface (each result is modified and returned).
triple_to_pid/3Equivalent of pid(X,Y,Z) in the Erlang shell.

Function Details

count/1

count(Terms::[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/1

inet_attrs(AttrName::term()) -> [recon:inet_attrs()]

Returns the attributes (recon:inet_attrs()) of all inet ports (UDP, SCTP, TCP) of the node.

inet_attrs/2

inet_attrs(AttributeName, Port::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/1

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-2.

port_list/2

port_list(Attr::atom(), Val::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/1

proc_attrs(AttrName::term()) -> [recon:proc_attrs()]

Returns the attributes (recon:proc_attrs()) of all processes of the node, except the caller.

proc_attrs/2

proc_attrs(AttrName::term(), Pid::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/2

sample(Ms::non_neg_integer(), Fun::fun(() -> term())) -> {First::term(), Second::term()}

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

scheduler_usage_diff/2

scheduler_usage_diff(SchedTime, SchedTime) -> undefined | [{SchedulerId, Usage}]

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

sliding_window/2

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.

sublist_top_n_attrs/2

sublist_top_n_attrs(List::[Attrs], Len::pos_integer()) -> [Attrs]

Returns the top n element of a list of process or inet attributes

term_to_pid/1

term_to_pid(Pid::recon:pid_term()) -> pid()

Transforms a given term to a pid.

term_to_port/1

term_to_port(Port::recon:port_term()) -> port()

Transforms a given term to a port

time_fold/6

time_fold(N, Interval, Fun, State, FoldFun, Init) -> [term()]

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

time_map/5

time_map(N, Interval, Fun, State, MapFun) -> [term()]

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

triple_to_pid/3

triple_to_pid(N, N, N) -> pid()

Equivalent of pid(X,Y,Z) in the Erlang shell.