Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / kmemsum @ 9ff495b3

Historique | Voir | Annoter | Télécharger (1,6 ko)

1
#!/bin/sh
2
# Kernel Memory usage stats.
3
# Author: alex@trull.org 
4
# 
5
# Based on the short script at http://wiki.freebsd.org/ZFSTuningGuide (20080820)
6
#
7
# Parameters:
8
#
9
# 	config   (required)
10
# 	autoconf (optional - only used by munin-config)
11
#
12
# Magic markers (optional - only used by munin-config and some
13
# installation scripts):
14
#%# family=auto
15
#%# capabilities=autoconf
16

    
17
if [ "$1" = "autoconf" ]; then
18
    if [ -x /sbin/sysctl ]; then
19
        /sbin/sysctl vm.kmem_size_max > /dev/null
20
    	if [ $? = "0" ]; then
21
	    	echo yes
22
    		exit 0
23
    	else
24
		    echo no
25
		    exit 1
26
	    fi
27
    else
28
        echo no
29
        exit 1
30
    fi
31
fi
32

    
33
TEXT=`kldstat | tr a-f A-F | awk 'BEGIN {print "ibase=16"}; NR > 1 {print $4}' | bc | awk '{a+=$1}; END {print a}'`
34
DATA=`vmstat -m | sed 's/K//' | awk '{a+=$3}; END {print a*1024}'`
35
TOTAL=`echo $DATA $TEXT | awk '{print $1+$2}'`
36
MAX=`sysctl vm.kmem_size_max | awk '{print $2}'`
37

    
38
if [ "$1" = "config" ]; then
39
        echo 'graph_args --base 1024 -l 0 --vertical-label Bytes'
40
	echo 'graph_title Kernel Memory usage'
41
	echo 'graph_category system'
42
	echo 'graph_info This graph shows kmem usage.'
43
	echo 'graph_order text data'
44
	echo 'text.label text'
45
	echo 'text.info kmem text'
46
	echo 'text.draw AREA'
47
        echo 'data.label data'
48
        echo 'data.info kmem data' 
49
        echo 'data.draw STACK'
50
        echo 'total.label total'
51
        echo 'total.info kmem total'
52
        echo 'total.draw LINE'
53
        echo 'max.label max'
54
        echo 'max.info kmem max'
55
        echo 'max.draw LINE2'
56
	exit 0
57
fi
58

    
59
echo "text.value $TEXT"
60
echo "data.value $DATA"
61
echo "total.value $TOTAL"
62
echo "max.value $MAX"
63

    
64