X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_cache.c;h=dd5bcb59ffc9833b2a92341a085e32d526e9e812;hb=e44afcf744af2337983b41c6e7a3617595692ddd;hp=2ed58706d96782d45b8e95229adb372766a5ba3f;hpb=171a92c968cb41c314736b0d26f5a6ba2ae59666;p=collectd.git diff --git a/src/utils_cache.c b/src/utils_cache.c index 2ed58706..dd5bcb59 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -119,81 +119,6 @@ static void cache_free (cache_entry_t *ce) sfree (ce); } /* void cache_free */ -__attribute__((unused)) -static int uc_send_notification (const char *name) -{ - cache_entry_t *ce = NULL; - int status; - - char *name_copy; - char *host; - char *plugin; - char *plugin_instance; - char *type; - char *type_instance; - - notification_t n; - - name_copy = strdup (name); - if (name_copy == NULL) - { - ERROR ("uc_send_notification: strdup failed."); - return (-1); - } - - status = parse_identifier (name_copy, &host, - &plugin, &plugin_instance, - &type, &type_instance); - if (status != 0) - { - ERROR ("uc_send_notification: Cannot parse name `%s'", name); - return (-1); - } - - /* Copy the associative members */ - notification_init (&n, NOTIF_FAILURE, /* host = */ NULL, - host, plugin, plugin_instance, type, type_instance); - - sfree (name_copy); - name_copy = host = plugin = plugin_instance = type = type_instance = NULL; - - pthread_mutex_lock (&cache_lock); - - /* - * Set the time _after_ getting the lock because we don't know how long - * acquiring the lock takes and we will use this time later to decide - * whether or not the state is OKAY. - */ - n.time = cdtime (); - - status = c_avl_get (cache_tree, name, (void *) &ce); - if (status != 0) - { - pthread_mutex_unlock (&cache_lock); - sfree (name_copy); - return (-1); - } - - /* Check if the entry has been updated in the meantime */ - if ((n.time - ce->last_update) < (timeout_g * ce->interval)) - { - ce->state = STATE_OKAY; - pthread_mutex_unlock (&cache_lock); - sfree (name_copy); - return (-1); - } - - ssnprintf (n.message, sizeof (n.message), - "%s has not been updated for %.3f seconds.", name, - CDTIME_T_TO_DOUBLE (n.time - ce->last_update)); - - pthread_mutex_unlock (&cache_lock); - - plugin_dispatch_notification (&n); - - return (0); -} /* int uc_send_notification */ - static void uc_check_range (const data_set_t *ds, cache_entry_t *ce) { int i;