#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 : */
#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 */