feat(system_monitor): Add system_monitor application
This commit is contained in:
parent
dfa45c909a
commit
9fbc247e29
|
@ -105,6 +105,10 @@ natively in the EMQ X node;<br>
|
|||
sc(ref("db"),
|
||||
#{ desc => "Settings of the embedded database."
|
||||
})}
|
||||
, {"system_monitor",
|
||||
sc(ref("system_monitor"),
|
||||
#{ desc => "Erlang process and application monitoring."
|
||||
})}
|
||||
] ++
|
||||
emqx_schema:roots(medium) ++
|
||||
emqx_schema:roots(low) ++
|
||||
|
@ -327,6 +331,64 @@ a crash dump
|
|||
)}
|
||||
];
|
||||
|
||||
fields("system_monitor") ->
|
||||
[ {"top_num_items",
|
||||
sc(non_neg_integer(),
|
||||
#{ mapping => "system_monitor.top_num_items"
|
||||
, default => 10
|
||||
, desc => "The number of top processes per monitoring group"
|
||||
})
|
||||
}
|
||||
, {"top_sample_interval",
|
||||
sc(emqx_schema:duration(),
|
||||
#{ mapping => "system_monitor.top_sample_interval"
|
||||
, default => "2s"
|
||||
, desc => "Specifies how often process top should be collected"
|
||||
})
|
||||
}
|
||||
, {"top_max_procs",
|
||||
sc(non_neg_integer(),
|
||||
#{ mapping => "system_monitor.top_max_procs"
|
||||
, default => 200000
|
||||
, desc => "Stop collecting data when the number of processes exceeds this value"
|
||||
})
|
||||
}
|
||||
, {"db_hostname",
|
||||
sc(string(),
|
||||
#{ mapping => "system_monitor.db_hostname"
|
||||
, desc => "Hostname of the postgres database that collects the data points"
|
||||
})
|
||||
}
|
||||
, {"db_port",
|
||||
sc(integer(),
|
||||
#{ mapping => "system_monitor.db_port"
|
||||
, default => 5432
|
||||
, desc => "Port of the postgres database that collects the data points"
|
||||
})
|
||||
}
|
||||
, {"db_username",
|
||||
sc(string(),
|
||||
#{ mapping => "system_monitor.db_username"
|
||||
, default => "system_monitor"
|
||||
, desc => "EMQX user name in the postgres database"
|
||||
})
|
||||
}
|
||||
, {"db_password",
|
||||
sc(binary(),
|
||||
#{ mapping => "system_monitor.db_password"
|
||||
, default => "system_monitor_password"
|
||||
, desc => "EMQX user password in the postgres database"
|
||||
})
|
||||
}
|
||||
, {"db_name",
|
||||
sc(string(),
|
||||
#{ mapping => "system_monitor.db_name"
|
||||
, default => "postgres"
|
||||
, desc => "Postgres database name"
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
fields("db") ->
|
||||
[ {"backend",
|
||||
sc(hoconsc:enum([mnesia, rlog]),
|
||||
|
|
|
@ -32,6 +32,7 @@ start() ->
|
|||
os:set_signal(sigterm, handle) %% default is handle
|
||||
end,
|
||||
ok = set_backtrace_depth(),
|
||||
start_sysmon(),
|
||||
ekka:start(),
|
||||
ok = print_otp_version_warning().
|
||||
|
||||
|
@ -54,3 +55,15 @@ print_otp_version_warning() ->
|
|||
?ULOG("WARNING: Running on Erlang/OTP version ~p. Recommended: 23~n",
|
||||
[?OTP_RELEASE]).
|
||||
-endif. % OTP_RELEASE > 22
|
||||
|
||||
start_sysmon() ->
|
||||
case application:get_env(system_monitor, db_hostname) of
|
||||
undefined ->
|
||||
%% If there is no sink for the events, there is no reason
|
||||
%% to run system_monitor_top, ignore it:
|
||||
ok;
|
||||
_ ->
|
||||
application:set_env(system_monitor, callback_mod, system_monitor_pg),
|
||||
_ = application:ensure_all_started(system_monitor, temporary),
|
||||
ok
|
||||
end.
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.3"}}}
|
||||
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.4"}}}
|
||||
, {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x
|
||||
, {system_monitor, {git, "https://github.com/klarna-incubator/system_monitor", {tag, "2.2.0"}}}
|
||||
, {getopt, "1.0.2"}
|
||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.15.0"}}}
|
||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.6"}}}
|
||||
|
|
|
@ -281,6 +281,7 @@ relx_apps(ReleaseType, Edition) ->
|
|||
, {emqx_plugin_libs, load}
|
||||
, {esasl, load}
|
||||
, observer_cli
|
||||
, system_monitor
|
||||
, emqx_http_lib
|
||||
, emqx_resource
|
||||
, emqx_connector
|
||||
|
|
Loading…
Reference in New Issue