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
commit13522a2240c9ff9d32dc91b1518c4675df4db87e (patch)
treef9c491dda470b98b09e7e8f7331aac336566449d
parentfa99b2988412da8628f05bcd632de1ee5562d500 (diff)
downloadrabbitmq-server-13522a2240c9ff9d32dc91b1518c4675df4db87e.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 ab443780..17d8e2f2 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")),