mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
Initial version of multigraph version
This commit is contained in:
parent
154ffc100b
commit
ddcc19cd81
8 changed files with 0 additions and 634 deletions
|
@ -1,11 +0,0 @@
|
|||
This works for lxc 3 (and lxc 2, as long as you don't have
|
||||
cruft in your config file, test it with:
|
||||
lxc-cgroup -o /dev/stdout -l INFO -n 104 cpuacct.usage
|
||||
-- with 104 a valid lxc instance)
|
||||
|
||||
Tested on Debian buster and Debian jessie.
|
||||
|
||||
See the individual files for copyright and installation/configuration
|
||||
information.
|
||||
|
||||
This is version 1.3 by schaefer@alphanet.ch
|
|
@ -1,80 +0,0 @@
|
|||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc-lib -- some base functions for the lxc_* plugins
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
schaefer@alphanet.ch
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv3
|
||||
|
||||
=cut
|
||||
|
||||
lxcpath=${lxcpath:-/var/lib/lxc}
|
||||
|
||||
function active_guests {
|
||||
local g active i ok
|
||||
for g in $(lxc-ls | sort -u)
|
||||
do
|
||||
# handle optional exclude list in $1
|
||||
ok=1
|
||||
for i in $1
|
||||
do
|
||||
if [ "$i" = "$g" ]; then
|
||||
ok=0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ok = 1 ]; then
|
||||
if lxc-info -n $g 2>&1 | grep -qs RUNNING; then
|
||||
active="$active $g"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo $active
|
||||
}
|
||||
|
||||
function lxc_cgroup {
|
||||
# lxc3 (lxc < 3: may output some warnings if there is cruft in your config dir)
|
||||
lxc-cgroup -o /dev/stdout -l INFO $* | sed 's/^.*lxc_cgroup.c:main:[0-9][0-9]* - //'
|
||||
}
|
||||
|
||||
function lxc_clean_fieldname {
|
||||
# clean_fieldname should be used on the whole identifier, not just the
|
||||
# lxc instance ID, because if it is only numeric, the first digit will
|
||||
# be replaced with a "_"; this is a work-around
|
||||
case "${1::1}" in
|
||||
[0-9]) echo $(clean_fieldname ${1::1}$1);; # 104 -> __104
|
||||
*) echo $(clean_fieldname $1);;
|
||||
esac
|
||||
}
|
||||
|
||||
function lxc_netdev {
|
||||
local g=$1 dev
|
||||
|
||||
if [ -f $lxcpath/$g/config ]; then
|
||||
# lxc 3 vs < 3
|
||||
(egrep '^lxc.net.0.veth.pair' $lxcpath/$g/config 2>/dev/null \
|
||||
|| egrep '^lxc.network.veth.pair' $lxcpath/$g/config
|
||||
) | awk '{print $NF;}'
|
||||
else
|
||||
echo unknown
|
||||
fi
|
||||
}
|
||||
|
||||
# BUGS
|
||||
# - I don't think this is enough or even appropriate
|
||||
function lxc_autoconf {
|
||||
if [ -r /proc/stat ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no /proc/stat)"
|
||||
exit 0
|
||||
fi
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_cpu - Plugin to monitor LXC CPU usage
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[lxc_*]
|
||||
user root
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin needs root privilege.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
vajtsz vajtsz@gmail.com
|
||||
mitty mitty@mitty.jp
|
||||
(many changes schaefer@alphanet.ch)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
2-clause BSD License
|
||||
or GPLv3 license, at your option
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title CPU Usage
|
||||
graph_args -l 0 --base 1000
|
||||
graph_vlabel USER_HZ
|
||||
graph_category lxc
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
for i in user system
|
||||
do
|
||||
cat <<EOF
|
||||
cpu_${i}_${g}.label $n: $(echo ${i:0:1} | tr "[:lower:]" "[:upper:]")${i:1}
|
||||
cpu_${i}_${g}.type DERIVE
|
||||
cpu_${i}_${g}.min 0
|
||||
EOF
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
|
||||
for i in user system
|
||||
do
|
||||
echo "cpu_${i}_${g}.value $(lxc_cgroup -n $n cpuacct.stat | grep $i | awk '{ print $2; }')"
|
||||
done
|
||||
done
|
|
@ -1,71 +0,0 @@
|
|||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_cpu_time - Plugin to monitor LXC CPU time usage
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[lxc_*]
|
||||
user root
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin needs root privilege.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
vajtsz vajtsz@gmail.com
|
||||
mitty mitty@mitty.jp
|
||||
(many changes schaefer@alphanet.ch)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
2-clause BSD License
|
||||
or GPLv3 license, at your option
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title CPU time
|
||||
graph_args -l 0 --base 1000
|
||||
graph_vlabel nanosec
|
||||
graph_category lxc
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
cat <<EOF
|
||||
cpu_time_${g}.label $n: CPU time
|
||||
cpu_time_${g}.type DERIVE
|
||||
cpu_time_${g}.min 0
|
||||
EOF
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
echo "cpu_time_${g}.value $(lxc_cgroup -n $n cpuacct.usage)"
|
||||
done
|
|
@ -1,65 +0,0 @@
|
|||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_logins - Plugin to monitor LXC logins
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[lxc_*]
|
||||
user root
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin needs root privilege.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
schaefer@alphanet.ch
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv3
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title Logins
|
||||
graph_category lxc
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
cat <<EOF
|
||||
logins_${g}.label $n: logins
|
||||
logins_${g}.type GAUGE
|
||||
EOF
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
echo "logins_${g}.value $(lxc-attach -n $n users | wc -w | bc)"
|
||||
done
|
|
@ -1,116 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_net - Munin plugin to graph traffic of active LXC containers.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
LXC container with "lxc.network.type=veth" and "lxc.network.veth.pair" settings.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
env.lxcpath - Set the path where LXC containers are stored, default: /var/lib/lxc
|
||||
env.exclude - Removing containers from graphs, default: empty
|
||||
|
||||
[lxc_net]
|
||||
env.lxcpath /var/lib/lxc
|
||||
env.exclude container1 container2
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin reads a "lxc.network.veth.pair" setting from "config" file of each container,
|
||||
because lxc-start command creates a random named veth device without the setting, which
|
||||
changes at each run.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
mitty mitty@mitty.jp
|
||||
(many changes schaefer@alphanet.ch)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
2-clause BSD License
|
||||
or GPLv3 license, at your option
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests $exclude)
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ ! -r /proc/net/dev ]; then
|
||||
echo "no (/proc/net/dev cannot be read)"
|
||||
exit 0
|
||||
fi
|
||||
if [ ! -e "$lxcpath" ]; then
|
||||
echo "no ($lxcdir is not present)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title Network traffic
|
||||
graph_args --base 1000
|
||||
graph_vlabel bits in (-) / out (+) per ${graph_period}
|
||||
graph_category lxc
|
||||
graph_info This graph shows the traffic of active LXC containers.
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
device=$(lxc_netdev $n)
|
||||
if [ "$device" = "unknown" ]; then
|
||||
continue
|
||||
fi
|
||||
bps="U"
|
||||
if [ -r /sys/class/net/$device/speed ]; then
|
||||
bps=$(($(cat /sys/class/net/$device/speed) * 1000 * 1000))
|
||||
fi
|
||||
cat <<EOF
|
||||
net_${g}_down.label $n
|
||||
net_${g}_down.type DERIVE
|
||||
net_${g}_down.graph no
|
||||
net_${g}_down.cdef net_${g}_down,8,*
|
||||
net_${g}_down.min 0
|
||||
net_${g}_down.max $bps
|
||||
net_${g}_up.label $n
|
||||
net_${g}_up.type DERIVE
|
||||
net_${g}_up.negative net_${g}_down
|
||||
net_${g}_up.cdef net_${g}_up,8,*
|
||||
net_${g}_up.min 0
|
||||
net_${g}_up.max $bps
|
||||
EOF
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
device=$(lxc_netdev $n)
|
||||
if [ "$device" = "unknown" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
net_${g}_up.value $(egrep "^ *${device}:" /proc/net/dev | awk '{print $10;}')
|
||||
net_${g}_down.value $(egrep "^ *${device}:" /proc/net/dev | awk '{print $2;}')
|
||||
EOF
|
||||
done
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_proc - Plugin to monitor LXC Processes count
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
env.cgrouppath - Set the path where 'tasks' sysfs files are stored, default: empty
|
||||
|
||||
[lxc_proc]
|
||||
user root
|
||||
env.cgrouppath /sys/fs/cgroup/cpuacct/lxc/
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin needs root privilege.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
vajtsz vajtsz@gmail.com
|
||||
(many changes schaefer@alphanet.ch)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
2-clause BSD License
|
||||
or GPLv3 license, at your option
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests)
|
||||
|
||||
## find proper sysfs and count it
|
||||
# Debian 6.0: /sys/fs/cgroup/<container>/tasks
|
||||
# Ubuntu 12.04 with fstab: /sys/fs/cgroup/lxc/<container>/tasks
|
||||
# Ubuntu 12.04 with cgroup-lite: /sys/fs/cgroup/cpuacct/lxc/<container>/tasks
|
||||
# Ubuntu 12.04 with cgroup-bin: /sys/fs/cgroup/cpuacct/sysdefault/lxc/<container>/tasks
|
||||
# Ubuntu 14.04 /sys/fs/cgroup/systemd/lxc/<container>/tasks
|
||||
# and with cgmanager on jessie
|
||||
count_processes () {
|
||||
[ -z "$1" ] && return 0
|
||||
|
||||
if [ -n "$cgrouppath" ]; then
|
||||
SYSFS=$cgrouppath/$1/tasks
|
||||
if [ -e $SYSFS ]; then
|
||||
return `wc -l < $SYSFS`
|
||||
fi
|
||||
fi
|
||||
|
||||
for SYSFS in \
|
||||
/sys/fs/cgroup/$1/tasks \
|
||||
/sys/fs/cgroup/lxc/$1/tasks \
|
||||
/sys/fs/cgroup/systemd/lxc/$1/tasks \
|
||||
/sys/fs/cgroup/cpuacct/lxc/$1/tasks \
|
||||
/sys/fs/cgroup/cpuacct/sysdefault/lxc/$1/tasks
|
||||
do
|
||||
if [ -e $SYSFS ]; then
|
||||
return `wc -l < $SYSFS`
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e /usr/bin/cgm ]; then
|
||||
return `cgm getvalue cpu lxc/$1 tasks 2>/dev/null | wc -l`
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title Processes
|
||||
graph_args -l 0 --base 1000
|
||||
graph_vlabel Number of processes
|
||||
graph_category lxc
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
cat <<EOF
|
||||
lxc_proc_${g}.label $n: processes
|
||||
lxc_proc_${g}.type GAUGE
|
||||
lxc_proc_${g}.min 0
|
||||
EOF
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
|
||||
count_processes $n
|
||||
tmp_g=$?
|
||||
if [ $tmp_g -eq 0 ]; then
|
||||
tmp_g=$(lxc_cgroup -n $n tasks | wc -l)
|
||||
fi
|
||||
echo "lxc_proc_${g}.value $tmp_g"
|
||||
done
|
|
@ -1,98 +0,0 @@
|
|||
#!/bin/bash
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
lxc_ram - Plugin to monitor LXC memory usage.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
[lxc_*]
|
||||
user root
|
||||
|
||||
[lxc_ram]
|
||||
env.areastack true
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin needs root privilege.
|
||||
|
||||
If env.areastack is set to true, all memory usages of containers will be
|
||||
drawn as stacked area charts.
|
||||
This option changes graph order, all of 'Mem usage' comes first and then others.
|
||||
(default: false)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
vajtsz vajtsz@gmail.com
|
||||
mitty mitty@mitty.jp
|
||||
(many changes schaefer@alphanet.ch)
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
2-clause BSD License
|
||||
or GPLv3 license, at your option
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/lxc-lib
|
||||
|
||||
active_guests=$(active_guests)
|
||||
|
||||
# configurable: true/false
|
||||
areastack=${areastack:-false}
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
lxc_autoconf
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
cat <<EOF
|
||||
graph_title Memory
|
||||
graph_args -l 0 --base 1024
|
||||
graph_vlabel byte
|
||||
graph_category lxc
|
||||
EOF
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
cat <<EOF
|
||||
mem_usage_${g}.label ${n}: Mem usage
|
||||
mem_usage_${g}.type GAUGE
|
||||
EOF
|
||||
if [ "$areastack" = "true" ]; then
|
||||
echo "mem_usage_${g}.draw AREASTACK"
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
mem_cache_${g}.label ${n}: Cache
|
||||
mem_cache_${g}.type GAUGE
|
||||
mem_active_${g}.label ${n}: Active
|
||||
mem_active_${g}.type GAUGE
|
||||
mem_inactive_${g}.label ${n}: Inactive
|
||||
mem_inactive_${g}.type GAUGE
|
||||
EOF
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for n in $active_guests
|
||||
do
|
||||
g=$(lxc_clean_fieldname $n)
|
||||
cat <<EOF
|
||||
mem_usage_${g}.value $(lxc_cgroup -n $n memory.usage_in_bytes)
|
||||
mem_cache_${g}.value $(lxc_cgroup -n $n memory.stat | grep total_cache | awk '{print $2;}')
|
||||
mem_active_${g}.value $(lxc_cgroup -n $n memory.stat | grep total_active_anon | awk '{print $2;}')
|
||||
mem_inactive_${g}.value $(lxc_cgroup -n $n memory.stat | grep total_inactive_anon | awk '{print $2;}')
|
||||
EOF
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue