Last active
March 25, 2021 03:28
-
-
Save frjufvjn/b29f748f2652456e22c148fda2d85b1e 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
free -m | \ | |
awk ' | |
{ | |
if (NR==1) { | |
if (/cached$/) { | |
vesion=0 | |
} else { | |
version=1 | |
} | |
} else { | |
if (/^Mem/) { | |
if (version==0) { | |
usage1 = ($3 - $6 - $7) / $2 * 100 | |
print "memory usage: " usage1 | |
} else { | |
usage2 = ($2 - $7) / $2 * 100 | |
print "memory usage: " usage2 | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment