Created
December 16, 2017 08:36
-
-
Save ivan-loh/d9d6d55e49254e2baecc307babb4ef40 to your computer and use it in GitHub Desktop.
script to use to monitor memory utilization
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 | |
function alert { | |
curl --header 'Access-Token: <access_token_here>' \ | |
--header 'Content-Type: application/json' \ | |
--data-binary '{"body":"Memory Threshold Reachd","title":"Database Server Alert","type":"note"}' \ | |
--request POST \ | |
https://api.pushbullet.com/v2/pushes | |
} | |
# Checks | |
THRESHOLD_PERCENTAGE=90 | |
TOTAL=$(grep MemTotal /proc/meminfo | awk '{print $2}') | |
FREE=$(grep MemFree /proc/meminfo | awk '{print $2}') | |
let "USED = $TOTAL - $FREE" | |
let "USED = $USED * 100" | |
let "USED_PERCENTAGE = $USED / $TOTAL" | |
echo "USED "$USED_PERCENTAGE | |
if [ $USED_PERCENTAGE -gt $THRESHOLD_PERCENTAGE ] | |
then | |
alert | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment