diff --git a/plugins/lxc/README b/plugins/lxc/README deleted file mode 100644 index b259f704..00000000 --- a/plugins/lxc/README +++ /dev/null @@ -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 diff --git a/plugins/lxc/lxc-lib b/plugins/lxc/lxc-lib deleted file mode 100644 index bf9687ae..00000000 --- a/plugins/lxc/lxc-lib +++ /dev/null @@ -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 -} diff --git a/plugins/lxc/lxc_cpu b/plugins/lxc/lxc_cpu deleted file mode 100755 index f501cad2..00000000 --- a/plugins/lxc/lxc_cpu +++ /dev/null @@ -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 </tasks -# Ubuntu 12.04 with fstab: /sys/fs/cgroup/lxc//tasks -# Ubuntu 12.04 with cgroup-lite: /sys/fs/cgroup/cpuacct/lxc//tasks -# Ubuntu 12.04 with cgroup-bin: /sys/fs/cgroup/cpuacct/sysdefault/lxc//tasks -# Ubuntu 14.04 /sys/fs/cgroup/systemd/lxc//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 <