|
79 | 79 | %%----------------------------------------------------------------------------
|
80 | 80 |
|
81 | 81 | get_total_memory() ->
|
82 |
| - try |
83 |
| - get_total_memory(os:type()) |
84 |
| - catch _:Error -> |
85 |
| - rabbit_log:warning( |
86 |
| - "Failed to get total system memory: ~n~p~n~p~n", |
87 |
| - [Error, erlang:get_stacktrace()]), |
88 |
| - unknown |
| 82 | + case application:get_env(rabbit, total_memory_available_override_value) of |
| 83 | + {ok, Value} -> |
| 84 | + case rabbit_resource_monitor_misc:parse_information_unit(Value) of |
| 85 | + {ok, ParsedTotal} -> |
| 86 | + ParsedTotal; |
| 87 | + {error, parse_error} -> |
| 88 | + rabbit_log:warning( |
| 89 | + "The override value for the total memmory available is " |
| 90 | + "not a valid value: ~p, getting total from the system.~n", |
| 91 | + [Value]), |
| 92 | + get_total_memory_from_os() |
| 93 | + end; |
| 94 | + undefined -> |
| 95 | + get_total_memory_from_os() |
89 | 96 | end.
|
90 | 97 |
|
91 | 98 | get_vm_limit() -> get_vm_limit(os:type()).
|
@@ -164,6 +171,15 @@ code_change(_OldVsn, State, _Extra) ->
|
164 | 171 | %%----------------------------------------------------------------------------
|
165 | 172 | %% Server Internals
|
166 | 173 | %%----------------------------------------------------------------------------
|
| 174 | +get_total_memory_from_os() -> |
| 175 | + try |
| 176 | + get_total_memory(os:type()) |
| 177 | + catch _:Error -> |
| 178 | + rabbit_log:warning( |
| 179 | + "Failed to get total system memory: ~n~p~n~p~n", |
| 180 | + [Error, erlang:get_stacktrace()]), |
| 181 | + unknown |
| 182 | + end. |
167 | 183 |
|
168 | 184 | set_mem_limits(State, MemLimit) ->
|
169 | 185 | case erlang:system_info(wordsize) of
|
|
0 commit comments