Skip to content
Snippets Groups Projects
Commit 7565c62b authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

detect -d param for smartctl

parent a7b4d1d4
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,13 @@ ...@@ -19,6 +19,13 @@
# - [does not exist] - device does not exist in the system # - [does not exist] - device does not exist in the system
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# #
# v1.3 more smartctl params - parsed in function detectParam()
# 1st value is empty ... last one something invalid
# PARAMS:
# PARAMS:-d cciss,0
# PARAMS:NO-PARAM-WAS-DETECTED
# ----------------------------------------------------------------------
#
# ah=axel.hahn@iml.unibe.ch # ah=axel.hahn@iml.unibe.ch
# ds=daniel.schueler@iml.unibe.ch # ds=daniel.schueler@iml.unibe.ch
# #
...@@ -28,6 +35,7 @@ ...@@ -28,6 +35,7 @@
# 2020-03-05 v1.0 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-03-05 v1.0 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2021-01-22 v1.1 <axel.hahn@iml.unibe.ch> add status [no access] # 2021-01-22 v1.1 <axel.hahn@iml.unibe.ch> add status [no access]
# 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails # 2021-04-07 v1.2 <axel.hahn@iml.unibe.ch> update message if sudo smartctl -H fails
# 2021-10-28 v1.3 <axel.hahn@iml.unibe.ch> detect -d param for smartctl
# ====================================================================== # ======================================================================
...@@ -47,6 +55,18 @@ export PATH ...@@ -47,6 +55,18 @@ export PATH
# functions # functions
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
function detectParam(){
local _mydevice=$1
local _moreparam
grep '^# PARAM' $0 | cut -f 2- -d ':' | while read _moreparam
do
sudo smartctl -H $_mydevice $_moreparam >/dev/null 2>&1 && echo "$_moreparam"
done
echo "$_moreparam"
}
# smart details for given device
# param string device, i.e. /dev/sda
function checkDrive(){ function checkDrive(){
tmpfile=/tmp/smartstatus.log tmpfile=/tmp/smartstatus.log
device=$1 device=$1
...@@ -68,8 +88,9 @@ function checkDrive(){ ...@@ -68,8 +88,9 @@ function checkDrive(){
# echo >>$tmpfile # echo >>$tmpfile
# --- check health # --- check health
# sudo smartctl -T permissive -Ha $device >>$tmpfile moreparam=$( detectParam $device )
sudo smartctl -Ha $device >>$tmpfile 2>&1 echo sudo smartctl -Ha $device $moreparam >>$tmpfile 2>&1
sudo smartctl -Ha $device $moreparam >>$tmpfile 2>&1
rcs=$? rcs=$?
echo $device - rc=$rcs >>$tmpfile echo $device - rc=$rcs >>$tmpfile
echo >>$tmpfile echo >>$tmpfile
...@@ -116,7 +137,8 @@ do ...@@ -116,7 +137,8 @@ do
# on first device: check permissions # on first device: check permissions
if [ $iFound -eq 1 ]; then if [ $iFound -eq 1 ]; then
sudo smartctl -H $mydevice >/dev/null 2>&1 moreparam=$( detectParam $mydevice )
sudo smartctl -H $mydevice $moreparam >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
ph.abort "SKIP: smartctl was found - but did not respond results. Maybe no sudo permissions or additional parameters required. $( sudo smartctl -H $mydevice )" ph.abort "SKIP: smartctl was found - but did not respond results. Maybe no sudo permissions or additional parameters required. $( sudo smartctl -H $mydevice )"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment