Last active
December 21, 2015 21:29
-
-
Save rahulinux/6368248 to your computer and use it in GitHub Desktop.
Check disk spce , if disk space (Example /home = 90 %) then return 1 if no partition specified then it will check each partition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CheckSpace() { | |
local Partition=$1 | |
awk -v p=$Partition 'BEGIN{ | |
threshold=80 | |
cmd = "LC_ALL=C df -Ph "p | |
while( cmd | getline ) { | |
used=$5 # Usage in % of 5th colume | |
if ( $1 != "Filesystem" && int(used) >= threshold ) { | |
exit 1 | |
} | |
} | |
}' | |
} | |
CheckSpace $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment