b27d8f359ddc5e7106bf70b2033a48198ec8fa05
[collectd.git] / bindings / erlang / cexample.erl
1 -module(cexample).
2 -export([my_init/0]).
3
4 -include("collectd.hrl").
5
6 dispatch_reductions ({Total, _}) ->
7         collectd:dispatch_values (#value_list{host="localhost", plugin="erlang",
8                         type="counter", type_instance="reductions",
9                         values=[Total]}).
10
11 dispatch_memory ({Type, Size}) ->
12         collectd:dispatch_values (#value_list{host="localhost", plugin="erlang",
13                         type="memory", type_instance=atom_to_list (Type),
14                         values=[Size]}).
15
16 my_read() ->
17         dispatch_reductions (statistics (reductions)),
18         lists:foreach (fun dispatch_memory/1, erlang:memory()),
19         success.
20
21 my_init() ->
22         collectd:register_read (fun my_read/0).