Commit bb400f48 by Jocelyn Delalande

monit : Add smart checks to monit

parent 6bd9c9f8
monit_emails: []
monit_cycle_duration: 15
monit_cycle_duration: 60
monit_enabled_modules: []
\ No newline at end of file
#!/bin/sh -e
# source
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" ]
# 0 implies PASSED
# 1 implies FAILED
#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
#!/bin/sh -e
# source
HDDTP=`/usr/sbin/smartctl -a /dev/sda | grep Temp | awk -F " " '{printf "%d",$10}'`
#echo $HDDTP # for debug only
exit $HDDTP
- name: Install apt package
apt: pkg=monit update_cache=yes cache_valid_time=1800
- import_tasks: smart.yml
- name: Deploy monitrc configuration
src: monitrc.j2
dest: /etc/monit/monitrc
notify: restart monit
- name: Create custom monit scripts dir
path: /etc/monit/scripts
state: directory
- name: Deploy custom monit scripts
src: "scripts/"
dest: "/etc/monit/scripts/"
mode: 0755
- name: Enable monit modules
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
- name: Install apt package
apt: pkg=smartmontools update_cache=yes cache_valid_time=1800
# Temperature
check program HDD-Temp with path "/etc/monit/scripts/"
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/"
every 30 cycles
if status != 0 for 2 cycles then alert
group health
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment