Révision 82c2db05
Initial version
| plugins/other/solaris-memstat | ||
|---|---|---|
| 1 |
#! /bin/ksh |
|
| 2 |
# Copyright (c) 2010, Wikimedia Deutschland |
|
| 3 |
# All rights reserved. |
|
| 4 |
# |
|
| 5 |
# Redistribution and use in source and binary forms, with or without |
|
| 6 |
# modification, are permitted provided that the following conditions are met: |
|
| 7 |
# * Redistributions of source code must retain the above copyright |
|
| 8 |
# notice, this list of conditions and the following disclaimer. |
|
| 9 |
# * Redistributions in binary form must reproduce the above copyright |
|
| 10 |
# notice, this list of conditions and the following disclaimer in the |
|
| 11 |
# documentation and/or other materials provided with the distribution. |
|
| 12 |
# * Neither the name of Wikimedia Deutschland nor the |
|
| 13 |
# names of its contributors may be used to endorse or promote products |
|
| 14 |
# derived from this software without specific prior written permission. |
|
| 15 |
# |
|
| 16 |
# THIS SOFTWARE IS PROVIDED BY WIKIMEDIA DEUTSCHLAND ''AS IS'' AND ANY |
|
| 17 |
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
| 18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
| 19 |
# DISCLAIMED. IN NO EVENT SHALL WIKIMEDIA DEUTSCHLAND BE LIABLE FOR ANY |
|
| 20 |
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
| 21 |
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
| 22 |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
| 23 |
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
| 24 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
| 25 |
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
| 26 |
# |
|
| 27 |
# NOTE: This software is not released as a product. It was written primarily for |
|
| 28 |
# Wikimedia Deutschland's own use, and is made public as is, in the hope it may |
|
| 29 |
# be useful. Wikimedia Deutschland may at any time discontinue developing or |
|
| 30 |
# supporting this software. There is no guarantee any new versions or even fixes |
|
| 31 |
# for security issues will be released. |
|
| 32 |
### |
|
| 33 |
# Munin plugin to report Solaris memory usage via mdb's memstat. |
|
| 34 |
# Must be run as root. |
|
| 35 |
# |
|
| 36 |
# river@tamara.tcx.org.uk 2010-08-28 |
|
| 37 |
|
|
| 38 |
#%# family=auto |
|
| 39 |
#%# capabilities=autoconf |
|
| 40 |
|
|
| 41 |
if [ "$1" = "autoconf" ]; then |
|
| 42 |
if [ -e /usr/bin/mdb ]; then |
|
| 43 |
echo yes |
|
| 44 |
exit 0 |
|
| 45 |
else |
|
| 46 |
echo /usr/bin/mdb not found |
|
| 47 |
exit 1 |
|
| 48 |
fi |
|
| 49 |
fi |
|
| 50 |
|
|
| 51 |
if [ "$1" = "config" ]; then |
|
| 52 |
echo ' |
|
| 53 |
graph_args --base 1024 -l 0 --vertical-label Bytes |
|
| 54 |
graph_title Memory usage |
|
| 55 |
graph_category system |
|
| 56 |
graph_info This graph shows system memory use. |
|
| 57 |
graph_order kernel anon exec cacheused zfs cachefree free |
|
| 58 |
|
|
| 59 |
kernel.label kernel |
|
| 60 |
kernel.draw AREA |
|
| 61 |
kernel.info Memory used by kernel |
|
| 62 |
|
|
| 63 |
anon.label anon |
|
| 64 |
anon.draw STACK |
|
| 65 |
anon.info Memory used by programs |
|
| 66 |
|
|
| 67 |
exec.label exec_and_libs |
|
| 68 |
exec.draw STACK |
|
| 69 |
exec.info Memory used by executable files and libraries |
|
| 70 |
|
|
| 71 |
cacheused.label cacheused |
|
| 72 |
cacheused.draw STACK |
|
| 73 |
cacheused.info Memory used by page cache |
|
| 74 |
|
|
| 75 |
zfs.label zfs |
|
| 76 |
zfs.draw STACK |
|
| 77 |
zfs.info Memory used for ZFS file cache |
|
| 78 |
|
|
| 79 |
cachefree.label cachefree |
|
| 80 |
cachefree.draw STACK |
|
| 81 |
cachefree.info Free memory in cache list |
|
| 82 |
|
|
| 83 |
free.label free |
|
| 84 |
free.draw STACK |
|
| 85 |
free.info Free memory |
|
| 86 |
' |
|
| 87 |
exit 0 |
|
| 88 |
fi |
|
| 89 |
|
|
| 90 |
echo "::memstat" | mdb -k | nawk ' |
|
| 91 |
BEGIN {
|
|
| 92 |
pagesize='$(getconf PAGESIZE)' |
|
| 93 |
kernel=0 |
|
| 94 |
zfs=0 |
|
| 95 |
anon=0 |
|
| 96 |
exec=0 |
|
| 97 |
cache=0 |
|
| 98 |
phys=0 |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
/^Kernel/ { kernel=$2 }
|
|
| 102 |
/^ZFS File Data/ { zfs=$4 }
|
|
| 103 |
/^Anon/ { anon=$2 }
|
|
| 104 |
/^Exec and libs/ { exec=$4 }
|
|
| 105 |
/^Page cache/ { cacheused=$3 }
|
|
| 106 |
/^Free \(cachelist\)/ { cachefree=$3 }
|
|
| 107 |
/^Free \(freelist\)/ { free=$3 }
|
|
| 108 |
|
|
| 109 |
END {
|
|
| 110 |
print "kernel.value " (kernel * pagesize) |
|
| 111 |
print "zfs.value " (zfs * pagesize) |
|
| 112 |
print "anon.value " (anon * pagesize) |
|
| 113 |
print "exec.value " (exec * pagesize) |
|
| 114 |
print "cacheused.value " (cacheused * pagesize) |
|
| 115 |
print "cachefree.value " (cachefree * pagesize) |
|
| 116 |
print "free.value " (free * pagesize) |
|
| 117 |
} |
|
| 118 |
' |
|
Formats disponibles : Unified diff