mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
190
plugins/vserver/vserver_cpu_
Executable file
190
plugins/vserver/vserver_cpu_
Executable file
|
@ -0,0 +1,190 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006-2008 Holger Levsen and Micah Anderson
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Graph Vserver cpu usage stats
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
#
|
||||
# NOTE: If no configuration variable is set, the default will be used
|
||||
#
|
||||
# see vserver_resources for example uses of configuration files
|
||||
#
|
||||
# or links to define what to monitor:
|
||||
# vserver_cpu_ -> monitor cpu usage of all vservers on all cpus
|
||||
# vserver_hold_ -> monitor hold on all vservers on all cpus
|
||||
# vserver_hold_0 -> monitor hold on all vservers on cpu0
|
||||
# vserver_hold_1 -> monitor hold on all vservers on cpu1
|
||||
# vserver_hold_foo -> monitor hold on all cpus on vserver named foo
|
||||
# vserver_sys_foo -> monitor cpu usage on all cpus on vserver named foo
|
||||
|
||||
# Changelog
|
||||
# version 0.2 - 2006 October 02 Holger Levsen <debian@layer-acht.org>
|
||||
# - label fixed: we measure jiffies not seconds
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
# - Fix hypens in NodeNames, replace them with underscores
|
||||
# - whitespace cleanup
|
||||
# version 0.3 - 2006 October 07 Holger Levsen <debian@layer-acht.org>
|
||||
# - rewrite of vserver_usercpu
|
||||
# - smp-aware
|
||||
# - can display hold too (third value in the cpu line(s) of /proc/virtual/<xid>/sched)
|
||||
# - no seperation between user and system cpu anymore
|
||||
# - handle identical vserver-names by using the vserver-id internally
|
||||
# version 0.4 - 2007, October 07
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - fixed variable name (thanks pietro)
|
||||
# version 0.5 - 2008, July 07
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - fixed number of CPU regexp to be more accurate
|
||||
# - added $NAMELOC - fixes plugin so it works with VCI_SPACES (> 2.6.19) as well as older version
|
||||
|
||||
# TODO:
|
||||
# - comment the code or go mad
|
||||
# - add info how many jiffies per second are available on a machine
|
||||
# - user and system cpu are always added to each other, make it optional to split them?
|
||||
# - 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";'`
|
||||
|
||||
|
||||
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 by linking but not in the configuration-file by name
|
||||
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
|
||||
|
||||
BASEPARAM=`basename $0 | sed 's/^vserver_//'`
|
||||
MODE=`echo $BASEPARAM | sed 's/^hold.*//'`
|
||||
|
||||
#debug=true
|
||||
|
||||
if [ -z "$MODE" ] ; then
|
||||
MODE=hold
|
||||
TARGET=`echo $BASEPARAM | sed 's/^hold_//'`
|
||||
else
|
||||
MODE=cpu
|
||||
TARGET=`echo $BASEPARAM | sed 's/^cpu_//'`
|
||||
fi
|
||||
|
||||
CPU1=0
|
||||
if [ -n "$TARGET" ] ; then
|
||||
if [ "${#TARGET}" == 1 ] ; then
|
||||
if [ $debug ] ; then echo $MODE, only on cpu $TARGET, for all vservers ; fi
|
||||
WHAT=ALLVSERVER
|
||||
CPU1=$TARGET
|
||||
else
|
||||
if [ $debug ] ; then echo $MODE on all cpus together, only for vserver $TARGET ; fi
|
||||
WHAT=VSERVER
|
||||
fi
|
||||
else
|
||||
if [ $debug ] ; then echo $MODE for all cpus, for all vservers ; fi
|
||||
WHAT=ALLVSERVER
|
||||
fi
|
||||
|
||||
CPUS=$[ `grep ^processor /proc/cpuinfo|wc -l` -1 ]
|
||||
CPUS=`seq $CPU1 $CPUS`
|
||||
|
||||
if [ $debug ] ; then
|
||||
echo cpus= $CPUS
|
||||
echo baseparam= $BASEPARAM
|
||||
echo mode= $MODE
|
||||
echo target= $TARGET
|
||||
echo what= $WHAT
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_category vserver'
|
||||
echo 'graph_args --base 1000'
|
||||
if [ "$MODE" == "cpu" ] ; then
|
||||
echo 'graph_title Vserver cpu usage'
|
||||
echo 'graph_vlabel jiffies used per cpu per ${graph_period}'
|
||||
echo 'graph_info Shows jiffies used per cpu on each vserver.'
|
||||
else
|
||||
echo 'graph_title Vserver cpu on hold'
|
||||
echo 'graph_vlabel jiffies on hold per cpu per ${graph_period}'
|
||||
echo 'graph_info Shows jiffies on hold used per cpu on each vserver.'
|
||||
fi
|
||||
|
||||
for j in $CPUS ; do
|
||||
A=0
|
||||
for i in $XIDS ; do
|
||||
LABEL=`cat /proc/virtual/$i/$NAMELOC |grep NodeName |cut -f2`
|
||||
if [ "$WHAT" == "ALLVSERVER" ] || [ "$TARGET" == "$LABEL" ] ; then
|
||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
||||
if [ "$MODE" == "cpu" ] ; then
|
||||
echo "${NAME}_$j.label cpu usage for cpu $j on $LABEL"
|
||||
echo "${NAME}_$j.info cpu usage for cpu $j on $LABEL."
|
||||
else
|
||||
echo "${NAME}_$j.label on hold for cpu $j on $LABEL"
|
||||
echo "${NAME}_$j.info on hold for cpu $j on $LABEL."
|
||||
fi
|
||||
echo "${NAME}_$j.type COUNTER"
|
||||
if [ "$A" == 0 ] ; then
|
||||
echo "${NAME}_$j.draw AREA"
|
||||
A=1
|
||||
else
|
||||
echo "${NAME}_$j.draw STACK"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for j in $CPUS ; do
|
||||
for i in $XIDS ; do
|
||||
LABEL=`cat /proc/virtual/$i/$NAMELOC |grep NodeName |cut -f2`
|
||||
if [ "$WHAT" == "ALLVSERVER" ] || [ "$TARGET" == "$LABEL" ] ; then
|
||||
NAME=`echo $LABEL | cut -d. -f1 | tr '-' '_'`
|
||||
echo -n "${NAME}_$j.value "
|
||||
if [ "$MODE" == "cpu" ] ; then
|
||||
USERCPU=`cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f3`
|
||||
SYSCPU=`cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f4`
|
||||
echo $[$USERCPU + $SYSCPU]
|
||||
else
|
||||
cat /proc/virtual/$i/sched |grep "cpu $j"| cut -d' ' -f5
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
|
77
plugins/vserver/vserver_jiffies
Executable file
77
plugins/vserver/vserver_jiffies
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Created by Jan Rękorajski <baggins@pld-linux.org> based on vserver_cpu_ plugin.
|
||||
#
|
||||
# Graph Vserver cumulative cpu usage stats
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
#
|
||||
# NOTE: If no configuration variable is set, the default will be used
|
||||
#
|
||||
# see vserver_resources for example uses of configuration files
|
||||
|
||||
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 by linking but not in the configuration-file by name
|
||||
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
|
||||
echo 'graph_category vserver'
|
||||
echo 'graph_args --base 1000'
|
||||
echo 'graph_title Vserver cpu usage'
|
||||
echo 'graph_vlabel jiffies used per ${graph_period}'
|
||||
echo 'graph_info Shows jiffies used on each vserver.'
|
||||
|
||||
for i in $XIDS ; do
|
||||
LABEL=`grep NodeName /proc/virtual/$i/$NAMELOC | cut -f2`
|
||||
NAME=`echo $LABEL | tr '-' '_'`
|
||||
echo "${NAME}_hold.label on hold for cpu on $LABEL"
|
||||
echo "${NAME}_hold.info on hold for cpu on $LABEL."
|
||||
echo "${NAME}_hold.type COUNTER"
|
||||
echo "${NAME}_scpu.label system cpu usage for $LABEL"
|
||||
echo "${NAME}_scpu.info system cpu usage for $LABEL."
|
||||
echo "${NAME}_scpu.type COUNTER"
|
||||
echo "${NAME}_ucpu.label user cpu usage for $LABEL"
|
||||
echo "${NAME}_ucpu.info user cpu usage for $LABEL."
|
||||
echo "${NAME}_ucpu.type COUNTER"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for i in $XIDS ; do
|
||||
NAME=`grep NodeName /proc/virtual/$i/$NAMELOC | cut -f2 | tr '-' '_'`
|
||||
awk -v name=$NAME -v u=0 -v s=0 -v h=0 '
|
||||
/^cpu [0-9]+:/ { u+=$3; s+=$4; h+=$5}
|
||||
END {
|
||||
print name "_hold.value " h
|
||||
print name "_scpu.value " s
|
||||
print name "_ucpu.value " u
|
||||
}' /proc/virtual/$i/sched
|
||||
done
|
120
plugins/vserver/vserver_limit_hits
Executable file
120
plugins/vserver/vserver_limit_hits
Executable file
|
@ -0,0 +1,120 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2008 Chris Wilson
|
||||
# Copyright (C) 2006 Holger Levsen
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
# limits - if true, turn on limit graphing (default: false)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# The first group monitors 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.
|
||||
#
|
||||
# The second monitors the vservers "vserver5 vserver6 vserver7" and
|
||||
# has no limit notifications turned on.
|
||||
#
|
||||
# The third monitors all vservers on the system, in one graph, and it has
|
||||
# no limit notifications defined.
|
||||
#
|
||||
# You can use any combination of these to fit your needs.
|
||||
#
|
||||
#
|
||||
# [vsrmem_group1]
|
||||
# user root
|
||||
# env.vservers vserver1 vserver2 vserver3 vserver4
|
||||
# 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
|
||||
#
|
||||
# [vsrmem_group2]
|
||||
# user root
|
||||
# env.vservers vserver5 vserver6 vserver7
|
||||
# env.limits 0
|
||||
#
|
||||
# [vserver_rmemory]
|
||||
# user root
|
||||
#
|
||||
# Graph Vserver RSS usage and limits
|
||||
#
|
||||
# Changelog
|
||||
# version 0.1 - 2006 April xx - Holger Levsen
|
||||
# - initial author
|
||||
# version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net>
|
||||
# - Add dynamic arch page size determination
|
||||
# - Some cleanup and clarification
|
||||
# version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net>
|
||||
# - Add ability to group vservers via environment vars
|
||||
# - Fix missing close quotes and standardize indents
|
||||
# - Add limit notification
|
||||
# - Update documentation to include info on groups and limits
|
||||
# version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net>
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
# version 0.5 - 2008 Apr 12 - Chris Wilson <chris+munin@qwirx.com>
|
||||
# - Changed to display limit hits instead of resource usage
|
||||
# - Adapt to latest vserver kernel (lack of some variables in /proc/virtual)
|
||||
# Note that your vserver names may change if the contents of
|
||||
# /etc/vservers/* do not match the nodenames. Also you must specify
|
||||
# the vservers variable with context IDs (XIDs) rather than names.
|
||||
|
||||
scriptname=`basename $0`
|
||||
resource=`echo $scriptname | sed -e 's/.*_//'`
|
||||
vservers="$vservers"
|
||||
|
||||
if [ -z "$vservers" ]; then
|
||||
vservers=`ls -1 /proc/virtual | grep -v info | grep -v status`
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Vserver $resource limit hits"
|
||||
# echo 'graph_args --base 1024k -l 0'
|
||||
echo "graph_vlabel $resource limit hits"
|
||||
echo 'graph_category vserver'
|
||||
echo "graph_info Shows number of hits on $resource limits by each vserver.'"
|
||||
|
||||
for vserver_xid in $vservers ; do
|
||||
longname=`/usr/sbin/vuname --xid $vserver_xid NODENAME | cut -f2`
|
||||
name=`echo $longname | cut -d. -f1`
|
||||
echo "$vserver_xid.label $name"
|
||||
echo "$vserver_xid.info $resource limit hits by $longname"
|
||||
echo "$vserver_xid.critical 1"
|
||||
echo "$vserver_xid.min 0"
|
||||
echo "$vserver_xid.type DERIVE"
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif [ "$1" = "suggest" ]; then
|
||||
if [ -z "$vservers" ]; then
|
||||
echo "No vservers running, cannot suggest!" >&2
|
||||
exit 2
|
||||
fi
|
||||
vserver1=`echo $vservers | sed -e 's/ .*//'`
|
||||
tail -n +2 /proc/virtual/$vserver1/limit | sed -e 's/:.*//'
|
||||
else
|
||||
for vserver_xid in $vservers; do
|
||||
cat /proc/virtual/$vserver_xid/limit \
|
||||
| awk -v xid="$vserver_xid" -v res="$resource:" \
|
||||
'{ if ( $1 == res )
|
||||
printf "%s.value %d\n", xid, $7 }'
|
||||
done
|
||||
fi
|
96
plugins/vserver/vserver_limits
Executable file
96
plugins/vserver/vserver_limits
Executable file
|
@ -0,0 +1,96 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2008 Chris Wilson
|
||||
# Copyright (C) 2006 Holger Levsen
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
# limits - if true, turn on limit graphing (default: false)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# [vserver_limits_RSS]
|
||||
# user root
|
||||
# env.vservers 7 18 20 42
|
||||
#
|
||||
# Graph Vserver resource limits. Useful to help you know when and how often
|
||||
# you changed the limits of each vserver, e.g. because customer needed more
|
||||
# RAM.
|
||||
#
|
||||
# Changelog
|
||||
# version 0.1 - 2006 April xx - Holger Levsen
|
||||
# - initial author
|
||||
# version 0.2 - 2006 April 24 - Micah Anderson <micah@riseup.net>
|
||||
# - Add dynamic arch page size determination
|
||||
# - Some cleanup and clarification
|
||||
# version 0.3 - 2006 May 3 - Micah Anderson <micah@riseup.net>
|
||||
# - Add ability to group vservers via environment vars
|
||||
# - Fix missing close quotes and standardize indents
|
||||
# - Add limit notification
|
||||
# - Update documentation to include info on groups and limits
|
||||
# version 0.4 - 2006 Jun 22 - Micah Anderson <micah@riseup.net>
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
# version 0.5 - 2008 Apr 12 - Chris Wilson <chris+munin@qwirx.com>
|
||||
# - Changed to display limits instead of resource usage
|
||||
# - Adapt to latest vserver kernel (lack of some variables in /proc/virtual)
|
||||
# Note that your vserver names may change if the contents of
|
||||
# /etc/vservers/* do not match the nodenames. Also you must specify
|
||||
# the vservers variable with context IDs (XIDs) rather than names.
|
||||
|
||||
|
||||
scriptname=`basename $0`
|
||||
resource=`echo $scriptname | sed -e 's/.*_//'`
|
||||
vservers="$vservers"
|
||||
|
||||
if [ -z "$vservers" ]; then
|
||||
vservers=`ls -1 /proc/virtual | grep -v info | grep -v status`
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title Vserver $resource limits"
|
||||
# echo 'graph_args --base 1024k -l 0'
|
||||
echo "graph_vlabel $resource limits"
|
||||
echo 'graph_category vserver'
|
||||
echo "graph_info Shows current $resource limits for each vserver.'"
|
||||
|
||||
for vserver_xid in $vservers ; do
|
||||
longname=`/usr/sbin/vuname --xid $vserver_xid NODENAME | cut -f2`
|
||||
name=`echo $longname | cut -d. -f1`
|
||||
echo "$vserver_xid.label $name"
|
||||
echo "$vserver_xid.info $resource limits for $longname"
|
||||
echo "$vserver_xid.min 0"
|
||||
echo "$vserver_xid.type GAUGE"
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif [ "$1" = "suggest" ]; then
|
||||
if [ -z "$vservers" ]; then
|
||||
echo "No vservers running, cannot suggest!" >&2
|
||||
exit 2
|
||||
fi
|
||||
vserver1=`echo $vservers | sed -e 's/ .*//'`
|
||||
tail -n +2 /proc/virtual/$vserver1/limit | sed -e 's/:.*//'
|
||||
else
|
||||
for vserver_xid in $vservers; do
|
||||
cat /proc/virtual/$vserver_xid/limit \
|
||||
| awk -v xid="$vserver_xid" -v res="$resource:" \
|
||||
'{ if ( $1 == res )
|
||||
printf "%s.value %d\n", xid, $6 }'
|
||||
done
|
||||
fi
|
123
plugins/vserver/vserver_loadavg
Executable file
123
plugins/vserver/vserver_loadavg
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2007 Andrei Morgan
|
||||
# Copyright (C) 2008 Micah Anderson
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Graph Vserver load average
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# The following monitors the load average for vservers 1 and 3:
|
||||
#
|
||||
# [vserver_loadavg]
|
||||
# user root
|
||||
# env.vservers vserver1 vserver3
|
||||
|
||||
# Changelog
|
||||
# version 0.1 - 2007 June 26
|
||||
# Andrei Morgan <asm-debian@fifthhorseman.net>
|
||||
# - initial author, based upon vserver_resources by Holger Levsen and
|
||||
# Micah Anderson, and upon the examples in the munin wiki.
|
||||
# version 0.2 - 2008 July 7
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - fix cvirt vs. nsproxy issue with newer kernels by adding $NAMELOC which
|
||||
# is aware of VCI_SPACES (> 2.6.19) as well as the older version
|
||||
|
||||
# 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-config. In the case of this plugin, we should most probably
|
||||
# always be included whwn there is a vserver kernel.
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
echo yes
|
||||
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
|
||||
|
317
plugins/vserver/vserver_resources
Executable file
317
plugins/vserver/vserver_resources
Executable file
|
@ -0,0 +1,317 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2006-2008 Holger Levsen, Micah Anderson
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Graph Vserver resource usage and limits
|
||||
#
|
||||
# Configuration variables
|
||||
# vservers - specify the vservers to include in the graph (default: all)
|
||||
# resource - specify the resource to be monitored (no default)
|
||||
# limits - if true, turn on limit graphing (default: false)
|
||||
#
|
||||
# NOTE: If no configuration variables are set, the defaults will be used
|
||||
|
||||
# Example /etc/munin/plugin-conf.d/munin-node
|
||||
#
|
||||
# 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
|
||||
|
||||
# Possible values for env.resource are:
|
||||
#
|
||||
# ALL - all the below resources
|
||||
# PROC - number of processes
|
||||
# VM - sum of all virtual pages inside the guest
|
||||
# VML - sum of all virtual pages locked into memory
|
||||
# RSS - number of pages currently present in RAM
|
||||
# ANON - number of anonymous memory pages
|
||||
# FILES - number of open files
|
||||
# OFD
|
||||
# LOCKS
|
||||
# SOCK
|
||||
# MSGQ
|
||||
# SHM - number of shared memory pages
|
||||
|
||||
# Changelog
|
||||
# version 0.1 - 2006 April xx
|
||||
# Holger Levsen <debian@layer-acht.org>
|
||||
# - initial author
|
||||
# version 0.2 - 2006 April 24
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - Add dynamic arch page size determination
|
||||
# - Some cleanup and clarification
|
||||
# version 0.3 - 2006 May 3
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - Add ability to group vservers via environment vars
|
||||
# - Fix missing close quotes and standardize indents
|
||||
# - Add limit notification
|
||||
# - Update documentation to include info on groups and limits
|
||||
# version 0.4 - 2006 Jun 22
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - Fix error that results if NodeName is set to include a domain name
|
||||
# version 0.5 - 2006 Oct
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - fixed changelog entries so more changes can happen per version
|
||||
# - standardized changelog date and name format
|
||||
# - added myself to copyright
|
||||
# - standardized indentation
|
||||
# - abstracted from just RSS to be usable for any resource specified
|
||||
# Holger Levsen <debian@layer-acht.org>
|
||||
# - Fix hypens in NodeNames, replace them with underscores
|
||||
# - Fix the fix from version 0.4
|
||||
# - allow specifying the ressource by linking
|
||||
# (ln -s vserver_resources vserver_VM)
|
||||
# - provided info about all resources
|
||||
# - code cleaned
|
||||
# - errors if an invalid resource is specified
|
||||
# - handle identical vserver-names by using the vserver-id internally
|
||||
# version 0.6 - 2007 Oct
|
||||
# Micah Anderson <micah@riseup.net>
|
||||
# - removed BASENAME - plugin isn't a wildcard plugin any longer
|
||||
# - added $NAMELOC - fixes plugin so it works with VCI_SPACES (> 2.6.19) as well as older version
|
||||
#
|
||||
# TODO:
|
||||
# - make it so you can specify more than one resource to be graphed?
|
||||
# or 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
|
||||
# - set a default for the resource if it is unset?
|
||||
# - 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";'`
|
||||
# - ALL resource is broken
|
||||
|
||||
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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue