2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/memory/kmemsum

62 lines
1.7 KiB
Plaintext
Raw Normal View History

2008-08-26 22:25:26 +02:00
#!/bin/sh
# Kernel Memory usage stats.
# Author: alex@trull.org
#
2008-08-26 22:25:26 +02:00
# Based on the short script at http://wiki.freebsd.org/ZFSTuningGuide (20080820)
#
# Parameters:
#
# config (required)
# autoconf (optional - only used by munin-config)
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#%# family=auto
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
if [ -x /sbin/sysctl ]; then
if /sbin/sysctl vm.kmem_size_max >/dev/null 2>&1; then
echo "yes"
else
echo "no (missing sysctl variable 'vm.kmem_size_max')"
fi
2008-08-26 22:25:26 +02:00
else
echo "no (missing 'sysctl' executable)"
2008-08-26 22:25:26 +02:00
fi
exit 0
2008-08-26 22:25:26 +02:00
fi
TEXT=`kldstat | tr a-f A-F | awk 'BEGIN {print "ibase=16"}; NR > 1 {print $4}' | bc | awk '{a+=$1}; END {print a}'`
DATA=`vmstat -m | sed 's/K//' | awk '{a+=$3}; END {print a*1024}'`
TOTAL=`echo $DATA $TEXT | awk '{print $1+$2}'`
MAX=`sysctl vm.kmem_size_max | awk '{print $2}'`
if [ "$1" = "config" ]; then
echo 'graph_args --base 1024 -l 0 --vertical-label Bytes'
echo 'graph_title Kernel Memory usage'
echo 'graph_category system'
echo 'graph_info This graph shows kmem usage.'
echo 'graph_order text data'
echo 'text.label text'
echo 'text.info kmem text'
echo 'text.draw AREA'
echo 'data.label data'
echo 'data.info kmem data'
2008-08-26 22:25:26 +02:00
echo 'data.draw STACK'
echo 'total.label total'
echo 'total.info kmem total'
echo 'total.draw LINE'
echo 'max.label max'
echo 'max.info kmem max'
echo 'max.draw LINE2'
exit 0
fi
echo "text.value $TEXT"
echo "data.value $DATA"
echo "total.value $TOTAL"
echo "max.value $MAX"