File: memory_pools.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (143 lines) | stat: -rw-r--r-- 4,151 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!@@GOODSH@@
#
# Plugin to monitor NetBSD kernel memory pool usage.
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - only used by munin-config)
#
# $Log: memory_pools.in,v $
# Revision 1.1.1.1  2006/06/04 20:53:57  he
# Import the client version of the Munin system monitoring/graphing
# tool -- project homepage is at http://munin.sourceforge.net/
#
# This package has added support for NetBSD, via a number of new plugin
# scripts where specific steps needs to be taken to collect information.
#
# I also modified the ntp_ plugin script to make it possible to not
# plot the NTP poll delay, leaving just jitter and offset, which IMO
# produces a more telling graph.
#
#
#
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#
#%# family=auto
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
    if [ -x /usr/bin/vmstat ]; then
    	echo yes
	exit 0
    else
        echo no
	exit 0
    fi
fi

PAGESIZE=`/sbin/sysctl -n hw.pagesize`

KMEM=`vmstat -s | awk -v bpp=$PAGESIZE '
/pages managed$/  { managed = $1; }
/pages free$/     { free = $1;    }
/pages active$/   { active = $1;  }
/pages inactive$/ { inactive = $1;}
/pages wired$/    { wired = $1;   }
END { kernel = managed - wired - inactive - active - free;
    print kernel * bpp; }'`


if [ "$1" = "config" ]; then

        echo 'graph_args --base 1024 -l 0 --vertical-label Bytes'
	echo 'graph_title Kernel Pool Memory usage'
	echo 'graph_category system'
	echo 'graph_info This graph shows the kernel memory pool usage'
	echo 'graph_order vnode ncache ffsino mbufs rest bufpl bufs'

	echo 'vnode.label vnodes'
	echo 'vnode.info vnode cache'
	echo 'vnode.draw AREA'

	echo 'ncache.label ncache'
	echo 'ncache.info namei cache'
	echo 'ncache.draw STACK'

	echo 'ffsino.label ffs-i'
	echo 'ffsino.info FFS inode cache'
	echo 'ffsino.draw STACK'

	echo 'mbufs.label mbufs'
	echo 'mbufs.info network buffers (mbufs + mbuf clusters)'
	echo 'mbufs.draw STACK'

	echo 'rest.label rest'
	echo 'rest.info sum of other memory pools'
	echo 'rest.draw STACK'

	echo 'bufpl.label bufpl'
	echo 'bufpl.info buffer pool'
	echo 'bufpl.draw STACK'

	echo 'bufs.label bufs'
	echo 'bufs.info buffer pools, for file metadata'
	echo 'bufs.draw STACK'

	exit 0
fi

vmstat -m -W > /dev/null 2>&1
if [ $? -eq 0 ]; then
	vmstat -m -W 2>/dev/null | awk '
/^Memory resource pool statistics/ { inpool=1; next; }
/^In use/			   { inpool=0; next; }
/^Name/ { next; }
/^vnodepl/ &&  inpool   { vnode  = $10 * $11; next; }
/^ncachepl/ && inpool   { ncache = $10 * $11; next; }
/^ffsinopl/ && inpool	{ ffsino = $10 * $11; next; }
/^dino1pl/ &&  inpool	{ dinopl = $10 * $11; next; }
/^buf.*k / &&  inpool   { bufk  += $10 * $11; next; }
/^bufpl/   &&  inpool	{ bufpl  = $10 * $11; next; }
/^mbpl/    &&  inpool   { mbufs += $10 * $11; next; }
/^mclpl/   &&  inpool   { mbufs += $10 * $11; next; }
$16 != "0x200" && $16 != "0x600" && inpool { rest  += $10 * $11; }
END {
	print "bufs.value " bufk;
	print "bufpl.value " bufpl;
	print "vnode.value " vnode;
	print "ncache.value " ncache;
	print "ffsino.value " ffsino;
	print "mbufs.value " mbufs;
	print "rest.value " rest;
}'
else
	# Need to guess size of pool pages, may not be correct
	# for small-memory machines (< 16MB)
	vmstat -m 2>/dev/null | awk -v bpp=$PAGESIZE '
/^Memory resource pool statistics/ { inpool=1; next; }
/^In use/			   { inpool=0; next; }
/^Name/				   { next; }
/^vnodepl/ &&  inpool   { vnode  = $8 * bpp; next; }
/^ncachepl/ && inpool   { ncache = $8 * bpp; next; }
/^ffsinopl/ && inpool	{ ffsino = $8 * bpp; next; }
/^dino1pl/ &&  inpool	{ dinopl = $8 * bpp; next; }
/^buf.*k / &&  inpool   { bufk  += $8 * 65536; next; }
/^bufpl/    && inpool	{ bufpl  = $8 * bpp; next; }
/^mbpl/    &&  inpool   { mbufs += $8 * bpp; next; }
/^mclpl/   &&  inpool   { mbufs += $8 * bpp; next; }
/^kvakernel/ 		{ next; }
/^kvakmem/              { next; }
inpool			{ rest  += $8 * bpp; }
END {
	print "bufs.value " bufk;
	print "bufpl.value " bufpl;
	print "vnode.value " vnode;
	print "ncache.value " ncache;
	print "ffsino.value " ffsino;
	print "mbufs.value " mbufs;
	print "rest.value " rest;
}'
fi