8aaf34c61af0175c18d3fa9f4ae3897d8b998e15
[collectd.git] / src / utils_threshold.h
1 /**
2  * collectd - src/utils_threshold.h
3  * Copyright (C) 2007-2009  Florian octo Forster
4  *
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.
8  *
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.
13  *
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
17  *
18  * Author:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef UTILS_THRESHOLD_H
23 #define UTILS_THRESHOLD_H 1
24
25 #include "collectd.h"
26 #include "liboconfig/oconfig.h"
27 #include "plugin.h"
28
29 typedef struct threshold_s
30 {
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];
37   gauge_t warning_min;
38   gauge_t warning_max;
39   gauge_t failure_min;
40   gauge_t failure_max;
41   gauge_t hysteresis;
42   int flags;
43   int hits;
44   struct threshold_s *next;
45 } threshold_t;
46
47 /*
48  * ut_config
49  *
50  * Parses the configuration and sets up the module. This is called from
51  * `src/configfile.c'.
52  */
53 int ut_config (const oconfig_item_t *ci);
54
55 /*
56  * ut_check_threshold
57  *
58  * Checks if a threshold is defined for this value and if such a threshold is
59  * configured, check if the value within the acceptable range. If it is not, a
60  * notification is dispatched to inform the user that a problem exists. This is
61  * called from `plugin_read_all'.
62  */
63 int ut_check_threshold (const data_set_t *ds, const value_list_t *vl);
64
65 /*
66  * Given an identification returns
67  * 0: No threshold is defined.
68  * 1: A threshold has been found. The flag `persist' is off.
69  * 2: A threshold has been found. The flag `persist' is on.
70  *    (That is, it is expected that many notifications are sent until the
71  *    problem disappears.)
72  */
73 int ut_check_interesting (const char *name);
74
75 /* 
76  * Given an identifier in form of a `value_list_t', searches for the best
77  * matching threshold configuration. `ret_threshold' may be NULL.
78  *
79  * Returns:
80  *        0: Success. Threshold configuration has been copied to
81  *           `ret_threshold' (if it is non-NULL).
82  *   ENOENT: No configuration for this identifier found.
83  *     else: Error.
84  */
85 int ut_search_threshold (const value_list_t *vl, threshold_t *ret_threshold);
86
87 #endif /* UTILS_THRESHOLD_H */