Created
July 7, 2017 19:39
-
-
Save goulon/b2c72bebdc015b7c7ab40a837cf1fd89 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:=0.8} | |
CRIT=${CRIT:=1} | |
vLoadPerCore=$(echo $(uptime | awk '{ gsub(/,/, ""); print $(NF-2)}') / $(cat /proc/cpuinfo | grep 'processor'| wc -l) | bc -l) | |
if [ $(echo ${vLoadPerCore}'>='${CRIT} | bc -l) -eq 1 ] | |
then | |
echo "LOAD CRITICAL - ${vLoadPerCore}" | |
exit 2 | |
elif [ $(echo ${vLoadPerCore}'>='${WARN} | bc -l) -eq 1 ] | |
then | |
echo "LOAD WARNING - ${vLoadPerCore}" | |
exit 1 | |
else | |
echo "LOAD OK - ${vLoadPerCore}" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment