From f37375f4b8bf7ea20e9677d0bbeabb7ae97226ff Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 29 Jun 2023 09:29:45 +0200 Subject: [PATCH] sysutils/smart: use `smartctl --scan' as disk source; closes #3236 --- sysutils/smart/Makefile | 2 +- .../opnsense/scripts/OPNsense/Smart/detailed_list.sh | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sysutils/smart/Makefile b/sysutils/smart/Makefile index b0863f9fb..111cc3115 100644 --- a/sysutils/smart/Makefile +++ b/sysutils/smart/Makefile @@ -1,6 +1,6 @@ PLUGIN_NAME= smart PLUGIN_VERSION= 2.2 -PLUGIN_REVISION= 1 +PLUGIN_REVISION= 2 PLUGIN_COMMENT= SMART tools PLUGIN_DEPENDS= smartmontools PLUGIN_MAINTAINER= franco@opnsense.org 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 d8a3b55c1..73a2f6567 100755 --- a/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh +++ b/sysutils/smart/src/opnsense/scripts/OPNsense/Smart/detailed_list.sh @@ -27,21 +27,15 @@ RESULT= -for DEV in $(sysctl -n kern.disks); do +for DEV in $(smartctl --scan | awk '{ print $1 }'); do IDENT=$(/usr/sbin/diskinfo -s ${DEV}) - - if [ "${DEV#nvd}" != "${DEV}" ]; then - # the disk formerly know as nvdX - DEV="nvme${DEV#nvd}" - fi - - STATE=$(/usr/local/sbin/smartctl -jH /dev/${DEV}) + STATE=$(/usr/local/sbin/smartctl -jH ${DEV}) if [ -n "${RESULT}" ]; then RESULT="${RESULT},"; fi - RESULT="${RESULT}{\"device\":\"${DEV}\",\"ident\":\"${IDENT}\",\"state\":${STATE}}"; + RESULT="${RESULT}{\"device\":\"${DEV##/dev/}\",\"ident\":\"${IDENT}\",\"state\":${STATE}}"; done echo "[${RESULT}]"