mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
78 lines
1.2 KiB
Bash
Executable file
78 lines
1.2 KiB
Bash
Executable file
#!/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
|