2008-07-25 23:53:08 +02:00
|
|
|
#!/bin/sh
|
2012-07-24 15:01:01 +02:00
|
|
|
# -*- sh -*-
|
|
|
|
|
|
|
|
: << EOF
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
lvm_ - Wildcard plugin for monitoring disk usage on LVM. Each Volume Group is graphed separately.
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
This plugin needs to run as the root user in order to have permission to run lvs and vgs
|
|
|
|
|
|
|
|
[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
|
2008-07-25 23:53:08 +02:00
|
|
|
|
2015-05-17 17:20:31 +02:00
|
|
|
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
|
|
|
|
|
|
|
2008-07-25 23:53:08 +02:00
|
|
|
if [ "$1" = "autoconf" ]; then
|
2012-08-21 13:07:59 +02:00
|
|
|
if ! command -v lvs >/dev/null; then
|
2012-07-24 14:46:19 +02:00
|
|
|
echo "no (lvs not found)"
|
2012-08-21 13:07:59 +02:00
|
|
|
elif ! command -v vgs >/dev/null; then
|
2012-07-24 14:46:19 +02:00
|
|
|
echo "no (vgs not found)"
|
|
|
|
else
|
|
|
|
echo "yes"
|
|
|
|
fi
|
|
|
|
exit 0
|
2008-07-25 23:53:08 +02:00
|
|
|
fi
|
|
|
|
|
2012-07-23 17:52:42 +02:00
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
vgs -o vg_name --noheadings | sed -e 's/\ *//'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
vg=`echo $0 | awk '{ sub(".*lvm_","",\$1); print \$1; }'`
|
2008-07-25 23:53:08 +02:00
|
|
|
|
|
|
|
clean_name() {
|
2015-05-17 17:20:31 +02:00
|
|
|
echo "$(clean_fieldname "$1")"
|
2008-07-25 23:53:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
2012-07-23 18:14:16 +02:00
|
|
|
echo "graph_title Logical Volume Usage($vg)"
|
2012-07-23 16:44:00 +02:00
|
|
|
echo 'graph_args --base 1024 -l 0'
|
2008-07-25 23:53:08 +02:00
|
|
|
echo 'graph_category disk'
|
|
|
|
echo 'graph_info This graph shows disk usage on the machine.'
|
|
|
|
echo "free.label free"
|
|
|
|
echo "free.draw AREA"
|
|
|
|
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
|
|
|
|
name=`clean_name $i`
|
|
|
|
echo -n "$name.label "
|
|
|
|
echo $i | awk '{ print $1 }'
|
|
|
|
echo "$name.draw STACK"
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
i=`vgs --units b --nosuffix --noheadings | grep "$vg"`
|
|
|
|
echo -n "free.value "
|
|
|
|
echo $i | awk '{ print $7 }'
|
|
|
|
|
|
|
|
lvs --units b --nosuffix --noheadings | grep "$vg" | while read i; do
|
|
|
|
name=`clean_name $i`
|
|
|
|
echo -n "$name.value "
|
|
|
|
echo $i | awk '{ print $4 }'
|
|
|
|
done
|