/usr/share/munin/plugins/vserver_resources is in munin-node 1.4.6-3ubuntu3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | #!/bin/bash
# -*- sh -*-
: <<'=cut'
=head1 NAME
vserver_resources - Plugin to graph Vserver resource usage and limits
=head1 CONFIGURATION
This plugin uses the following configuration variables
[vserver_resources]
env.vservers - specify the vservers to include in the graph
env.resource - specify the resource to be monitored
env.limits - if true, turn on limit graphing
=head2 DEFAULT CONFIGURATION
This is the default configuration
[vserver_resources]
env.vservers <all vservers>
env.limits false
=head1 EXAMPLE CONFIGURATIONS
The following monitors the RSS value for the vservers named "vserver1
vserver2 vserver3 vserver4" and looks to see if the resource limit has
been breached, if so it sends a message to nagios via send_nsca, and
sends an email to notify that this has happened:
[vserver_resources]
user root
env.vservers vserver1 vserver2 vserver3 vserver4
env.resource RSS
env.limits 1
contacts nagios email
contact.nagios.command /usr/bin/send_nsca -H your.nagios-host.here -c /etc/send_nsca.cfg
contact.email.command mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email.address.here
This second example monitors the VM value for all vservers on the system and
has no limit notifications turned on:
[vserver_resources]
user root
env.vservers vserver5 vserver6 vserver7
env.resource VM
env.limits 0
This last example monitors all the resources for vserver5. Note that
this will be a busy graph, and it would be really useless if you
specified more than one vserver when the resource is set to ALL:
[vserver_resources]
user root
env.vservers vserver5
env.resource ALL
env.limits 0
=head1 USAGE
Possible values for env.resource are:
=over 4
=item ALL
all the below resources
=item PROC
number of processes
=item VM
sum of all virtual pages inside the guest
=item VML
sum of all virtual pages locked into memory
=item RSS
number of pages currently present in RAM
=item ANON
number of anonymous memory pages
=item FILES
number of open files
=item OFD
=item LOCKS
=item SOCK
=item MSGQ
=item SHM
number of shared memory pages
=back
=head1 AUTHORS
Copyright (C) 2006-2008 Holger Levsen, Micah Anderson
=head1 LICENSE
GNU GPLv2
=begin comment
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
=end comment
=head1 TODO
=over 4
=item Less shell subprocesses
The plugin uses lots and lots of shell subprocesses. Maybe factor
common vserver plugin code into Munin::Plugin::Linux::Vserver?
=item Multigraph
make it so you can specify more than one resource to be graphed?
Alternatively define combined ressource-display: VM+RSS+ANON+SHM and
FILES+OFD+LOCK+SOCK (for one vserver only), and/or make it so you can
graph all resources for one vserver
=item Default resource
set a default for the resource if it is unset?
=item Use /proc less often
use /proc less often (100 times more overhead than talking to the
kernel directly) i.e. use something like pagesize=\`perl -MPOSIX -e
'print POSIX::sysconf(_SC_PAGESIZE), "\n";'\`
=back
=head1 BUGS
The "ALL" resource is broken
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
if [ "$1" = "autoconf" ]; then
if [ -r /proc/virtual/info ]; then
echo yes
else
echo "no (/proc/virtual/info not found)"
fi
exit 0
fi
VSERVERS="$vservers"
LIMITS="$limits"
RESOURCE="$resource"
INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo '<none>'`)
KCIN="$[ 16#${INFO[2]} ]";
# If this is 1, then VCI_SPACES is present in the kernel (new in 2.6.19)
if [ $[ (KCIN >> 10) & 1 ] -eq 1 ]
then
NAMELOC="nsproxy"
else
NAMELOC="cvirt"
fi
if [ -z "$VSERVERS" ] ; then
XIDS=`find /proc/virtual/* -type d -exec basename {} \;`
else
# it's really more performant to specify vservers by ids or not at all
XIDS=""
for i in $VSERVERS ; do
if [ -d /proc/virtual/$i ] ; then
XIDS="${XIDS}${i} "
else
for j in `find /proc/virtual/* -type d -exec basename {} \;` ; do
if [ "$i" = "`cat /proc/virtual/$j/$NAMELOC |grep NodeName |cut -f2`" ] ; then
XIDS="${XIDS}${j} "
fi
done
fi
done
fi
if [ "$1" = "config" ]; then
case "$RESOURCE" in
PROC)
echo 'graph_title Processes used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Processes'
echo 'graph_info Shows the number of processes used by each vserver.'
;;
VM)
echo 'graph_title Virtual memory used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel VM pages'
echo 'graph_info Shows virtual memory (human readable) used by each vserver.'
;;
VML)
echo 'graph_title Locked memory used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel VML pages'
echo 'graph_info Shows locked memory (human readable) used by each vserver.'
;;
RSS)
echo 'graph_title Resident set size used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel RSS pages'
echo 'graph_info Shows resident set size (human readable) used by each vserver.'
;;
ANON)
echo 'graph_title Anonymous memory used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel ANON pages'
echo 'graph_info Shows anonymous memory (human readable) used by each vserver.'
;;
FILES)
echo 'graph_title Files used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Files'
echo 'graph_info Shows files used by each vserver.'
;;
OFD)
echo 'graph_title Open filedescriptors used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Open filedescriptors'
echo 'graph_info Shows open filedescriptors used by each vserver.'
;;
LOCKS)
echo 'graph_title Locks used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Locks'
echo 'graph_info Shows locks used by each vserver.'
;;
SOCK)
echo 'graph_title Sockets used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Sockets'
echo 'graph_info Shows sockets used by each vserver.'
;;
MSGQ)
echo 'graph_title Message queues used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel Message queues'
echo 'graph_info Shows message queues used by each vserver.'
;;
SHM)
echo 'graph_title Shared memory used by vserver'
echo 'graph_args --base 1024k -l 0'
echo 'graph_vlabel SHM pages'
echo 'graph_info Shows shared memory (human readable) used by each vserver.'
;;
*)
echo "$RESOURCE not defined."
exit 1
;;
esac
echo 'graph_category vserver'
# do not assume we are on i386 where pagesize is 4096...
pagesize=`perl -MPOSIX -e 'print POSIX::sysconf(_SC_PAGESIZE), "\n";'`
for xid in $XIDS ; do
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
case "$RESOURCE" in
PROC)
echo "$NAME.label $LABEL: processes"
echo "$NAME.info Number of processes used by $LABEL."
;;
VM)
echo "$NAME.label $LABEL: Virtual memory"
echo "$NAME.info Size of virtual memory used by $LABEL. (Number multipled by $pagesize to make it human readable)"
echo "$NAME.cdef $NAME,$pagesize,*"
;;
VML)
echo "$NAME.label $LABEL: Locked memory"
echo "$NAME.info Size of locked memory used by $LABEL. (Number multipled by $pagesize to make it human readable)"
echo "$NAME.cdef $NAME,$pagesize,*"
;;
RSS)
echo "$NAME.label $LABEL: Resident set size"
echo "$NAME.info Size of resident set size used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
echo "$NAME.cdef $NAME,$pagesize,*"
;;
ANON)
echo "$NAME.label $LABEL: Anonymous memory"
echo "$NAME.info Size of anonymous memory used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
echo "$NAME.cdef $NAME,$pagesize,*"
;;
FILES)
echo "$NAME.label $LABEL: Files"
echo "$NAME.info Number of files used by $LABEL."
;;
OFD)
echo "$NAME.label $LABEL: Open filedescriptors"
echo "$NAME.info Number of open filedescriptors used by $LABEL."
;;
LOCKS)
echo "$NAME.label $LABEL: Locks"
echo "$NAME.info Number of locks used by $LABEL."
;;
SOCK)
echo "$NAME.label $LABEL: Sockets"
echo "$NAME.info Number of sockets used by $LABEL."
;;
MSGQ)
echo "$NAME.label $LABEL: Message queues"
echo "$NAME.info Number of message queues used by $LABEL."
;;
SHM)
echo "$NAME.label $LABEL: Shared memory"
echo "$NAME.info Size of shared memory used by $LABEL. (Number multiplied by $pagesize to make it human readable)"
echo "$NAME.cdef $1,$pagesize,*"
;;
*)
echo "$RESOURCE not defined."
exit 1
;;
esac
if [ ! -z "$LIMITS" -a "$LIMITS" = 1 ]; then
LIMIT=`cat /proc/virtual/$xid/limit | grep $RESOURCE | cut -f4`
if [ ${LIMIT:-0} -gt 0 ]; then
echo "$NAME.critical $LIMIT"
fi
fi
done
exit 0
fi
for xid in $XIDS ; do
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
cat /proc/virtual/$xid/limit | awk -v name="${NAME}" -v resource="${RESOURCE}:" \
'{ if ( $1 == resource )
printf "%s.value %d\n", name, $2 }'
done
|