From 920283041b8753167d7c82f1e869450012bee1da Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchuk Date: Fri, 11 Oct 2024 13:06:10 +0300 Subject: [PATCH 1/2] Add files via upload Signed-off-by: Mykhailo Kravchuk --- smartmon.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/smartmon.sh b/smartmon.sh index c20a850..51fdc83 100755 --- a/smartmon.sh +++ b/smartmon.sh @@ -166,13 +166,12 @@ format_output() { awk -F'{' "${output_format_awk}" } -smartctl_version="$(/usr/sbin/smartctl -V | head -n1 | awk '$1 == "smartctl" {print $2}')" +smartctl_version="$(/usr/sbin/smartctl -V | awk 'NR==1 && $1 == "smartctl" {print $2}')" echo "smartctl_version{version=\"${smartctl_version}\"} 1" | format_output -if [[ "$(expr "${smartctl_version}" : '\([0-9]*\)\..*')" -lt 6 ]]; then - exit -fi +# Exit if "smartctl" version is lower 6 +[[ ${smartctl_version%.*} -lt 6 ]] && exit 0 device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')" From e93d84791c47132075a53fb07fe27b7913a29b9b Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchuk Date: Tue, 22 Oct 2024 23:16:40 +0300 Subject: [PATCH 2/2] Update smartmon.sh Co-authored-by: Daniel Swarbrick Signed-off-by: Mykhailo Kravchuk --- smartmon.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/smartmon.sh b/smartmon.sh index 51fdc83..9bc4e21 100755 --- a/smartmon.sh +++ b/smartmon.sh @@ -171,7 +171,9 @@ smartctl_version="$(/usr/sbin/smartctl -V | awk 'NR==1 && $1 == "smartctl" {prin echo "smartctl_version{version=\"${smartctl_version}\"} 1" | format_output # Exit if "smartctl" version is lower 6 -[[ ${smartctl_version%.*} -lt 6 ]] && exit 0 +if [[ ${smartctl_version%.*} -lt 6 ]]; then + exit 0 +fi device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')"