From 1b0da3cc58a430d96b34d326604141e2e12b3a2f Mon Sep 17 00:00:00 2001 From: DDDHuang <904897578@qq.com> Date: Mon, 6 Dec 2021 14:36:51 +0800 Subject: [PATCH] fix(alarm): alarm message with .2f format --- apps/emqx/src/emqx_os_mon.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/emqx/src/emqx_os_mon.erl b/apps/emqx/src/emqx_os_mon.erl index e0cfac7af..263035db5 100644 --- a/apps/emqx/src/emqx_os_mon.erl +++ b/apps/emqx/src/emqx_os_mon.erl @@ -96,8 +96,8 @@ handle_info({timeout, _Timer, check}, State) -> _ = case emqx_vm:cpu_util() of %% TODO: should be improved? 0 -> ok; Busy when Busy >= CPUHighWatermark -> - Usage = io_lib:format("~p%", [Busy]), - Message = [Usage, " cpu usage"], + Usage = list_to_binary(io_lib:format("~.2f%", [Busy])), + Message = <>, emqx_alarm:activate(high_cpu_usage, #{ usage => Usage, @@ -107,8 +107,8 @@ handle_info({timeout, _Timer, check}, State) -> Message), start_check_timer(); Busy when Busy =< CPULowWatermark -> - Usage = io_lib:format("~p%", [Busy]), - Message = [Usage, " cpu usage"], + Usage = list_to_binary(io_lib:format("~.2f%", [Busy])), + Message = <>, emqx_alarm:deactivate(high_cpu_usage, #{ usage => Usage,