diskspace - Harddisk Belegungs Alarm
Vorwort
Ein kleines Tool das sicher Alarm gibt.
Das Feld ist frei - auch für eure Vorschläge. cy
diskspace
Das erste Zeichen darf kein Leerzeichen sein beim Speichern!
#!/bin/sh # # Scriptname: diskspace # # Installation: # chmod 755 /usr/local/bin/diskspace # chown root.root /usr/local/bin/diskspace # # Project idee by me :) # Main Part Script from my friend: tk-sls.de # # For test start: diskspace 1 , then check mutt # or your email client # # Starts: # A user can put it in his autostart in his home. # A admin cp /usr/local/bin/diskspace /etc/cron.daily (or /etc/cron.hourly) and disabling xmessaging. # Email Warning,true or false email_warning=true # X11 Messaging, true or false xmessage_warning=true # Multiple emails, just a space between. admin_email="root@localhost" domain=`hostname -f` # Hard disk usage alert in percent hd_limit=90 # Script if [ -n "$1" ];then hd_limit="$1";fi msg=$( df -h | tail -n+2 | awk -v limit=$hd_limit ' /sd/ { gsub("%","",$5); if($5>=limit) printf "Diskspace Warning: %-25s: %d%% used\n-------------------------------------------------------\n", $1, $5 }' ) if test -n "$msg" ; then #by email if "$email_warning" = true;then echo "$msg\n\nIt is recommend fix the problem, on Server: $domain\n" | mutt -s "Diskspace Warning" $admin_email fi #by xmessage for local Display if "$xmessage_warning" = true;then warn=$(echo "$msg\n\n!!! It is recommend fix the problem, on Server: $domain !!!") xmessage -center "$warn" fi fi exit 0