Skip to content

Commit

Permalink
Removing extra shell command; Use bash builtin for extracting a subst…
Browse files Browse the repository at this point in the history
…ring (prometheus-community#221)

Removing extra shell command; Use bash builtin for extracting a
substring

Signed-off-by: Mykhailo Kravchuk <michael.ua@gmail.com>
  • Loading branch information
mvk15 authored and allamiro committed Nov 16, 2024
1 parent 335fb4c commit 57bc4e0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions smartmon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ 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
# Exit if "smartctl" version is lower 6
if [[ ${smartctl_version%.*} -lt 6 ]]; then
exit 0
fi

device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')"
Expand Down

0 comments on commit 57bc4e0

Please sign in to comment.