|
81 | 81 | %%----------------------------------------------------------------------------
|
82 | 82 |
|
83 | 83 | get_total_memory() ->
|
84 |
| - try |
85 |
| - get_total_memory(os:type()) |
86 |
| - catch _:Error -> |
87 |
| - rabbit_log:warning( |
88 |
| - "Failed to get total system memory: ~n~p~n~p~n", |
89 |
| - [Error, erlang:get_stacktrace()]), |
90 |
| - unknown |
| 84 | + case application:get_env(rabbit, total_memory_available_override_value) of |
| 85 | + {ok, Value} -> |
| 86 | + case rabbit_resource_monitor_misc:parse_information_unit(Value) of |
| 87 | + {ok, ParsedTotal} -> |
| 88 | + ParsedTotal; |
| 89 | + {error, parse_error} -> |
| 90 | + rabbit_log:warning( |
| 91 | + "The override value for the total memmory available is " |
| 92 | + "not a valid value: ~p, getting total from the system.~n", |
| 93 | + [Value]), |
| 94 | + get_total_memory_from_os() |
| 95 | + end; |
| 96 | + undefined -> |
| 97 | + get_total_memory_from_os() |
91 | 98 | end.
|
92 | 99 |
|
93 | 100 | get_vm_limit() -> get_vm_limit(os:type()).
|
@@ -179,6 +186,15 @@ code_change(_OldVsn, State, _Extra) ->
|
179 | 186 | %%----------------------------------------------------------------------------
|
180 | 187 | %% Server Internals
|
181 | 188 | %%----------------------------------------------------------------------------
|
| 189 | +get_total_memory_from_os() -> |
| 190 | + try |
| 191 | + get_total_memory(os:type()) |
| 192 | + catch _:Error -> |
| 193 | + rabbit_log:warning( |
| 194 | + "Failed to get total system memory: ~n~p~n~p~n", |
| 195 | + [Error, erlang:get_stacktrace()]), |
| 196 | + unknown |
| 197 | + end. |
182 | 198 |
|
183 | 199 | set_mem_limits(State, MemLimit) ->
|
184 | 200 | case erlang:system_info(wordsize) of
|
|
0 commit comments