munin-plugins/lvm_

100 lines
1.9 KiB
Text
Raw Normal View History

2021-06-16 11:39:04 +02:00
#!/bin/sh
# -*- sh -*-
: << EOF
=head1 NAME
lvm_ - Wildcard plugin for monitoring disk usage on LVM. Each Volume Group is graphed separately.
=head1 CONFIGURATION
2021-06-16 12:11:26 +02:00
This plugin needs to run as the root user in order to have permission to run sudo lvs and vgs
2021-06-16 11:39:04 +02:00
[lvm_*]
user root
=head1 AUTHOR
=over 4
=item * PatrickDK (Original Author)
=item * Niall Donegan
=back
=head1 LICENSE
Unknown license
=head1 MAGIC MARKERS
=begin comment
These magic markers are used by munin-node-configure when installing
munin-node.
=end comment
#%# family=auto
#%# capabilities=autoconf suggest
=cut
EOF
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
2021-06-16 12:11:26 +02:00
if ! command -v sudo lvs >/dev/null; then
echo "no (sudo lvs not found)"
2021-06-16 11:39:04 +02:00
elif ! command -v vgs >/dev/null; then
echo "no (vgs not found)"
else
echo "yes"
fi
exit 0
fi
if [ "$1" = "suggest" ]; then
2021-06-16 12:15:28 +02:00
sudo vgs -o vg_name --noheadings | sed -e 's/\ *//'
2021-06-16 11:39:04 +02:00
exit 0
fi
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
clean_name() {
echo "$(clean_fieldname "$1")"
}
if [ "$1" = "config" ]; then
echo "graph_title Logical Volume Usage($vg)"
echo 'graph_args --base 1024 -l 0'
echo 'graph_category disk'
echo 'graph_info This graph shows disk usage on the machine.'
echo "free.label free"
echo "free.draw AREA"
2021-06-16 12:11:26 +02:00
sudo lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
2021-06-16 11:39:04 +02:00
name=`clean_name $i`
echo -n "$name.label "
echo $i | awk '{ print $1 }'
echo "$name.draw STACK"
done
exit 0
fi
2021-06-16 12:15:28 +02:00
i=`sudo vgs --units b --nosuffix --noheadings | grep "$vg"`
2021-06-16 11:39:04 +02:00
echo -n "free.value "
echo $i | awk '{ print $7 }'
2021-06-16 12:11:26 +02:00
sudo lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
2021-06-16 11:39:04 +02:00
name=`clean_name $i`
echo -n "$name.value "
echo $i | awk '{ print $4 }'
done