Watch disk space

Iš Žinynas.
08:50, 18 sausio 2018 versija, sukurta \dev\null (Aptarimas | indėlis) (Naujas puslapis: Scriptas skirtas pranesti apie mazejancia disko vieta <SyntaxHighLight lang="bash"> #!/bin/bash # Watch disk space by percent per mounted volume, and report if it exceeds the pe...)
(skirt) ← Ankstesnė versija | Dabartinė versija (skirt) | Vėlesnė versija → (skirt)
Jump to navigation Jump to search

Scriptas skirtas pranesti apie mazejancia disko vieta

#!/bin/bash
# Watch disk space by percent per mounted volume, and report if it exceeds the percentage that provided in this script configuration
# (c) 2018 justinas@eofnet.lt
DISK=/tmp # mount point to watch
PERCENT=90 # if disk is over 90 percentage then do the command
COMM="rm -f /tmp/*"
MAIL="justinas@eofnet.lt"
SPACE=`df -h $DISK|grep $DISK|awk '{print $5}'|awk -F\% '{print $1}'`
if [ "$SPACE" -ge "$PERCENT" ]; then
echo "Server status `hostname` $DISK space running low"|mail -n -s "Server status `hostname`" $MAIL
$COMM
fi