diff options
author | Zdenek Behan <rain@matfyz.cz> | 2009-10-19 13:13:58 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-10-19 13:13:58 +1100 |
commit | 9a36a9b713a6c789f268251a81de67bb8fd9c7f8 (patch) | |
tree | 1591bd243d1267838e6cbe405533dac6348b0f1b /Monitor.c | |
parent | 1373b07d758213b643f72a09384b840e4f08057a (diff) |
Monitor: add option to specify rebuild increments
ie. the percent increments after which RebuildNN event is generated
This is particulary useful when using --program option, rather than
(only) syslog for alerts.
Signed-off-by: Zdenek Behan <rain@matfyz.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r-- | Monitor.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -33,14 +33,6 @@ static void alert(char *event, char *dev, char *disc, char *mailaddr, char *mailfrom, char *cmd, int dosyslog); -static char *percentalerts[] = { - "RebuildStarted", - "Rebuild20", - "Rebuild40", - "Rebuild60", - "Rebuild80", -}; - /* The largest number of disks current arrays can manage is 384 * This really should be dynamically, but that will have to wait * At least it isn't MD_SB_DISKS. @@ -49,7 +41,7 @@ static char *percentalerts[] = { int Monitor(mddev_dev_t devlist, char *mailaddr, char *alert_cmd, int period, int daemonise, int scan, int oneshot, - int dosyslog, int test, char* pidfile) + int dosyslog, int test, char* pidfile, int increments) { /* * Every few seconds, scan every md device looking for changes @@ -77,8 +69,8 @@ int Monitor(mddev_dev_t devlist, * An active device had a reverse transition * RebuildStarted * percent went from -1 to +ve - * Rebuild20 Rebuild40 Rebuild60 Rebuild80 - * percent went from below to not-below that number + * RebuildNN + * percent went from below to not-below NN% * DeviceDisappeared * Couldn't access a device which was previously visible * @@ -311,9 +303,17 @@ int Monitor(mddev_dev_t devlist, if (mse && st->percent >= 0 && mse->percent >= 0 && - (mse->percent / 20) > (st->percent / 20)) - alert(percentalerts[mse->percent/20], + (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 && |