mirror of
https://github.com/Spearfoot/FreeNAS-scripts
synced 2025-12-06 01:23:19 +00:00
POSIX-compliant version
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
# Display current temperature of all SMART-enabled drives
|
||||
|
||||
@@ -16,18 +16,13 @@
|
||||
# 3. A smartctl-based function:
|
||||
get_smart_drives()
|
||||
{
|
||||
local gs_smartdrives
|
||||
local gs_drives
|
||||
local gs_drive
|
||||
local gs_smart_flag
|
||||
|
||||
gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///')
|
||||
gs_drives=$(/usr/local/sbin/smartctl --scan | grep "dev" | awk '{print $1}' | sed -e 's/\/dev\///' | tr '\n' ' ')
|
||||
|
||||
gs_smartdrives=""
|
||||
|
||||
for gs_drive in $gs_drives; do
|
||||
gs_smart_flag=$(/usr/local/sbin/smartctl -i /dev/"$gs_drive" | grep "SMART support is: Enabled" | awk '{print $4}')
|
||||
if [ "$gs_smart_flag" == "Enabled" ]; then
|
||||
if [ "$gs_smart_flag" = "Enabled" ]; then
|
||||
gs_smartdrives=$gs_smartdrives" "${gs_drive}
|
||||
fi
|
||||
done
|
||||
@@ -35,17 +30,17 @@ get_smart_drives()
|
||||
eval "$1=\$gs_smartdrives"
|
||||
}
|
||||
|
||||
declare drives
|
||||
drives=""
|
||||
get_smart_drives drives
|
||||
|
||||
# end of method 3.
|
||||
|
||||
for drive in $drives; do
|
||||
serial=$(/usr/local/sbin/smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')
|
||||
temp=$(/usr/local/sbin/smartctl -A /dev/${drive} | grep "Temperature_Celsius" | awk '{print $10}')
|
||||
brand=$(/usr/local/sbin/smartctl -i /dev/${drive} | grep "Model Family" | awk '{print $3, $4, $5}')
|
||||
serial=$(/usr/local/sbin/smartctl -i /dev/"${drive}" | grep "Serial Number" | awk '{print $3}')
|
||||
temp=$(/usr/local/sbin/smartctl -A /dev/"${drive}" | grep "Temperature_Celsius" | awk '{print $10}')
|
||||
brand=$(/usr/local/sbin/smartctl -i /dev/"${drive}" | grep "Model Family" | awk '{print $3, $4, $5}')
|
||||
if [ -z "$brand" ]; then
|
||||
brand=$(/usr/local/sbin/smartctl -i /dev/${drive} | grep "Device Model" | awk '{print $3, $4, $5}')
|
||||
brand=$(/usr/local/sbin/smartctl -i /dev/"${drive}" | grep "Device Model" | awk '{print $3, $4, $5}')
|
||||
fi
|
||||
printf "%5.5s: %3.3sC %s %s\n" "$drive" "$temp" "$brand" "$serial"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user