Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
7565c62b
Commit
7565c62b
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
detect -d param for smartctl
parent
a7b4d1d4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_smartstatus
+25
-3
25 additions, 3 deletions
check_smartstatus
with
25 additions
and
3 deletions
check_smartstatus
+
25
−
3
View file @
7565c62b
...
...
@@ -19,6 +19,13 @@
# - [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
# ds=daniel.schueler@iml.unibe.ch
#
...
...
@@ -28,6 +35,7 @@
# 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-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
# 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
(){
tmpfile
=
/tmp/smartstatus.log
device
=
$1
...
...
@@ -68,8 +88,9 @@ function checkDrive(){
# echo >>$tmpfile
# --- check health
# sudo smartctl -T permissive -Ha $device >>$tmpfile
sudo
smartctl
-Ha
$device
>>
$tmpfile
2>&1
moreparam
=
$(
detectParam
$device
)
echo sudo
smartctl
-Ha
$device
$moreparam
>>
$tmpfile
2>&1
sudo
smartctl
-Ha
$device
$moreparam
>>
$tmpfile
2>&1
rcs
=
$?
echo
$device
-
rc
=
$rcs
>>
$tmpfile
echo
>>
$tmpfile
...
...
@@ -116,7 +137,8 @@ do
# on first device: check permissions
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
ph.abort
"SKIP: smartctl was found - but did not respond results. Maybe no sudo permissions or additional parameters required.
$(
sudo
smartctl
-H
$mydevice
)
"
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment