2012-11-01 13:55:13 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# Detect and display Linux sw-raid mismatch count
|
|
|
|
# Copyright (C) 2011 Rory Jaffe <rsjaffe@gmail.com>
|
|
|
|
# derived from md_sync_speed by Kristian Lyngstøl
|
|
|
|
# Copyright (C) 2010 Kristian Lyngstøl <kristian@bohemians.org>
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2012-11-01 13:55:13 +01:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2012-11-01 13:55:13 +01:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2012-11-01 13:55:13 +01:00
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#####
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2012-11-01 13:55:13 +01:00
|
|
|
# Magic Markers:
|
|
|
|
# #%# family=auto
|
|
|
|
# #%# capabilities=autoconf
|
|
|
|
|
|
|
|
|
2015-05-04 18:02:49 +02:00
|
|
|
targets=`ls /sys/devices/virtual/block/*/md/mismatch_cnt 2> /dev/null | cut -d/ -f6`
|
2012-11-01 13:55:13 +01:00
|
|
|
returnval=$?
|
|
|
|
|
|
|
|
if [ "x$1" = "xautoconf" ]; then
|
|
|
|
if [ -z "$targets" ]; then
|
|
|
|
echo "no (no md devices found under /sys/devices/virtual/block/*/md/mismatch_cnt)"
|
|
|
|
elif [ "x$returnval" != "x0" ]; then
|
|
|
|
echo "no (discovery of md devices failed strangely)"
|
|
|
|
else
|
|
|
|
echo "yes"
|
|
|
|
fi
|
2018-09-16 04:01:57 +02:00
|
|
|
exit 0
|
2012-11-01 13:55:13 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$1" = "xconfig" ]; then
|
|
|
|
cat << __EOF__
|
|
|
|
graph_title Software-raid mismatch count
|
|
|
|
graph_args -l 0
|
|
|
|
graph_info Display mismatch count of software raid devices
|
|
|
|
graph_category disk
|
|
|
|
graph_vlabel Count
|
|
|
|
__EOF__
|
|
|
|
for target in $targets; do
|
|
|
|
echo "$target.label $target"
|
2016-05-15 17:38:38 +02:00
|
|
|
echo "$target.critical 1"
|
2016-05-15 17:40:50 +02:00
|
|
|
echo "$target.info Mismatch count for software raid device $target"
|
2012-11-01 13:55:13 +01:00
|
|
|
done
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
for target in $targets; do
|
2015-05-04 18:02:49 +02:00
|
|
|
echo $target.value $(cat /sys/devices/virtual/block/$target/md/mismatch_cnt)
|
2012-11-01 13:55:13 +01:00
|
|
|
done
|