Created
July 7, 2017 19:40
-
-
Save goulon/509ecb297bf6bd49060819d5067b584c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
while getopts 'w:c:' OPT; do | |
case $OPT in | |
w) WARN=$OPTARG;; | |
c) CRIT=$OPTARG;; | |
esac | |
done | |
WARN=${WARN:=90} | |
CRIT=${CRIT:=95} | |
vUsedMemory=$(free -m| grep Mem | awk '{ print int(($3-$7)*100/$2) }' ) | |
if [ "${vUsedMemory}" -ge "${CRIT}" ] | |
then | |
echo "MEM CRITICAL - ${vUsedMemory}%" | |
exit 2 | |
elif [ "${vUsedMemory}" -ge "${WARN}" ] | |
then | |
echo "MEM WARNING - ${vUsedMemory}%" | |
exit 1 | |
else | |
echo "MEM OK - ${vUsedMemory}%" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment