2012-12-31 15:13:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-01-02 16:50:27 +01:00
|
|
|
true << =cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
ext2 - Wildcard plugin shows ext2/3/4 filesystem information (mount count, last checked, lifetime writes)
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
[ext2_*]
|
|
|
|
group disk,floppy
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Andreas Hrubak <>
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
GPLv2
|
|
|
|
|
|
|
|
=head1 MAGICK MARKERS
|
|
|
|
|
|
|
|
#%# family=disk
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
=cut
|
2012-12-31 15:13:41 +01:00
|
|
|
|
|
|
|
print_details() {
|
|
|
|
local myname
|
|
|
|
while read line; do
|
|
|
|
key=${line%%:*}
|
|
|
|
val=`echo ${line#*:}`
|
|
|
|
val1=${val%% *}
|
|
|
|
[ -z "$line" ] && break
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2012-12-31 15:13:41 +01:00
|
|
|
case "$key" in
|
|
|
|
"Mount count") myname=$1; mc=$val ;;
|
|
|
|
"Maximum mount count") mmc=$val ;;
|
|
|
|
"Last checked") lcts=`date +%s -d "$val" 2>/dev/null` ;;
|
|
|
|
"Check interval") ciis=$val1 ;;
|
|
|
|
"Lifetime writes") lwGB=$val1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
[ -n "$myname" ] && echo "$myname ${mc:-0} ${mmc:-0} ${lcts:-0} ${ciis:-0} ${lwGB:-0}"
|
|
|
|
}
|
|
|
|
|
|
|
|
lse2() {
|
|
|
|
for name in {h,s}d{a..z}{1..16}; do
|
|
|
|
if [ -b /dev/$name ]; then
|
|
|
|
LANG=C dumpe2fs /dev/$name 2>/dev/null | print_details "$name"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
2013-01-02 16:50:27 +01:00
|
|
|
if which dumpe2fs >/dev/null 2>&1; then
|
2012-12-31 15:13:41 +01:00
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo no
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
|
|
lse2 | while read name rest; do
|
|
|
|
echo mounts_$name
|
|
|
|
echo checked_$name
|
|
|
|
echo writes_$name
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
self=${0##*/}
|
|
|
|
self=${self#*_}
|
|
|
|
plugin=${self%%_*}
|
|
|
|
if [ -n "${self//[!_]/}" ]; then
|
|
|
|
blkdev=${self#*_}
|
|
|
|
blkdevAppend=" ($blkdev)"
|
|
|
|
else
|
|
|
|
blkdev=
|
|
|
|
blkdevAppend=
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
|
|
|
|
echo "graph_category disk"
|
2012-12-31 15:46:43 +01:00
|
|
|
args="-l 0"
|
2012-12-31 15:13:41 +01:00
|
|
|
case "$plugin" in
|
2018-08-02 02:03:42 +02:00
|
|
|
mounts)
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "graph_vlabel times"
|
|
|
|
echo "graph_title Ext2 Filesystem mount details"
|
|
|
|
;;
|
|
|
|
checked)
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "graph_vlabel days"
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "graph_title Ext2 Filesystem fsck interval"
|
|
|
|
;;
|
2018-08-02 02:03:42 +02:00
|
|
|
writes)
|
2012-12-31 15:46:43 +01:00
|
|
|
args="$args --base 1024"
|
|
|
|
echo "graph_vlabel bytes"
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "graph_title Ext2 Filesystem lifetime writes$blkdevAppend"
|
|
|
|
;;
|
|
|
|
esac
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "graph_args $args"
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2012-12-31 15:13:41 +01:00
|
|
|
if [ -z "$blkdev" ]; then
|
|
|
|
lse2
|
|
|
|
else
|
|
|
|
LANG=C dumpe2fs /dev/$blkdev 2>/dev/null | print_details "$blkdev"
|
|
|
|
fi | \
|
|
|
|
while read name mounts maxmounts last interval writes; do
|
|
|
|
[ -z "$blkdev" ] && blkdevAppend2=" ($name)" || blkdevAppend2=
|
|
|
|
case "$plugin" in
|
|
|
|
mounts)
|
|
|
|
echo "${name}_mounts.label Mount count$blkdevAppend2"
|
|
|
|
echo "${name}_mounts.draw LINE2"
|
|
|
|
echo "${name}_maxmounts.label Max. mount count$blkdevAppend2"
|
|
|
|
echo "${name}_maxmounts.draw LINE1"
|
|
|
|
;;
|
|
|
|
checked)
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "${name}_last.label Since checked$blkdevAppend2"
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "${name}_last.draw LINE2"
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "${name}_last.cdef ${name}_last,86400,/"
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "${name}_interval.label Check interval$blkdevAppend2"
|
|
|
|
echo "${name}_interval.draw LINE1"
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "${name}_interval.cdef ${name}_interval,86400,/"
|
2012-12-31 15:13:41 +01:00
|
|
|
;;
|
|
|
|
writes)
|
|
|
|
echo "${name}_writes.label Lifetime writes$blkdevAppend2"
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "${name}_writes.type GAUGE"
|
2012-12-31 15:13:41 +01:00
|
|
|
echo "${name}_writes.draw LINE2"
|
2012-12-31 15:46:43 +01:00
|
|
|
echo "${name}_writes.cdef ${name}_writes,1073741824,*"
|
2012-12-31 15:13:41 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## fetch ##
|
|
|
|
|
|
|
|
if [ -z "$blkdev" ]; then
|
|
|
|
lse2
|
|
|
|
else
|
|
|
|
LANG=C dumpe2fs /dev/$blkdev 2>/dev/null | print_details "$blkdev"
|
|
|
|
fi | \
|
|
|
|
while read name mounts maxmounts last interval writes; do
|
|
|
|
case "$plugin" in
|
|
|
|
mounts)
|
|
|
|
echo "${name}_mounts.value $mounts"
|
|
|
|
echo "${name}_maxmounts.value $maxmounts"
|
|
|
|
;;
|
|
|
|
checked)
|
|
|
|
now=`date +%s`
|
|
|
|
past=$(( now - last ))
|
|
|
|
echo "${name}_last.value $past"
|
|
|
|
echo "${name}_interval.value $interval"
|
|
|
|
;;
|
|
|
|
writes)
|
|
|
|
echo "${name}_writes.value $writes"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2012-12-31 15:46:43 +01:00
|
|
|
|