Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

md0_sync: Clean up and add autoconf++

  • Loading branch information...
commit c988acf51d05526a799cd45d844b8a9d04c85046 1 parent 99f5c8f
@KristianLyng KristianLyng authored
Showing with 40 additions and 5 deletions.
  1. +1 −1  README
  2. +39 −4 md0_sync/md0_sync
View
2  README
@@ -4,12 +4,12 @@ Decent or better quality:
proc_ - Monitor a process
munin_plugins - Count how many plugins are linked up
+md0_sync - Sync/recover progress of a md0
Read first-quality:
df_abs - Slight modifications to the original, including a "Total Capacity"
-md0_sync - Sync/recover progress of a md0
md0_sync_speed - Sync/recover SPEED of a md0
scsi_media_scan - Display scsi media scan progress
scsi_temp - Fetch temperature with sg_logs (a bit redundant)
View
43 md0_sync/md0_sync
@@ -1,11 +1,46 @@
-
#!/bin/sh
+# Detect and display Linux sw-raid sync progress
+# Copyright (C) 2010 Kristian Lyngstøl <kristian@bohemians.org>
+#
+# 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.
+#
+# 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.
+#
+# 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.
+#####
+#
+# Magic Markers:
+# #%# family=auto
+# #%# capabilities=autoconf
+
+# Hopefully, the sysfs paths are generic? Suggestions are welcome.
+targets=`ls /sys/devices/virtual/block/*/md/sync_completed | cut -d/ -f6`
+returnval=$?
-targets="md0"
+if [ "x$1" = "xautoconf" ]; then
+ if [ -z "$targets" ]; then
+ echo "no (no md devices found under /sys/devices/virtual/block/*/md/sync_completed)"
+ exit 1;
+ elif [ "x$returnval" != "x0" ]; then
+ echo "no (discovery of md devices failed strangely)"
+ exit 1;
+ else
+ echo "yes"
+ exit 0
+ fi
+fi
if [ "x$1" = "xconfig" ]; then
cat << __EOF__
-graph_title SW-raid resync progress
+graph_title Software-raid resync progress
graph_args -l 0
graph_info Display progress of Linux softwareraid resync
graph_category disk
@@ -18,5 +53,5 @@ __EOF__
fi
for target in $targets; do
- cat /sys/devices/virtual/block/$target/md/sync_completed | awk -v tar=$target '{print tar ".value " 100*$1/$3}'
+ cat /sys/devices/virtual/block/$target/md/sync_completed | awk -v tar=$target '{if ($1 != "none") { print tar ".value " 100*$1/$3 } else { print tar ".value 0"}}'
done
Please sign in to comment.
Something went wrong with that request. Please try again.