From: Florian Forster Date: Sat, 14 Nov 2009 10:38:37 +0000 (+0100) Subject: bindings/erlang: Added example module. X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=4d3ada0eaa0f8c522d1116e40068a0b84dd8ff4a bindings/erlang: Added example module. --- diff --git a/bindings/erlang/cexample.erl b/bindings/erlang/cexample.erl new file mode 100644 index 00000000..b27d8f35 --- /dev/null +++ b/bindings/erlang/cexample.erl @@ -0,0 +1,22 @@ +-module(cexample). +-export([my_init/0]). + +-include("collectd.hrl"). + +dispatch_reductions ({Total, _}) -> + collectd:dispatch_values (#value_list{host="localhost", plugin="erlang", + type="counter", type_instance="reductions", + values=[Total]}). + +dispatch_memory ({Type, Size}) -> + collectd:dispatch_values (#value_list{host="localhost", plugin="erlang", + type="memory", type_instance=atom_to_list (Type), + values=[Size]}). + +my_read() -> + dispatch_reductions (statistics (reductions)), + lists:foreach (fun dispatch_memory/1, erlang:memory()), + success. + +my_init() -> + collectd:register_read (fun my_read/0).