File: memory.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 (89 lines) | stat: -rw-r--r-- 2,502 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
#!@@GOODSH@@
#
# Plugin to monitor memory usage.
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - only used by munin-config)
#
# $Log: memory.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 /sbin/sysctl ]; then
        /sbin/sysctl hw.pagesize > /dev/null
    	if [ $? = "0" ]; then
	    	echo yes
    		exit 0
    	else
	        echo no
		exit 0
	fi
    else
        echo no
        exit 0
    fi
fi

PAGESIZE=`/sbin/sysctl -n hw.pagesize`
MEMSIZE=`vmstat -s | awk '/pages managed/ { print $1 }'`
MEMMAX=`echo 2k $PAGESIZE $MEMSIZE '*p' | dc`

if [ "$1" = "config" ]; then
        echo 'graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit '$MEMMAX
	echo 'graph_title Memory usage'
	echo 'graph_category system'
	echo 'graph_info This graph shows what the machine uses its memory for.'

	echo 'graph_order active inactive wired kernel free'

	echo 'active.label active'
	echo 'active.info pages recently statistically used'
	echo 'active.draw AREA'

	echo 'inactive.label inactive'
	echo 'inactive.info pages recently statistically unused'
	echo 'inactive.draw STACK'

	echo 'wired.label wired'
	echo 'wired.info pages that are fixed into memory'
	echo 'wired.draw STACK'

	echo 'kernel.label kernel'
	echo 'kernel.info pages used by the kernel'
	echo 'kernel.draw STACK'

	echo 'free.label free'
	echo 'free.info pages without data content'
	echo 'free.draw STACK'

	exit 0
fi

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