summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 83ca15b)
raw | patch | inline | side by side (parent: 83ca15b)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 10:23:31 +0000 (11:23 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 5 Dec 2010 10:23:31 +0000 (11:23 +0100) |
src/threshold.c | patch | blob | history | |
src/utils_cache.c | patch | blob | history |
diff --git a/src/threshold.c b/src/threshold.c
index 7d48244c4948a29b85b885e22b2c18c6309ecc01..369051a2d46fff900ca778f22736c6da3139ec86 100644 (file)
--- a/src/threshold.c
+++ b/src/threshold.c
} /* }}} int ut_check_one_threshold */
/*
- * int ut_check_threshold (PUBLIC)
+ * int ut_check_threshold
*
* Gets a list of matching thresholds and searches for the worst status by one
* of the thresholds. Then reports that status using the ut_report_state
return (0);
} /* }}} int ut_check_threshold */
+/*
+ * int ut_missing
+ *
+ * This function is called whenever a value goes "missing".
+ */
+static int ut_missing (const value_list_t *vl,
+ __attribute__((unused)) user_data_t *ud)
+{ /* {{{ */
+ threshold_t *th;
+ cdtime_t missing_time;
+ char identifier[6 * DATA_MAX_NAME_LEN];
+ notification_t n;
+
+ th = threshold_search (vl);
+ if (th == NULL)
+ return (0);
+
+ missing_time = cdtime () - vl->time;
+ FORMAT_VL (identifier, sizeof (identifier), vl);
+
+ NOTIFICATION_INIT_VL (&n, vl);
+ ssnprintf (n.message, sizeof (n.message),
+ "%s has not been updated for %.3f seconds.",
+ identifier, CDTIME_T_TO_DOUBLE (missing_time));
+
+ plugin_dispatch_notification (&n);
+
+ return (0);
+} /* }}} int ut_missing */
+
void module_register (void)
{
plugin_register_complex_config ("threshold", ut_config);
+ plugin_register_missing ("threshold", ut_missing,
+ /* user data = */ NULL);
plugin_register_write ("threshold", ut_check_threshold,
/* user data = */ NULL);
}
diff --git a/src/utils_cache.c b/src/utils_cache.c
index 2ed58706d96782d45b8e95229adb372766a5ba3f..dd5bcb59ffc9833b2a92341a085e32d526e9e812 100644 (file)
--- a/src/utils_cache.c
+++ b/src/utils_cache.c
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;