/usr/share/munin/plugins/vserver_loadavg 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 | #!/bin/bash
# -*- sh -*-
: <<'=cut'
=head1 NAME
vserver_loadavg - Plugin to graph vserver load average
=head1 CONFIGURATION
The following configuration variables are used by this plugin
[vserver_loadavg]
env.vservers - A list of vservers to include in the graph
This plugin should run as the "root" user
=head2 DEFAULT CONFIGURATION
The default configuration will graph all vservers.
[vserver_loadavg]
env.vservers all
=head1 AUTHORS
Copyright (C) 2008 Micah Anderson
Copyright (C) 2007 Andrei Morgan
=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 BUGS
None known.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
# If run with the "autoconf"-parameter, give our opinion on whether we
# should be run on this system or not. This is optional, and only used by
# munin-node-config.
if [ "$1" = "autoconf" ]; then
if [ -r /proc/virtual/info ]; then
echo yes
else
echo "no (/proc/virtual/info not found)"
fi
exit 0
fi
# if vservers are specified, use them; the default is to use all.
VSERVERS="$vservers"
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 run with the "config"-parameter, give out information on how the
# graphs should look.
if [ "$1" = "config" ]; then
# The title of the graph
echo 'graph_title loadavg of vserver'
# Arguments to "rrdtool graph". In this case, tell it that the
# lower limit of the graph is '0', and that 1k=1000 (not 1024)
echo 'graph_args --base 1000 -l 0'
# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
# 420 milliload)
echo 'graph_scale no'
# The Y-axis label
echo 'graph_vlabel loadavg'
# graph information for the main table
echo 'graph_info Shows 5-minute load average per vserver.'
# Graph category. Defaults to 'other'
echo 'graph_category vserver'
for xid in $XIDS ; do
# Specify the vservers
LABEL=`cat /proc/virtual/$xid/$NAMELOC |grep NodeName |cut -f2`
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
echo "$NAME.label $LABEL: load average"
echo "$NAME.info $NAME average load for the past 5 minutes"
done
# Last, if run with the "config"-parameter, quit here (don't
# display any data)
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 '-' '_'`
echo -n "$NAME.value ";
cat /proc/virtual/$xid/cvirt | grep loadavg: | cut -d' ' -f2
done
|