Files
HDD_scripts/README.md
2024-10-19 21:54:51 +02:00

84 lines
2.4 KiB
Markdown

# 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)
```bash
sudo apt install smartmontools
```
- **requests** Python library (for sending notifications)
```bash
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:
```bash
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)
```bash
sudo apt install hdparm
```
## Usage
1. Clone or download the script to your machine.
2. Make the script executable:
```bash
chmod +x HDD.sh
```
3. Run the script with one of the following options:
```bash
./HDD.sh [option]
```
### Options:
- **Option 1**: Spin down all drives (excluding the boot drive)
```bash
./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)
```bash
./HDD.sh 2
```
This will check whether each connected drive (except the boot drive) is active or idle.