1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 18:07:20 +00:00
Munin-Contrib/plugins/lxc/lxc_cpu_time

77 lines
1.1 KiB
Bash
Executable file

#!/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
if [ -r /proc/stat ]; then
echo yes
exit 0
else
echo "no (no /proc/stat)"
exit 0
fi
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