You are viewing ghostdog74

Previous Entry | Next Entry

Gawk
#!/bin/bash
awk ' BEGIN {
    recipient = "root" #email recipient
    threshold = "90" #90%
    df = "/bin/df -k"
    while ( ( df |getline line ) > 0 ) {
      split(line,array," ")
      if ( array[5]+0 > threshold ) {      
        email="/usr/bin/mail -s \047Threshold reached\047 "recipient
        print "Filesystem " array[1] " hits the threshold " threshold ".Value: " array[5] | email
        close(email)
      }    
    }
    close(df)    
}'






Bash
threshold=50
df -HP | { while read a b c d u e
do    
        u=${u%?}
        case  "$u" in
        [1-9][0-9])
            echo "overload: $a, used: $u% more than $threshold" | mail root
        esac
done 
}

Profile

ghostdog74
ghostdog74

Latest Month

November 2013
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930

Tags

Powered by LiveJournal.com
Designed by Lilia Ahner