summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-04-09 13:29:16 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-04-09 13:29:16 +0100
commit6badfa64a071d66ba28c8049bca6f8465276a278 (patch)
treef9c491dda470b98b09e7e8f7331aac336566449d
parent11010df4c155accf9823947097272e405aff3636 (diff)
downloadrabbitmq-server-git-6badfa64a071d66ba28c8049bca6f8465276a278.tar.gz
Make sure we have complete command output if we actually can't parse it.
-rw-r--r--src/rabbit_disk_monitor.erl14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/rabbit_disk_monitor.erl b/src/rabbit_disk_monitor.erl
index ab4437802d..17d8e2f2e9 100644
--- a/src/rabbit_disk_monitor.erl
+++ b/src/rabbit_disk_monitor.erl
@@ -103,7 +103,7 @@ init([Limit]) ->
{ok, start_timer(set_disk_limits(State, Limit))};
Err ->
rabbit_log:info("Disabling disk free space monitoring "
- "on unsupported platform: ~p~n", [Err]),
+ "on unsupported platform:~n~p~n", [Err]),
{stop, unsupported_platform}
end.
@@ -188,10 +188,14 @@ get_disk_free(Dir, {unix, _}) ->
get_disk_free(Dir, {win32, _}) ->
parse_free_win32(rabbit_misc:os_cmd("dir /-C /W \"" ++ Dir ++ "\"")).
-parse_free_unix(CommandResult) ->
- [_, Stats | _] = string:tokens(CommandResult, "\n"),
- [_FS, _Total, _Used, Free | _] = string:tokens(Stats, " \t"),
- list_to_integer(Free) * 1024.
+parse_free_unix(Str) ->
+ case string:tokens(Str, "\n") of
+ [_, S | _] -> case string:tokens(S, " \t") of
+ [_, _, _, Free | _] -> list_to_integer(Free) * 1024;
+ _ -> exit({not_found, Str})
+ end;
+ _ -> exit({not_found, Str})
+ end.
parse_free_win32(CommandResult) ->
LastLine = lists:last(string:tokens(CommandResult, "\r\n")),