commit
e79c714ec4
|
@ -92,7 +92,7 @@ publish(Msg = #mqtt_message{from = From}) ->
|
||||||
{ok, Msg1 = #mqtt_message{topic = Topic}} ->
|
{ok, Msg1 = #mqtt_message{topic = Topic}} ->
|
||||||
emqttd_pubsub:publish(Topic, Msg1);
|
emqttd_pubsub:publish(Topic, Msg1);
|
||||||
{stop, Msg1} ->
|
{stop, Msg1} ->
|
||||||
lager:warning("Stop publishing: ~s", [emqttd_message:format(Msg1)]),
|
lager:info("Stop publishing: ~s", [emqttd_message:format(Msg1)]),
|
||||||
ignore
|
ignore
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ setstat(Stat, Val) ->
|
||||||
ets:update_element(?STATS_TAB, Stat, {2, Val}).
|
ets:update_element(?STATS_TAB, Stat, {2, Val}).
|
||||||
|
|
||||||
%% @doc Set stats with max
|
%% @doc Set stats with max
|
||||||
-spec(setstats(Stat :: atom(), MaxStat :: atom(), Val :: pos_integer()) -> boolean()).
|
-spec(setstats(Stat :: atom(), MaxStat :: atom(), Val :: pos_integer()) -> ok).
|
||||||
setstats(Stat, MaxStat, Val) ->
|
setstats(Stat, MaxStat, Val) ->
|
||||||
gen_server:cast(?MODULE, {setstats, Stat, MaxStat, Val}).
|
gen_server:cast(?MODULE, {setstats, Stat, MaxStat, Val}).
|
||||||
|
|
||||||
|
|
|
@ -156,9 +156,9 @@ microsecs() ->
|
||||||
(Mega * 1000000 + Sec) * 1000000 + Micro.
|
(Mega * 1000000 + Sec) * 1000000 + Micro.
|
||||||
|
|
||||||
loads() ->
|
loads() ->
|
||||||
[{load1, ftos(cpu_sup:avg1()/256)},
|
[{load1, ftos(avg1()/256)},
|
||||||
{load5, ftos(cpu_sup:avg5()/256)},
|
{load5, ftos(avg5()/256)},
|
||||||
{load15, ftos(cpu_sup:avg15()/256)}].
|
{load15, ftos(avg15()/256)}].
|
||||||
|
|
||||||
get_system_info() ->
|
get_system_info() ->
|
||||||
[{Key, format_system_info(Key, get_system_info(Key))} || Key <- ?SYSTEM_INFO].
|
[{Key, format_system_info(Key, get_system_info(Key))} || Key <- ?SYSTEM_INFO].
|
||||||
|
@ -427,3 +427,27 @@ mapping([{owner, V}|Entries], Acc) when is_pid(V) ->
|
||||||
mapping([{Key, Value}|Entries], Acc) ->
|
mapping([{Key, Value}|Entries], Acc) ->
|
||||||
mapping(Entries, [{Key, Value}|Acc]).
|
mapping(Entries, [{Key, Value}|Acc]).
|
||||||
|
|
||||||
|
avg1() ->
|
||||||
|
case cpu_sup:avg1() of
|
||||||
|
SystemLoad when is_integer(SystemLoad) ->
|
||||||
|
SystemLoad;
|
||||||
|
{error, Reason} ->
|
||||||
|
lager:error("Get the average system load in the last minute fail for ~p~n", [Reason]),
|
||||||
|
0.00
|
||||||
|
end.
|
||||||
|
avg5() ->
|
||||||
|
case cpu_sup:avg5() of
|
||||||
|
SystemLoad when is_integer(SystemLoad) ->
|
||||||
|
SystemLoad;
|
||||||
|
{error, Reason} ->
|
||||||
|
lager:error("Get the average system load in the last 5 minutes fail for ~p~n", [Reason]),
|
||||||
|
0.00
|
||||||
|
end.
|
||||||
|
avg15() ->
|
||||||
|
case cpu_sup:avg15() of
|
||||||
|
SystemLoad when is_integer(SystemLoad) ->
|
||||||
|
SystemLoad;
|
||||||
|
{error, Reason} ->
|
||||||
|
lager:error("Get the average system load in the last 15 minutes fail for ~p~n", [Reason]),
|
||||||
|
0.00
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue