diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-11-25 16:34:08 +0000 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-11-25 16:34:08 +0000 |
| commit | a6dfa4a57a8022ee90614c9826d878ad32155728 (patch) | |
| tree | fc9a3e303cc2955190c182c3003459f9f6eb7951 /src | |
| parent | 7b8b7d2734c7c8759395c118c4896c1ec7ad394d (diff) | |
| download | rabbitmq-server-git-a6dfa4a57a8022ee90614c9826d878ad32155728.tar.gz | |
(kinda bug 22042) inline rabbit_misc:cmd seeing as it's not used elsewhere and we want to allow vm_memory_monitor to be used outside of rabbit
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_misc.erl | 10 | ||||
| -rw-r--r-- | src/vm_memory_monitor.erl | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index b9f9244263..97c96fc771 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -55,7 +55,7 @@ -export([append_file/2, ensure_parent_dirs_exist/1]). -export([format_stderr/2]). -export([start_applications/1, stop_applications/1]). --export([unfold/2, ceil/1, cmd/1]). +-export([unfold/2, ceil/1]). -export([sort_field_table/1]). -import(mnesia). @@ -127,7 +127,6 @@ -spec(stop_applications/1 :: ([atom()]) -> 'ok'). -spec(unfold/2 :: (fun ((A) -> ({'true', B, A} | 'false')), A) -> {[B], A}). -spec(ceil/1 :: (number()) -> number()). --spec(cmd/1 :: (string()) -> string()). -spec(sort_field_table/1 :: (amqp_table()) -> amqp_table()). -endif. @@ -496,10 +495,3 @@ ceil(N) -> %% Sorts a list of AMQP table fields as per the AMQP spec sort_field_table(Arguments) -> lists:keysort(1, Arguments). - -cmd(Command) -> - Exec = hd(string:tokens(Command, " ")), - case os:find_executable(Exec) of - false -> throw({command_not_found, Exec}); - _ -> os:cmd(Command) - end. diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl index 9eee0c0b8f..65d4a45103 100644 --- a/src/vm_memory_monitor.erl +++ b/src/vm_memory_monitor.erl @@ -223,13 +223,19 @@ get_mem_limit(MemFraction, TotalMemory) -> %%---------------------------------------------------------------------------- %% Internal Helpers %%---------------------------------------------------------------------------- +cmd(Command) -> + Exec = hd(string:tokens(Command, " ")), + case os:find_executable(Exec) of + false -> throw({command_not_found, Exec}); + _ -> os:cmd(Command) + end. %% get_total_memory(OS) -> Total %% Windows and Freebsd code based on: memsup:get_memory_usage/1 %% Original code was part of OTP and released under "Erlang Public License". get_total_memory({unix,darwin}) -> - File = rabbit_misc:cmd("/usr/bin/vm_stat"), + File = cmd("/usr/bin/vm_stat"), Lines = string:tokens(File, "\n"), Dict = dict:from_list(lists:map(fun parse_line_mach/1, Lines)), [PageSize, Inactive, Active, Free, Wired] = @@ -257,7 +263,7 @@ get_total_memory({unix, linux}) -> dict:fetch('MemTotal', Dict); get_total_memory({unix, sunos}) -> - File = rabbit_misc:cmd("/usr/sbin/prtconf"), + File = cmd("/usr/sbin/prtconf"), Lines = string:tokens(File, "\n"), Dict = dict:from_list(lists:map(fun parse_line_sunos/1, Lines)), dict:fetch('Memory size', Dict); @@ -308,7 +314,7 @@ parse_line_sunos(Line) -> end. freebsd_sysctl(Def) -> - list_to_integer(rabbit_misc:cmd("/sbin/sysctl -n " ++ Def) -- "\n"). + list_to_integer(cmd("/sbin/sysctl -n " ++ Def) -- "\n"). %% file:read_file does not work on files in /proc as it seems to get %% the size of the file first and then read that many bytes. But files |
