From 7e0ac5bd3471fe7dfff1f4e8b1a8fd94e515cd12 Mon Sep 17 00:00:00 2001 From: tigercl Date: Wed, 8 May 2019 10:19:49 +0800 Subject: [PATCH] Fix bad config type of long_gc (#2504) --- etc/emqx.conf | 34 +++++++++++++++++++++++++++++----- priv/emqx.schema | 8 ++++---- src/emqx_sys_mon.erl | 11 +++++------ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index 0d6d5f3a9..df50884e9 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -2222,19 +2222,43 @@ broker.route_batch_clean = off ## System Monitor ##-------------------------------------------------------------------- -## Enable Long GC monitoring. +## Enable Long GC monitoring. Disable if the value is 0. ## Notice: don't enable the monitor in production for: ## https://github.com/erlang/otp/blob/feb45017da36be78d4c5784d758ede619fa7bfd3/erts/emulator/beam/erl_gc.c#L421 ## -## Value: true | false -sysmon.long_gc = false +## Value: Duration +## - h: hour +## - m: minute +## - s: second +## - ms: milliseconds +## +## Examples: +## - 2h: 2 hours +## - 30m: 30 minutes +## - 0.1s: 0.1 seconds +## - 100ms : 100 milliseconds +## +## Default: 0ms +sysmon.long_gc = 0 ## Enable Long Schedule(ms) monitoring. ## ## See: http://erlang.org/doc/man/erlang.html#system_monitor-2 ## -## Value: Number -sysmon.long_schedule = 240 +## Value: Duration +## - h: hour +## - m: minute +## - s: second +## - ms: milliseconds +## +## Examples: +## - 2h: 2 hours +## - 30m: 30 minutes +## - 0.1s: 0.1 seconds +## - 100ms: 100 milliseconds +## +## Default: 0ms +sysmon.long_schedule = 240ms ## Enable Large Heap monitoring. ## diff --git a/priv/emqx.schema b/priv/emqx.schema index 81f24884a..804ab041d 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -2074,14 +2074,14 @@ end}. %% @doc Long GC, don't monitor in production mode for: %% https://github.com/erlang/otp/blob/feb45017da36be78d4c5784d758ede619fa7bfd3/erts/emulator/beam/erl_gc.c#L421 {mapping, "sysmon.long_gc", "emqx.sysmon", [ - {default, false}, - {datatype, {enum, [true, false]}} + {default, 0}, + {datatype, [integer, {duration, ms}]} ]}. %% @doc Long Schedule(ms) {mapping, "sysmon.long_schedule", "emqx.sysmon", [ - {default, 1000}, - {datatype, integer} + {default, 240}, + {datatype, [integer, {duration, ms}]} ]}. %% @doc Large Heap diff --git a/src/emqx_sys_mon.erl b/src/emqx_sys_mon.erl index 03cc95819..b75503b53 100644 --- a/src/emqx_sys_mon.erl +++ b/src/emqx_sys_mon.erl @@ -33,9 +33,9 @@ , code_change/3 ]). --type(option() :: {long_gc, false | pos_integer()} - | {long_schedule, false | pos_integer()} - | {large_heap, pos_integer()} +-type(option() :: {long_gc, non_neg_integer()} + | {long_schedule, non_neg_integer()} + | {large_heap, non_neg_integer()} | {busy_port, boolean()} | {busy_dist_port, boolean()}). @@ -66,11 +66,11 @@ parse_opt(Opts) -> parse_opt(Opts, []). parse_opt([], Acc) -> Acc; -parse_opt([{long_gc, false}|Opts], Acc) -> +parse_opt([{long_gc, 0}|Opts], Acc) -> parse_opt(Opts, Acc); parse_opt([{long_gc, Ms}|Opts], Acc) when is_integer(Ms) -> parse_opt(Opts, [{long_gc, Ms}|Acc]); -parse_opt([{long_schedule, false}|Opts], Acc) -> +parse_opt([{long_schedule, 0}|Opts], Acc) -> parse_opt(Opts, Acc); parse_opt([{long_schedule, Ms}|Opts], Acc) when is_integer(Ms) -> parse_opt(Opts, [{long_schedule, Ms}|Acc]); @@ -177,4 +177,3 @@ safe_publish(Event, WarnMsg) -> sysmon_msg(Topic, Payload) -> Msg = emqx_message:make(?SYSMON, Topic, Payload), emqx_message:set_flag(sys, Msg). -