+ if (st->utime == 0 && /* new array */
+ mse && /* is in /proc/mdstat */
+ mse->pattern && strchr(mse->pattern, '_') /* degraded */
+ )
+ alert("DegradedArray", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
+
+ if (st->utime == 0 && /* new array */
+ st->expected_spares > 0 &&
+ array.spare_disks < st->expected_spares)
+ alert("SparesMissing", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
+ if (mse &&
+ st->percent == -1 &&
+ mse->percent >= 0)
+ alert("RebuildStarted", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
+ if (mse &&
+ st->percent >= 0 &&
+ mse->percent >= 0 &&
+ (mse->percent / increments) > (st->percent / increments)) {
+ char percentalert[15]; // "RebuildNN" (10 chars) or "RebuildStarted" (15 chars)
+
+ if((mse->percent / increments) == 0)
+ snprintf(percentalert, sizeof(percentalert), "RebuildStarted");
+ else
+ snprintf(percentalert, sizeof(percentalert), "Rebuild%02d", mse->percent);
+
+ alert(percentalert,
+ dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
+ }
+
+ if (mse &&
+ mse->percent == -1 &&
+ st->percent >= 0) {
+ /* Rebuild/sync/whatever just finished.
+ * If there is a number in /mismatch_cnt,
+ * we should report that.
+ */
+ struct mdinfo *sra =
+ sysfs_read(-1, st->devnum, GET_MISMATCH);
+ if (sra && sra->mismatch_cnt > 0) {
+ char cnt[40];
+ sprintf(cnt, " mismatches found: %d", sra->mismatch_cnt);
+ alert("RebuildFinished", dev, cnt, mailaddr, mailfrom, alert_cmd, dosyslog);
+ } else
+ alert("RebuildFinished", dev, NULL, mailaddr, mailfrom, alert_cmd, dosyslog);
+ if (sra)
+ free(sra);