From fcf30c18599413d79f743d61c0623c81ad36df87 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 23 Dec 2007 11:44:01 +0100 Subject: [PATCH] src/utils_cache.c: Added the creation of an `OKAY' notification. It is generated when a value was missing and is received again. --- src/utils_cache.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/utils_cache.c b/src/utils_cache.c index 560365b7..77b38ebe 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -238,6 +238,7 @@ int uc_update (const data_set_t *ds, const value_list_t *vl) { char name[6 * DATA_MAX_NAME_LEN]; cache_entry_t *ce = NULL; + int send_okay_notification = 0; if (FORMAT_VL (name, sizeof (name), vl, ds) != 0) { @@ -265,9 +266,7 @@ int uc_update (const data_set_t *ds, const value_list_t *vl) if ((ce->last_time + ce->interval) < vl->time) { - /* TODO: Implement a `real' okay notification. Watch out for locking - * issues, though! */ - NOTICE ("uc_insert: Okay notification for %s", name); + send_okay_notification = vl->time - ce->last_time; ce->state = STATE_OKAY; } @@ -369,6 +368,24 @@ int uc_update (const data_set_t *ds, const value_list_t *vl) pthread_mutex_unlock (&cache_lock); + if (send_okay_notification > 0) + { + notification_t n; + memset (&n, '\0', sizeof (n)); + + n.severity = NOTIF_OKAY; + strncpy (n.host, vl->host, sizeof (n.host)); + n.host[sizeof (n.host) - 1] = '\0'; + n.time = vl->time; + + snprintf (n.message, sizeof (n.message), + "Received a value for %s. It was missing for %i seconds.", + name, send_okay_notification); + n.message[sizeof (n.message) - 1] = '\0'; + + plugin_dispatch_notification (&n); + } + return (0); } /* int uc_insert */ -- 2.11.0