HiDiskMonitor
Jump to navigation
Jump to search
Questo script controlla lo spazio libero su disco e invia una notifica per email in caso di problema.
NOTA: i comandi mail e awc devono essere accessibili.
#!/bin/sh # # hiDiskMonitor # Var EMAIL="email@server.whr"; SUBJECT="domain.whr hiDiskMonitor"; MAX_USAGE=90; # Test if test ! `which mail` then echo "Command mail not found, exit."; exit 1; fi; if test ! `which awk` then echo "Command awk not found, exit." | mail -s "${SUBJECT} error." "${EMAIL}"; exit 1; fi; # Monitor LIST_OF_USAGES=$(df -H / | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5}' | cut -d '%' -f 1); SEND_WARNING=0; for DISK_USAGE in ${LIST_OF_USAGES}; do if test ${DISK_USAGE} -gt ${MAX_USAGE}; then SEND_WARNING=1; break; fi; done; if test "${SEND_WARNING}" -eq 1; then df -h / | mail -s "${SUBJECT} Alert! DISK space low" "${EMAIL}"; fi; # End