bindings/erlang: Added example module.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 14 Nov 2009 10:38:37 +0000 (11:38 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 14 Nov 2009 10:38:37 +0000 (11:38 +0100)
bindings/erlang/cexample.erl [new file with mode: 0644]

diff --git a/bindings/erlang/cexample.erl b/bindings/erlang/cexample.erl
new file mode 100644 (file)
index 0000000..b27d8f3
--- /dev/null
@@ -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).