mirror of
https://github.com/opnsense/plugins.git
synced 2026-04-22 06:37:43 -04:00
sysutils/smart: use `smartctl --scan' as disk source; closes #3236
This commit is contained in:
parent
e9044ac811
commit
f37375f4b8
2 changed files with 4 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}]"
|
||||
|
|
|
|||
Loading…
Reference in a new issue