Skip to content

Commit

Permalink
adding optional emission of some erlang vm stats
Browse files Browse the repository at this point in the history
  • Loading branch information
djnym committed Oct 28, 2015
1 parent 820691b commit 8533b7f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 5.5.0 (molinaro)
* vmstats can now be sent once a minute via mondemand when specified in the
application config file. A program id is required so a minimal config
might be something like
{ vmstats, [ { program_id, mondemand } ] }
in addition a context could be added via a context parameter with a
2-tuple list as an argument like
{ vmstats, [ { program_id, mondemand }, {context, [{foo,bar}]} ] }

Version 5.4.2 (molinaro)
* problem with context deserialization

Expand Down
3 changes: 2 additions & 1 deletion mondemand_dev.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{ mondemand, [
{ lwes_channel, { 1, [ { "127.0.0.1", 20602 } ] } } %,
{ lwes_channel, { 1, [ { "127.0.0.1", 20602 } ] } },
{ vmstats, [ { program_id, mondemand } ] }
% { lwes_channel, { 2, [{"127.0.0.1",20602}, {"172.16.107.128", 20602}] } } %,
% { config_file, "mondemand.conf" }
% { send_interval, 5 }
Expand Down
2 changes: 1 addition & 1 deletion src/mondemand.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ application, mondemand,
[
{ description, "Erlang Mondemand Bindings." },
{ vsn, "5.4.2" },
{ vsn, "5.5.0" },
{ modules, [] },
{ registered, [mondemand,mondemand_sup]},
{ applications, [kernel,stdlib,lwes]},
Expand Down
11 changes: 11 additions & 0 deletions src/mondemand.erl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ send_stats (ProgId, Context, Stats) ->
send_event (Event).

flush () ->
case application:get_env (mondemand, vmstats) of
{ok, L} when is_list (L) ->
case proplists:get_value (program_id, L) of
undefined -> ok;
ProgId ->
Context = proplists:get_value (context, L, []),
VmStats = mondemand_vmstats:to_mondemand (),
send_stats (ProgId, Context, VmStats)
end;
_ -> ok
end,
mondemand_statdb:flush (1, fun flush_one/1).

reset_stats () ->
Expand Down
24 changes: 14 additions & 10 deletions src/mondemand_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ init([]) ->

VMStatsChild =
case application:get_env (mondemand, vmstats) of
{ok, true} ->
[
{ mondemand_vmstats,
{mondemand_vmstats, start_link, []},
permanent,
2000,
worker,
[mondemand_vmstats]
}
];
{ok, L} when is_list (L) ->
case proplists:get_value (program_id, L) of
undefined -> [];
_ ->
[
{ mondemand_vmstats,
{mondemand_vmstats, start_link, []},
permanent,
2000,
worker,
[mondemand_vmstats]
}
]
end;
_ ->
[]
end,
Expand Down

0 comments on commit 8533b7f

Please sign in to comment.