Last active
October 5, 2019 08:19
-
-
Save dev-gwang/492571223f98aac7d837737e8d749bc3 to your computer and use it in GitHub Desktop.
centos6, centos5 free -m memory percentage check
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
DATE=`date`; | |
MEM_TOTAL_REAL=`free -m | head -n 2 | tail -n 1 | awk {'print $2'}` | |
MEM_USED=`free -m | head -n 2 | tail -n 1 | awk {'print $3'}` | |
MEM_BUFFER=`free -m | head -n 2 | tail -n 1 | awk {'print $6'}` | |
MEM_CACHED=`free -m | head -n 2 | tail -n 1 | awk {'print $7'}` | |
TEST=$(($MEM_USED-$MEM_BUFFER-$MEM_CACHED)); | |
RESULT=$(($TEST*100)) | |
RESULT=$(($RESULT/$MEM_TOTAL_REAL)) | |
echo "-----------------------------------------------------" | |
echo "1. Memory Total $MEM_TOTAL_REAL"; | |
echo "2. Memory Used $MEM_USED"; | |
echo "3. Memory Buffer $MEM_BUFFER"; | |
echo "4. Memory Cached $MEM_CACHED"; | |
echo "-----------------------------------------------------" | |
echo "[$DATE] Result : $RESULT %"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment