From eb6e584beb4f48529914425d2fb74bee4603a0cb Mon Sep 17 00:00:00 2001 From: ATL <15815417+atl285@users.noreply.github.com> Date: Fri, 23 Aug 2019 10:06:47 +0200 Subject: [PATCH] fixes SMART Status "unknown" in the smart widget and more... (#1429) * fixes SMART Status "unknown" in the smart widget This fixes the "Unable to detect device typ" of smartctl, because it needs the full path to the device (e.g. /dev/ada0). As second it removes white space from start of $state variable before return, which let it match in the right way in the smart_status.widget.php. And as last the additional diskinfo command let the script skip devices, where disking exits with the error 'failed, probably not a disk.'. * replace device listing replace fixed device pattern with list of disk devices detected by kernel --- .../src/opnsense/scripts/OPNsense/Smart/detailed_list.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh b/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh index b4bac7d46..b0c64a945 100755 --- a/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh +++ b/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh @@ -27,12 +27,13 @@ result="" -for dev in `ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'`; do +for dev in `sysctl -a | grep -i kern.disks | awk -F: '{print $2}'`; do + /usr/sbin/diskinfo $dev >/dev/null 2>&1 || continue ident=`/usr/sbin/diskinfo -v $dev | grep ident | awk '{print $1}'`; state=`/usr/local/sbin/smartctl -jH /dev/$dev` if [ -n "$result" ]; then - result="$result,"; + result="$result,"; fi result="$result{\"device\":\"$dev\",\"ident\":\"$ident\",\"state\":$state}";