mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
87 lines
1.6 KiB
Bash
Executable file
87 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# -*- sh -*-
|
|
|
|
: << =cut
|
|
|
|
=head1 NAME
|
|
|
|
lxc_ram - Plugin to monitor LXC memory 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 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
|
|
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
|