#include "plugin.h"
#include "utils_avltree.h"
#include "utils_cache.h"
-#include "utils_threshold.h"
#include "meta_data.h"
#include <assert.h>
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;
{
char name[6 * DATA_MAX_NAME_LEN];
cache_entry_t *ce = NULL;
- int send_okay_notification = 0;
- cdtime_t update_delay = 0;
- notification_t n;
int status;
int i;
return (-1);
}
- /* Send a notification (after the lock has been released) if we switch the
- * state from something else to `okay'. */
- if (ce->state == STATE_MISSING)
- {
- send_okay_notification = 1;
- ce->state = STATE_OKAY;
- update_delay = cdtime () - ce->last_update;
- }
-
for (i = 0; i < ds->ds_num; i++)
{
switch (ds->ds[i].type)
pthread_mutex_unlock (&cache_lock);
- if (send_okay_notification == 0)
- return (0);
-
- /* Do not send okay notifications for uninteresting values, i. e. values for
- * which no threshold is configured. */
- status = ut_check_interesting (name);
- if (status <= 0)
- return (0);
-
- /* Initialize the notification */
- memset (&n, '\0', sizeof (n));
- NOTIFICATION_INIT_VL (&n, vl, ds);
-
- n.severity = NOTIF_OKAY;
- n.time = vl->time;
-
- ssnprintf (n.message, sizeof (n.message),
- "Received a value for %s. It was missing for %u seconds.",
- name, (unsigned int) update_delay);
-
- plugin_dispatch_notification (&n);
-
return (0);
} /* int uc_update */