Created
November 12, 2012 18:31
-
-
Save jgoodall/4061026 to your computer and use it in GitHub Desktop.
shell script to print memory usage to the screen (geektool)
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
#!/bin/sh | |
# useful for [geektool](http://projects.tynsoe.org/en/geektool/) | |
/usr/bin/vm_stat | sed 's/\.//' | awk ' | |
/free/ {FREE_BLOCKS = $3} | |
/inactive/ {INACTIVE_BLOCKS = $3} | |
/speculative/ {SPECULATIVE_BLOCKS = $3} | |
/wired/ {WIRED_BLOCKS = $4} | |
END { | |
TOTAL = 16384 | |
FREE = ((FREE_BLOCKS + SPECULATIVE_BLOCKS) * 4096) / 1048576 | |
INACTIVE = (INACTIVE_BLOCKS * 4096) / 1048576 | |
TOTAL_FREE = FREE + INACTIVE | |
WIRED = (WIRED_BLOCKS * 4096) / 1048576 | |
ACTIVE = TOTAL - (TOTAL_FREE + WIRED) | |
TOTAL_USED = INACTIVE + WIRED + ACTIVE | |
printf "Free: %d\n", FREE | |
printf "Inactive: %d\n", INACTIVE | |
printf "Total Free: %d\n", TOTAL_FREE | |
printf "Wired: %d\n", WIRED | |
printf "Active: %d\n", ACTIVE | |
printf "Total Used: %d\n", TOTAL_USED | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment