Skip to content

Commit a0c021f

Browse files
committed
Only start os_mon application on win32
`os_mon` is only used on `win32` systems, so there is no need to start it on `unix` systems. In addition, `os_mon` can pollute the log files with memory high watermark messages that can be confused with those emitted by RabbitMQ's memory monitor. At some point, RabbitMQ _should_ use `os_mon` for disk and memory monitoring, but that day is a ways away. On `win32` systems, enable `memsup` in the `os_mon` application environment before starting the `os_mon` app.
1 parent 88ea37b commit a0c021f

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

deps/rabbit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ define PROJECT_ENV
125125
]
126126
endef
127127

128-
LOCAL_DEPS = sasl os_mon inets compiler public_key crypto ssl syntax_tools xmerl
128+
LOCAL_DEPS = sasl inets compiler public_key crypto ssl syntax_tools xmerl
129129

130130
BUILD_DEPS = rabbitmq_cli
131131
DEPS = ranch cowlib rabbit_common amqp10_common rabbitmq_prelaunch ra sysmon_handler stdout_formatter recon redbug observer_cli osiris syslog systemd seshat horus khepri khepri_mnesia_migration cuttlefish gen_batch_server

deps/rabbit/src/rabbit_disk_monitor.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ init([Limit]) ->
139139
{unix, _} ->
140140
start_portprogram();
141141
{win32, _OSname} ->
142+
%% Note: os_mon is not automatically started as it is only
143+
%% used on win32 for the time being. Rather than start it
144+
%% on all systems, we start it here.
145+
ok = rabbit_misc:ensure_os_mon_memsup(),
142146
not_used
143147
end,
144148
State3 = State2#state{port=Port, os=OS},

deps/rabbit/src/vm_memory_monitor.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ init_state_by_os(State0 = #state{os_type = {unix, linux}, os_pid = OsPid}) ->
275275
PageSize = get_linux_pagesize(),
276276
ProcFile = io_lib:format("/proc/~ts/statm", [OsPid]),
277277
State0#state{page_size = PageSize, proc_file = ProcFile};
278+
init_state_by_os(State = #state{os_type = {win32, _}}) ->
279+
%% Note: os_mon is not automatically started as it is only
280+
%% used on win32 for the time being. Rather than start it
281+
%% on all systems, we start it here.
282+
ok = rabbit_misc:ensure_os_mon_memsup(),
283+
State;
278284
init_state_by_os(State) ->
279285
State.
280286

deps/rabbit_common/src/rabbit_misc.erl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
-export([remote_sup_child/2]).
9191
-export([for_each_while_ok/2, fold_while_ok/3]).
9292

93+
-export([ensure_os_mon_memsup/0]).
94+
9395
%% Horrible macro to use in guards
9496
-define(IS_BENIGN_EXIT(R),
9597
R =:= noproc; R =:= noconnection; R =:= nodedown; R =:= normal;
@@ -1615,3 +1617,12 @@ fold_while_ok(Fun, Acc0, [Elem | Rest]) ->
16151617
end;
16161618
fold_while_ok(_Fun, Acc, []) ->
16171619
{ok, Acc}.
1620+
1621+
ensure_os_mon_memsup() ->
1622+
ensure_os_mon_memsup(os:type()).
1623+
1624+
ensure_os_mon_memsup({win32, _}) ->
1625+
ok = application:set_env(os_mon, start_memsup, true),
1626+
ok = application:ensure_started(os_mon);
1627+
ensure_os_mon_memsup(_) ->
1628+
ok.

0 commit comments

Comments
 (0)