2 * collectd - src/utils_threshold.h
3 * Copyright (C) 2007-2009 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
22 #ifndef UTILS_THRESHOLD_H
23 #define UTILS_THRESHOLD_H 1
26 #include "liboconfig/oconfig.h"
29 typedef struct threshold_s
31 char host[DATA_MAX_NAME_LEN];
32 char plugin[DATA_MAX_NAME_LEN];
33 char plugin_instance[DATA_MAX_NAME_LEN];
34 char type[DATA_MAX_NAME_LEN];
35 char type_instance[DATA_MAX_NAME_LEN];
36 char data_source[DATA_MAX_NAME_LEN];
45 char *missing_message;
46 struct threshold_s *next;
52 * Parses the configuration and sets up the module. This is called from
55 int ut_config (const oconfig_item_t *ci);
60 * Checks if a threshold is defined for this value and if such a threshold is
61 * configured, check if the value within the acceptable range. If it is not, a
62 * notification is dispatched to inform the user that a problem exists. This is
63 * called from `plugin_read_all'.
65 int ut_check_threshold (const data_set_t *ds, const value_list_t *vl);
68 * Given an identification returns
69 * 0: No threshold is defined.
70 * 1: A threshold has been found. The flag `persist' is off.
71 * 2: A threshold has been found. The flag `persist' is on.
72 * (That is, it is expected that many notifications are sent until the
73 * problem disappears.)
75 int ut_check_interesting (const char *name);
78 * Given an identifier in form of a `value_list_t', searches for the best
79 * matching threshold configuration. `ret_threshold' may be NULL.
82 * 0: Success. Threshold configuration has been copied to
83 * `ret_threshold' (if it is non-NULL).
84 * ENOENT: No configuration for this identifier found.
87 int ut_search_threshold (const value_list_t *vl, threshold_t *ret_threshold);
91 * Formats a notification message using specified patterns according to data
94 * Returns: the number of bytes in the output string.
96 int ut_build_message(char *out, size_t bufsize, const char *fmt,
97 const data_set_t *ds, int ds_index, const value_list_t *vl, const gauge_t *values,
98 const notification_t *n, const threshold_t *th);
100 #endif /* UTILS_THRESHOLD_H */