From: Vincent Bernat Date: Mon, 10 Nov 2014 10:36:58 +0000 (+0100) Subject: smart: add notifications when a value is below the threshold X-Git-Tag: collectd-5.5.0~154^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=394a4b4a8f9ecb180a4356c59c13df61b5f9f357;p=collectd.git smart: add notifications when a value is below the threshold --- diff --git a/src/smart.c b/src/smart.c index 6c01e677..f0c189e9 100644 --- a/src/smart.c +++ b/src/smart.c @@ -108,6 +108,25 @@ static void smart_handle_disk_attribute(SkDisk *d, const SkSmartAttributeParsedD sstrncpy (vl.type_instance, a->name, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); + + if (a->threshold_valid && a->current_value < a->threshold) + { + notification_t notif = { NOTIF_WARNING, + cdtime (), + "", + "", + "smart", "", + "smart_attribute", + "", + NULL }; + sstrncpy (notif.host, hostname_g, sizeof (notif.host)); + sstrncpy (notif.plugin_instance, dev, sizeof (notif.plugin_instance)); + sstrncpy (notif.type_instance, a->name, sizeof (notif.type_instance)); + ssnprintf (notif.message, sizeof (notif.message), + "attribute %s is below allowed threshold (%d < %d)", + a->name, a->current_value, a->threshold); + plugin_dispatch_notification (¬if); + } } static void smart_handle_disk (const char *dev)