Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'sm/fix-disksup-susv3/OTP-10945' into maint

* sm/fix-disksup-susv3/OTP-10945:
  This patch fixes disksup:get_disk_data for SUSv3, specifically OS X ML
  • Loading branch information...
commit 9e6214fb792adbe566bc0155c7050a07a531a825 2 parents c4011d1 + bdb135a
@gustehn gustehn authored
Showing with 22 additions and 2 deletions.
  1. +22 −2 lib/os_mon/src/disksup.erl
View
24 lib/os_mon/src/disksup.erl
@@ -275,8 +275,8 @@ check_disk_space({unix, sunos4}, Port, Threshold) ->
Result = my_cmd("df", Port),
check_disks_solaris(skip_to_eol(Result), Threshold);
check_disk_space({unix, darwin}, Port, Threshold) ->
- Result = my_cmd("/bin/df -k -t ufs,hfs", Port),
- check_disks_solaris(skip_to_eol(Result), Threshold).
+ Result = my_cmd("/bin/df -i -k -t ufs,hfs", Port),
+ check_disks_susv3(skip_to_eol(Result), Threshold).
% This code works for Linux and FreeBSD as well
check_disks_solaris("", _Threshold) ->
@@ -298,6 +298,26 @@ check_disks_solaris(Str, Threshold) ->
check_disks_solaris(skip_to_eol(Str),Threshold)
end.
+% Parse per SUSv3 specification, notably recent OS X
+check_disks_susv3("", _Threshold) ->
+ [];
+check_disks_susv3("\n", _Threshold) ->
+ [];
+check_disks_susv3(Str, Threshold) ->
+ case io_lib:fread("~s~d~d~d~d%~d~d~d%~s", Str) of
+ {ok, [_FS, KB, _Used, _Avail, Cap, _IUsed, _IFree, _ICap, MntOn], RestStr} ->
+ if
+ Cap >= Threshold ->
+ set_alarm({disk_almost_full, MntOn}, []);
+ true ->
+ clear_alarm({disk_almost_full, MntOn})
+ end,
+ [{MntOn, KB, Cap} |
+ check_disks_susv3(RestStr, Threshold)];
+ _Other ->
+ check_disks_susv3(skip_to_eol(Str),Threshold)
+ end.
+
%% Irix: like Linux with an extra FS type column and no '%'.
check_disks_irix("", _Threshold) -> [];
check_disks_irix("\n", _Threshold) -> [];
Please sign in to comment.
Something went wrong with that request. Please try again.