File 0145-replace-hardcoded-path-for-df-with-os-find_executabl.patch of Package erlang
From 71d5b36a0ab9e6558c5e88552461a07afd355a20 Mon Sep 17 00:00:00 2001
From: Taras Halturin <halturin@gmail.com>
Date: Thu, 8 Oct 2020 19:23:59 +0200
Subject: [PATCH 2/2] replace hardcoded path for 'df' with os:find_executable
---
lib/os_mon/src/disksup.erl | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lib/os_mon/src/disksup.erl b/lib/os_mon/src/disksup.erl
index f3e1211eaf..d1685b0054 100644
--- a/lib/os_mon/src/disksup.erl
+++ b/lib/os_mon/src/disksup.erl
@@ -228,6 +228,19 @@ newline([13|_], B) -> {ok, lists:reverse(B)};
newline([H|T], B) -> newline(T, [H|B]);
newline([], B) -> {more, B}.
+%%-- Looking for Cmd location ------------------------------------------
+find_cmd(Cmd) ->
+ os:find_executable(Cmd).
+
+find_cmd(Cmd, Path) ->
+ %% try to find it at the specific location
+ case os:find_executable(Cmd, Path) of
+ false ->
+ find_cmd(Cmd);
+ Found ->
+ Found
+ end.
+
%%--Check disk space----------------------------------------------------
check_disk_space({win32,_}, not_used, Threshold) ->
@@ -240,7 +253,8 @@ check_disk_space({unix, irix}, Port, Threshold) ->
Result = my_cmd("/usr/sbin/df -lk",Port),
check_disks_irix(skip_to_eol(Result), Threshold);
check_disk_space({unix, linux}, Port, Threshold) ->
- Result = my_cmd("/usr/bin/env df -lk -x squashfs", Port),
+ Df = find_cmd("df", "/bin"),
+ Result = my_cmd(Df ++ " -lk -x squashfs", Port),
check_disks_solaris(skip_to_eol(Result), Threshold);
check_disk_space({unix, posix}, Port, Threshold) ->
Result = my_cmd("df -k -P", Port),
--
2.26.2