Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 65 lines (59 sloc) 1.45 kb
#!/usr/bin/env bash
#
# Check for high memory usage on an Illumos
# based machine
#
# Not typically a problem in itself, but can
# indicate future problems
#
# Author: Dave Eddy <dave@voxer.com>
# Creation Date: 9/14/2012
# 01/10/2014 Added check for global zone (Napsty)
# License: MIT
rss_and_cap() {
local name value
if [[ $(zonename) == 'global' ]]; then
local pagesize=$(pagesize)
while read name value; do
IFS=: read _ _ _ name <<< "$name"
local "$name"
read "$name" <<< "$value"
done < <(kstat -p unix::system_pages:{availrmem,freemem,physmem})
echo "$(((availrmem - freemem) * pagesize)) $((physmem * pagesize))"
else
while read name value; do
IFS=: read _ _ _ name <<< "$name"
local "$name"
read "$name" <<< "$value"
done < <(kstat -pc zone_memory_cap :::rss :::physcap)
echo "$rss $physcap"
fi
}
warning=90
critical=95
perfdata=true
while getopts 'nw:c:' option; do
case "$option" in
n) perfdata=false;;
w) warning=$OPTARG;;
c) critical=$OPTARG;;
esac
done
read rss cap < <(rss_and_cap)
perc_used=$((rss * 100 / cap))
if [[ -z $perc_used ]]; then
echo 'unknown: error retrieving data'
exit 3
elif ((perc_used >= critical)); then
echo -n 'critical: '
ret=2
elif ((perc_used >= warning)); then
echo -n 'warning: '
ret=1
else
echo -n 'ok: '
ret=0
fi
echo -n "$perc_used% used (warning=$warning%, critical=$critical%)"
$perfdata && echo "|mem_used=$rss;mem_cap=$cap" || echo
exit "$ret"
Jump to Line
Something went wrong with that request. Please try again.