2024-10-19 21:54:51 +02:00
2024-10-19 12:53:17 +02:00
2024-10-19 12:52:51 +02:00
2024-10-19 21:54:51 +02:00

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

  1. Clone or download the script to your machine.
  2. Ensure you have proper permissions to run smartctl with sudo.
  3. Edit the script to replace the ntfy URL (https://ntfy.hrasci.eu/rpi5) with your desired ntfy topic.
  4. 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.
  • Unhealthy drives:

    • Notification with a title indicating the specific drive, an urgent priority, and warning tags warning, skull.

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

  1. Clone or download the script to your machine.
  2. Make the script executable:
    chmod +x HDD.sh
    
  3. 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 1
    

    This 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 2
    

    This will check whether each connected drive (except the boot drive) is active or idle.

Description
HDDs related scripts to spin down and other stuff
Readme 37 KiB
Languages
Python 77%
Shell 23%