#!/bin/bash # -- DFHR Version 0.3 / July 04, 2025 - BTA - LOSTGEEK.NET -- # ... ammended @ 20:50 / 07.05.25 echo -e "Device Size Used Avail Used Mount Hours Label" # Function to get power-on hours based on device get_poh() { local dev=$1 local poh="" case "$dev" in /dev/sda) poh=$(sudo smartctl -x "$dev" | grep On_Hour | awk '{print $8}' | tr -d ',' 2>/dev/null) ;; /dev/sdb) poh=$(sudo smartctl -x "$dev" | grep Loaded_H | awk '{print $8}' | tr -d ',' 2>/dev/null) ;; /dev/sdc) # THIS is a USB disk! We might need to wake it! Retry loop: try 3 times with 10s delay if value invalid for attempt in {1..3}; do poh=$(sudo smartctl -x "$dev" | grep On_Hours | awk '{print $8}' | tr -d ',' 2>/dev/null) if [[ "$poh" =~ ^[0-9]+$ ]]; then break else if [ "$attempt" -lt 3 ]; then sleep 10 fi fi done ;; /dev/nvme0n1) poh=$(sudo smartctl -x "$dev" | grep Hours | awk '{print $4}' | tr -d ',' 2>/dev/null) ;; *) poh="N/A" ;; esac echo "${poh:-N/A}" } # Loop over your drives for dev in /dev/nvme0n1 /dev/sda /dev/sdb /dev/sdc; do # Skip if the device doesn't exist if [ ! -b "$dev" ]; then continue fi label="" case "$dev" in /dev/nvme0n1) label=" root / " ;; /dev/sda) label=" nfs data main " ;; /dev/sdb) label=" nfs data mirror " ;; /dev/sdc) label=" bulk archive " ;; esac # Get df info for the device df_line=$(df -h | grep "$dev" | head -n1) if [ -z "$df_line" ]; then fs="$dev" size="N/A" used="N/A" avail="N/A" usep="N/A" mount="(not mounted)" else read fs size used avail usep mount <<< $(echo "$df_line" | awk '{print $1, $2, $3, $4, $5, $6}') fi # Get power-on hours poh=$(get_poh "$dev") # Print aligned info printf "%-15s %-5s %-5s %-5s %-4s %-12s %-7s (%s)\n" "$fs" "$size" "$used" "$avail" "$usep" "$mount" "$poh" "$label" done