bindings/erlang: Added copyright and license header.
[collectd.git] / bindings / erlang / collectd.erl
1 % collectd - bindings/erlang/collectd.erl
2 % Copyright (C) 2009  Florian octo Forster
3
4 % This program is free software; you can redistribute it and/or modify it
5 % under the terms of the GNU General Public License as published by the
6 % Free Software Foundation; only version 2 of the License is applicable.
7
8 % This program is distributed in the hope that it will be useful, but
9 % WITHOUT ANY WARRANTY; without even the implied warranty of
10 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 % General Public License for more details.
12
13 % You should have received a copy of the GNU General Public License along
14 % with this program; if not, write to the Free Software Foundation, Inc.,
15 % 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
17 % Authors:
18 %   Florian octo Forster <octo at verplant.org>
19
20 -module(collectd).
21 -export([dispatch_values/1, register_read/1]).
22
23 -include("collectd.hrl").
24
25 dispatch_values (#value_list{} = VL) ->
26         call_cnode (dispatch_values, VL).
27
28 register_read (Callback) ->
29         call_cnode (register_read, Callback).
30
31 call_cnode(Func, Args) ->
32         {any, 'collectd@leeloo.lan.home.verplant.org'} ! {Func, Args},
33         receive
34                 { error, Message } ->
35                         io:format ("Function ~w failed: ~s~n", [Func, Message]),
36                         error;
37                 success ->
38                         success
39         end.