summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40104b0)
raw | patch | inline | side by side (parent: 40104b0)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 5 Sep 2009 14:36:12 +0000 (16:36 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 5 Sep 2009 14:36:12 +0000 (16:36 +0200) |
It allows external modules to query the threshold for a specific
`value_list_t'.
`value_list_t'.
src/utils_threshold.c | patch | blob | history | |
src/utils_threshold.h | patch | blob | history |
diff --git a/src/utils_threshold.c b/src/utils_threshold.c
index 5e98e699120eab3987a4b2bd411e333182bc8e86..2cf0b677a3880de9d272ce75fe8c945f85ad8b8d 100644 (file)
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
#include "plugin.h"
#include "utils_avltree.h"
#include "utils_cache.h"
+#include "utils_threshold.h"
#include <assert.h>
#include <pthread.h>
#define UT_FLAG_INVERT 0x01
#define UT_FLAG_PERSIST 0x02
#define UT_FLAG_PERCENTAGE 0x04
-
-typedef struct threshold_s
-{
- char host[DATA_MAX_NAME_LEN];
- char plugin[DATA_MAX_NAME_LEN];
- char plugin_instance[DATA_MAX_NAME_LEN];
- char type[DATA_MAX_NAME_LEN];
- char type_instance[DATA_MAX_NAME_LEN];
- char data_source[DATA_MAX_NAME_LEN];
- gauge_t warning_min;
- gauge_t warning_max;
- gauge_t failure_min;
- gauge_t failure_max;
- gauge_t hysteresis;
- int flags;
- int hits;
- struct threshold_s *next;
-} threshold_t;
/* }}} */
/*
return (2);
} /* }}} int ut_check_interesting */
+int ut_search_threshold (const value_list_t *vl, /* {{{ */
+ threshold_t *ret_threshold)
+{
+ threshold_t *t;
+
+ if (vl == NULL)
+ return (EINVAL);
+
+ t = threshold_search (vl);
+ if (t == NULL)
+ return (ENOENT);
+
+ memcpy (ret_threshold, t, sizeof (*ret_threshold));
+ ret_threshold->next = NULL;
+
+ return (0);
+} /* }}} int ut_search_threshold */
+
/* vim: set sw=2 ts=8 sts=2 tw=78 et fdm=marker : */
diff --git a/src/utils_threshold.h b/src/utils_threshold.h
index a42c4121cd2f93599e9acacd9e61fa0c6cbd6334..369754dd3f2074db6be59b73fba864c544254d1d 100644 (file)
--- a/src/utils_threshold.h
+++ b/src/utils_threshold.h
#include "liboconfig/oconfig.h"
#include "plugin.h"
+typedef struct threshold_s
+{
+ char host[DATA_MAX_NAME_LEN];
+ char plugin[DATA_MAX_NAME_LEN];
+ char plugin_instance[DATA_MAX_NAME_LEN];
+ char type[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN];
+ char data_source[DATA_MAX_NAME_LEN];
+ gauge_t warning_min;
+ gauge_t warning_max;
+ gauge_t failure_min;
+ gauge_t failure_max;
+ gauge_t hysteresis;
+ int flags;
+ int hits;
+ struct threshold_s *next;
+} threshold_t;
+
/*
* ut_config
*
*/
int ut_check_interesting (const char *name);
+/*
+ * Given an identifier in form of a `value_list_t', searches for the best
+ * matching threshold configuration. `ret_threshold' may be NULL.
+ *
+ * Returns:
+ * 0: Success. Threshold configuration has been copied to
+ * `ret_threshold' (if it is non-NULL).
+ * ENOENT: No configuration for this identifier found.
+ * else: Error.
+ */
+int ut_search_threshold (const value_list_t *vl, threshold_t *ret_threshold);
+
#endif /* UTILS_THRESHOLD_H */