forked from astro/erlang-collectd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.erl
30 lines (25 loc) · 806 Bytes
/
example.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-module(example).
-export([start/0, loop/0]).
start() ->
application:start(collectd),
collectd:add_server(1),
loop().
loop() ->
collectd:set_gauge(ps_count, erlang,
[erlang:system_info(process_count), erlang:system_info(schedulers_online)]),
collectd:inc_counter(counter, inc, [1]),
lists:foreach(fun({Type, Size}) ->
collectd:set_gauge(memory, Type, [Size])
end, erlang:memory()),
{RunTime, _} = erlang:statistics(runtime),
collectd:set_counter(cpu, runtime, [RunTime]),
{Reductions, _} = erlang:statistics(reductions),
collectd:set_counter(counter, reductions, [Reductions]),
collectd:set_gauge(queue_length, run_queue, [erlang:statistics(run_queue)]),
sleep(1000),
?MODULE:loop().
sleep(I) ->
receive
after I ->
ok
end.