Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ansible-roles
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jocelyn Delalande
ansible-roles
Commits
bb400f48
Commit
bb400f48
authored
Mar 07, 2019
by
Jocelyn Delalande
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monit : Add smart checks to monit
parent
6bd9c9f8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
2 deletions
+53
-2
monit/defaults/main.yml
monit/defaults/main.yml
+1
-1
monit/files/scripts/sdahealth.sh
monit/files/scripts/sdahealth.sh
+19
-0
monit/files/scripts/sdatemp.sh
monit/files/scripts/sdatemp.sh
+5
-0
monit/tasks/main.yml
monit/tasks/main.yml
+14
-1
monit/tasks/smart.yml
monit/tasks/smart.yml
+2
-0
monit/templates/custom-modules/smart.j2
monit/templates/custom-modules/smart.j2
+12
-0
No files found.
monit/defaults/main.yml
View file @
bb400f48
monit_emails
:
[]
monit_email_from
:
monit@example.com
monit_cycle_duration
:
15
monit_cycle_duration
:
60
monit_enabled_modules
:
[]
\ No newline at end of file
monit/files/scripts/sdahealth.sh
0 → 100755
View file @
bb400f48
#!/bin/sh -e
# source https://www.smarthomebeginner.com/monit-monitor-hard-drive-smart-health-and-temperature/
STATUS
=
`
/usr/sbin/smartctl
-H
/dev/sda |
grep
overall-health |
awk
'match($0,"result:"){print substr($0,RSTART+8,6)}'
`
#echo $STATUS
if
[
"
$STATUS
"
=
"PASSED"
]
then
# 0 implies PASSED
TP
=
0
else
# 1 implies FAILED
TP
=
1
fi
#echo $TP # for debug only
# Enable offline data collection (idempotent)
/usr/sbin/smartctl
--smart
=
on
--offlineauto
=
on
--saveauto
=
on /dev/sda
>
/dev/null 2>&1
exit
$TP
monit/files/scripts/sdatemp.sh
0 → 100755
View file @
bb400f48
#!/bin/sh -e
# source https://www.smarthomebeginner.com/monit-monitor-hard-drive-smart-health-and-temperature/
HDDTP
=
`
/usr/sbin/smartctl
-a
/dev/sda |
grep
Temp |
awk
-F
" "
'{printf "%d",$10}'
`
#echo $HDDTP # for debug only
exit
$HDDTP
monit/tasks/main.yml
View file @
bb400f48
-
name
:
Install apt package
apt
:
pkg=monit update_cache=yes cache_valid_time=1800
-
import_tasks
:
smart.yml
-
name
:
Deploy monitrc configuration
template
:
src
:
monitrc.j2
dest
:
/etc/monit/monitrc
notify
:
restart monit
-
name
:
Create custom monit scripts dir
file
:
path
:
/etc/monit/scripts
state
:
directory
-
name
:
Deploy custom monit scripts
copy
:
src
:
"
scripts/"
dest
:
"
/etc/monit/scripts/"
mode
:
0755
-
name
:
Enable monit modules
template
:
src
:
"
custom-modules/{{
item
}}.j2"
dest
:
"
/etc/monit/conf.d/{{
item
}}"
with_items
:
"
{{
monit_enabled_modules
}}"
notify
:
restart monit
\ No newline at end of file
notify
:
restart monit
monit/tasks/smart.yml
0 → 100644
View file @
bb400f48
-
name
:
Install apt package
apt
:
pkg=smartmontools update_cache=yes cache_valid_time=1800
monit/templates/custom-modules/smart.j2
0 → 100644
View file @
bb400f48
# Temperature
check program HDD-Temp with path "/etc/monit/scripts/sdatemp.sh"
every 5 cycles
if status > 40 for 2 cycles then alert
group health
# SMART Overall Health
check program SSD-Health with path "/etc/monit/scripts/sdahealth.sh"
every 30 cycles
if status != 0 for 2 cycles then alert
group health
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment