skripting-section:bash:disk-monitoring-skript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
skripting-section:bash:disk-monitoring-skript [2018/01/08 13:16] – [Skript Sourcecode] michaelskripting-section:bash:disk-monitoring-skript [2018/09/25 13:52] (current) – [Skript Sourcecode] michael
Line 9: Line 9:
 #!/bin/bash #!/bin/bash
 ############################################################################################ ############################################################################################
-#******************* Disk Monitoring Script by Michael Reber - v 1.**********************#+#******************* Disk Monitoring Script by Michael Reber - v 1.**********************#
 ############################################################################################ ############################################################################################
  
Line 20: Line 20:
 # Before disk-check test, that disk is mounted! # Before disk-check test, that disk is mounted!
 #if grep "$diskToCheck" /etc/mtab > /dev/null 2>&1; then #if grep "$diskToCheck" /etc/mtab > /dev/null 2>&1; then
 +
 +uhubctl -a on -p 3
 +sleep 10
         ## System dependency Check:         ## System dependency Check:
         if [ -n "$(command -v apt-get)" ]; then         if [ -n "$(command -v apt-get)" ]; then
Line 35: Line 38:
  
         # Create Disk Smart-OUTPUT and check Status:         # Create Disk Smart-OUTPUT and check Status:
-        OUTPUT="$(smartctl -a /dev/sda > /tmp/smartInfo && grep -oP '(?<=test result: )[^ ]+' /tmp/smartInfo)"+        OUTPUT="$(smartctl -d sat -a /dev/sda > /tmp/smartInfo && grep -oP '(?<=test result: )[^ ]+' /tmp/smartInfo)"
         echo "$OUTPUT at $today" >> /var/log/disk-monitoring.log         echo "$OUTPUT at $today" >> /var/log/disk-monitoring.log
         if [ "${OUTPUT}" = "PASSED" ]         if [ "${OUTPUT}" = "PASSED" ]
         then         then
           echo "Disk is Healty!"           echo "Disk is Healty!"
-          exit 0 
         else         else
           echo "Disk detected a SMART-Error!"           echo "Disk detected a SMART-Error!"
Line 49: Line 51:
                 -o tls=yes \                 -o tls=yes \
                 -xu "mail.blackgate@gmail.com" \                 -xu "mail.blackgate@gmail.com" \
-                -xp "" \+                -xp "PASSWORD" \
                 -o message-file="/tmp/smartInfo"                 -o message-file="/tmp/smartInfo"
         fi         fi
 +        # Poweroff Disk and exit program:
 +        uhubctl -a off -p 3
         exit 0         exit 0
 #else #else
Line 57: Line 61:
 #fi #fi
 </sxh> </sxh>
- 
  • skripting-section/bash/disk-monitoring-skript.1515413808.txt.gz
  • Last modified: 2018/01/08 13:19
  • (external edit)