root / plugins / disk / lvm_snap_used @ 17f78427
Historique | Voir | Annoter | Télécharger (1,1 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
# |
| 3 |
# Plugin to monitor the % of allocated area of a LVM snapshot |
| 4 |
# |
| 5 |
# Parameters: |
| 6 |
# |
| 7 |
# config |
| 8 |
# autoconf |
| 9 |
# |
| 10 |
# Configuration variables |
| 11 |
# no config variables |
| 12 |
# |
| 13 |
#%# family=auto |
| 14 |
#%# capabilities=autoconf |
| 15 |
# |
| 16 |
# 2011/05/20 - pmoranga - initial version |
| 17 |
# |
| 18 |
# 2012/01/27 - Sébastien Gross |
| 19 |
# - Fix lvdisplay path |
| 20 |
|
| 21 |
|
| 22 |
. $MUNIN_LIBDIR/plugins/plugin.sh |
| 23 |
|
| 24 |
lvdisplay=$(which lvdisplay) |
| 25 |
|
| 26 |
if [ "$1" = "autoconf" ]; then |
| 27 |
if test -n "${lvdisplay}"; then
|
| 28 |
echo yes |
| 29 |
exit 0 |
| 30 |
fi |
| 31 |
echo "no lvdisplay found" |
| 32 |
exit 1 |
| 33 |
fi |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
if [ "$1" = "config" ]; then |
| 38 |
echo 'graph_title Allocated space for snapshot' |
| 39 |
echo 'graph_vlabel %' |
| 40 |
echo 'graph_category disk' |
| 41 |
echo 'graph_args -l 0 -u 100 -r' |
| 42 |
fi |
| 43 |
|
| 44 |
|
| 45 |
${lvdisplay} -C | awk '$3 ~ /^s/{print}' | while read line; do
|
| 46 |
name="$(echo $line | awk '{print $1}')"
|
| 47 |
id="$(clean_fieldname "$name")" |
| 48 |
origin="$(echo $line | awk '{print $5}')"
|
| 49 |
origin="$(clean_fieldname "$origin")" |
| 50 |
percent="$(echo $line | awk '{print $6}')"
|
| 51 |
|
| 52 |
if [ "$1" = "config" ]; then |
| 53 |
echo "$id.label $name snapshot of $origin" |
| 54 |
else |
| 55 |
echo "$id.value $percent" |
| 56 |
fi |
| 57 |
done |
