Last active
December 20, 2015 20:29
-
-
Save informationsea/6190972 to your computer and use it in GitHub Desktop.
Plugin to monitor the memory on a OS X system (Mavericks supported)
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/sh | |
# -*- sh -*- | |
#: =cut | |
# | |
#=head1 NAME | |
# | |
#load - Plugin to monitor the memory on a system. | |
# | |
#=head1 AUTHOR | |
# | |
#Y.OKAMURA | |
# | |
#=head1 LICENSE | |
# | |
#GPLv3+ | |
# | |
#=head1 MAGIC MARKERS | |
# | |
# #%# family=auto | |
# #%# capabilities=autoconf | |
# | |
#=cut | |
# If run with the "autoconf"-parameter, give our opinion on wether we | |
# should be run on this system or not. This is optinal, and only used by | |
# munin-config. In the case of this plugin, we should most probably | |
# always be included. | |
if [ "$1" = "autoconf" ]; then | |
echo yes | |
exit 0 | |
fi | |
# If run with the "config"-parameter, give out information on how the | |
# graphs should look. | |
MEMSIZE=`sysctl hw.memsize|cut -f 2 -d ' '` | |
PAGESIZE=`sysctl hw.pagesize|cut -f 2 -d ' '` | |
if [ "$1" = "config" ]; then | |
cat <<EOF | |
graph_args --base 1024 -l 0 --upper-limit $MEMSIZE | |
graph_vlabel Bytes | |
graph_title Memory usage | |
graph_category system | |
graph_info This graph shows what the machine uses memory for. | |
graph_order wired active inactive speculative free | |
wired.label Wired | |
wired.draw AREA | |
speculative.label speculative | |
speculative.draw STACK | |
active.label active | |
active.draw STACK | |
inactive.label inactive | |
inactive.draw STACK | |
compressed.label Compressed | |
compressed.draw STACK | |
free.label free | |
free.draw STACK | |
EOF | |
# Last, if run with the "config"-parameter, quit here (don't | |
# display any data) | |
exit 0 | |
fi | |
# If not run with any parameters at all (or only unknown ones), do the | |
# real work - i.e. display the data. Almost always this will be | |
# "value" subfield for every data field. | |
echo 'free.value' $((`vm_stat|fgrep 'Pages free'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) | |
echo 'active.value' $((`vm_stat|fgrep 'Pages active'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) | |
echo 'inactive.value' $((`vm_stat|fgrep 'Pages inactive'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) | |
echo 'wired.value' $((`vm_stat|fgrep 'Pages wired'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) | |
echo 'compressed.value' $((`vm_stat|fgrep 'Pages occupied by compressor'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) | |
echo 'speculative.value' $((`vm_stat|fgrep 'Pages speculative'|cut -f 2 -d ':'|sed -e 's/[\. ]//g'` * $PAGESIZE)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment