check_drives_health.py
Drive Health Monitoring Script
This script checks the SMART health status of all available drives on the system and sends notifications using the ntfy service. The script will alert you if any drives are failing and provide a summary of the health status for all drives.
Prerequisites
Before running the script, ensure you have the following installed:
- smartmontools (to check drive SMART status)
sudo apt install smartmontools - requests Python library (for sending notifications)
pip install requests
Usage
- Clone or download the script to your machine.
- Ensure you have proper permissions to run
smartctlwithsudo. - Edit the script to replace the ntfy URL (
https://ntfy.hrasci.eu/rpi5) with your desired ntfy topic. - Run the script:
sudo python3 drive_health.py
The script will:
- List all available drives on the system.
- Check the SMART health status of each drive.
- Send notifications via
ntfy:- If a drive is unhealthy, it sends an urgent notification with warning tags.
- If all drives are healthy, it sends a low-priority notification.
Example Notifications
-
Healthy drives:
- Notification with the title "All Drives Healthy" and tags
ok,check.
- Notification with the title "All Drives Healthy" and tags
-
Unhealthy drives:
- Notification with a title indicating the specific drive, an urgent priority, and warning tags
warning,skull.
- Notification with a title indicating the specific drive, an urgent priority, and warning tags
HDD.sh
HDD Spin Down and Status Check Script
This script provides two options to either spin down all drives on the system (excluding the boot drive) or check whether the drives are currently active or idle.
Prerequisites
Before running the script, ensure you have the following installed:
- hdparm (to manage and check drive states)
sudo apt install hdparm
Usage
- Clone or download the script to your machine.
- Make the script executable:
chmod +x HDD.sh - Run the script with one of the following options:
./HDD.sh [option]
Options:
-
Option 1: Spin down all drives (excluding the boot drive)
./HDD.sh 1This will send the command to spin down all connected drives except the boot drive.
-
Option 2: Check the activity status of all drives (excluding the boot drive)
./HDD.sh 2This will check whether each connected drive (except the boot drive) is active or idle.