Skip to content

Commit

Permalink
Merge pull request chrzaszcz#1 from benoitcnetwork/fix-upgrade
Browse files Browse the repository at this point in the history
Fix upgrade
  • Loading branch information
cstar committed Oct 16, 2014
2 parents 24a8bf0 + ce3b56b commit fc86805
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
{folsom, ".*", {git, "git://github.com/boundary/folsom.git", {branch, "master"}}}
]}.

{require_otp_vsn, "1[4567]"}.
{require_otp_vsn, "R14|R15|R16|17"}.
8 changes: 4 additions & 4 deletions src/alarms.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{application, alarms,
[
{description, "Alarm handler for systems using mnesia"},
{vsn, "0.1"},
{vsn, "0.1.1"},
{registered, []},
{applications, [
kernel,
Expand All @@ -12,9 +12,9 @@
{mod, {alarms_app, []}},
{env, [
{handlers, [alarms_basic_handler, alarms_folsom_handler]},
{{alarms_basic_handler, min_log_interval}, 30},
{{alarms_basic_handler, report}, info_report},
{{alarms_folsom_handler, history_size}, 1000},
{alarms_basic_handler, [{min_log_interval, 30},
{report, info_report}]},
{alarms_folsom_handler, [{history_size, 1000}]},
{long_gc, 10000},
{large_heap, 1000000}
]}
Expand Down
5 changes: 3 additions & 2 deletions src/alarms_basic_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ handle_alarm(AlarmType, Details, Alarms0, LogTS0) ->
{ok, T} ->
calendar:datetime_to_gregorian_seconds(TS) -
calendar:datetime_to_gregorian_seconds(T) >=
alarms_utils:get_cfg({?MODULE, min_log_interval});
alarms_utils:get_alarm_cfg(?MODULE,
min_log_interval);
error ->
true
end,
Expand All @@ -210,7 +211,7 @@ maybe_log(AlarmType, Count, Details) ->
[mnesia_up, mnesia_down |
?SYSTEM_MONITOR_ALARM_TYPES ++ ?NET_KERNEL_ALARM_TYPES]) of
true ->
Report = alarms_utils:get_cfg({?MODULE, report}),
Report = alarms_utils:get_alarm_cfg(?MODULE, report),
error_logger:Report([{alarm, AlarmType},
{count, Count},
{details, Details}]),
Expand Down
2 changes: 1 addition & 1 deletion src/alarms_folsom_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ get_alarm(AlarmType, Limit) ->
%%--------------------------------------------------------------------
init(_) ->
folsom:start(),
HistorySize = alarms_utils:get_cfg({?MODULE, history_size}),
HistorySize = alarms_utils:get_alarm_cfg(?MODULE, history_size),
lists:foreach(
fun(AlarmType) ->
folsom_metrics:new_spiral({alarm, AlarmType, summary}),
Expand Down
11 changes: 10 additions & 1 deletion src/alarms_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%%%-------------------------------------------------------------------
-module(alarms_utils).

-export([get_cfg/1, set_cfg/2, alarm_types/0, event_manager/0,
-export([get_cfg/1, set_cfg/2, get_alarm_cfg/2, alarm_types/0, event_manager/0,
now_epoch_usec/0, epoch_usec_to_local_time/1]).

-include("alarms.hrl").
Expand All @@ -22,6 +22,15 @@ get_cfg(Key) ->
set_cfg(Key, Val) ->
application:set_env(alarms, Key, Val).


get_alarm_cfg(Mod, Key) ->
case application:get_env(alarms, Mod) of
undefined -> undefined;
{ok, AlarmCfg} -> proplists:get_value(Key, AlarmCfg)
end.



alarm_types() ->
?ALARM_TYPES.

Expand Down

0 comments on commit fc86805

Please sign in to comment.