1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 10:28:36 +00:00
Munin-Contrib/plugins/lxc/lxc_logins

65 lines
860 B
Bash
Executable file

#!/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