2011-06-20 16:26:23 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Plugin to monitor the % of allocated area of a LVM snapshot
|
|
|
|
#
|
|
|
|
# Parameters:
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2011-06-20 16:26:23 +02:00
|
|
|
# config
|
|
|
|
# autoconf
|
|
|
|
#
|
|
|
|
# Configuration variables
|
|
|
|
# no config variables
|
|
|
|
#
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2011-06-20 16:26:23 +02:00
|
|
|
# 2011/05/20 - pmoranga - initial version
|
2012-01-27 17:07:41 +01:00
|
|
|
#
|
|
|
|
# 2012/01/27 - Sébastien Gross
|
|
|
|
# - Fix lvdisplay path
|
|
|
|
|
2015-05-17 17:20:31 +02:00
|
|
|
|
|
|
|
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
|
|
|
2012-01-27 17:07:41 +01:00
|
|
|
lvdisplay=$(which lvdisplay)
|
2011-06-20 16:26:23 +02:00
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2012-01-27 17:07:41 +01:00
|
|
|
if test -n "${lvdisplay}"; then
|
|
|
|
echo yes
|
2018-09-16 04:09:21 +02:00
|
|
|
else
|
|
|
|
echo "no (lvdisplay not found)"
|
2012-01-27 17:07:41 +01:00
|
|
|
fi
|
2018-09-16 04:09:21 +02:00
|
|
|
exit 0
|
2011-06-20 16:26:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
2018-08-02 02:03:42 +02:00
|
|
|
echo 'graph_title Allocated space for snapshot'
|
2011-06-20 16:26:23 +02:00
|
|
|
echo 'graph_vlabel %'
|
|
|
|
echo 'graph_category disk'
|
2015-05-17 17:20:31 +02:00
|
|
|
echo 'graph_args -l 0 -u 100 -r'
|
2011-06-20 16:26:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-05-17 17:20:31 +02:00
|
|
|
${lvdisplay} -C | awk '$3 ~ /^s/{print}' | while read line; do
|
|
|
|
name="$(echo $line | awk '{print $1}')"
|
|
|
|
id="$(clean_fieldname "$name")"
|
|
|
|
origin="$(echo $line | awk '{print $5}')"
|
|
|
|
origin="$(clean_fieldname "$origin")"
|
|
|
|
percent="$(echo $line | awk '{print $6}')"
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2015-05-17 17:20:31 +02:00
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "$id.label $name snapshot of $origin"
|
|
|
|
else
|
|
|
|
echo "$id.value $percent"
|
|
|
|
fi
|
|
|
|
done
|