Merge pull request #3339 from jkohen/patch-1
[collectd.git] / src / utils_threshold.h
1 /**
2  * collectd - src/utils_threshold.h
3  * Copyright (C) 2014 Pierre-Yves Ritschard
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  *   Pierre-Yves Ritschard <pyr at spootnik.org>
20  **/
21
22 #ifndef UTILS_THRESHOLD_H
23 #define UTILS_THRESHOLD_H 1
24
25 #define UT_FLAG_INVERT  0x01
26 #define UT_FLAG_PERSIST 0x02
27 #define UT_FLAG_PERCENTAGE 0x04
28 #define UT_FLAG_INTERESTING 0x08
29 #define UT_FLAG_PERSIST_OK 0x10
30 typedef struct threshold_s
31 {
32   char host[DATA_MAX_NAME_LEN];
33   char plugin[DATA_MAX_NAME_LEN];
34   char plugin_instance[DATA_MAX_NAME_LEN];
35   char type[DATA_MAX_NAME_LEN];
36   char type_instance[DATA_MAX_NAME_LEN];
37   char data_source[DATA_MAX_NAME_LEN];
38   gauge_t warning_min;
39   gauge_t warning_max;
40   gauge_t failure_min;
41   gauge_t failure_max;
42   gauge_t hysteresis;
43   unsigned int flags;
44   int hits;
45   struct threshold_s *next;
46 } threshold_t;
47
48 extern c_avl_tree_t   *threshold_tree;
49 extern pthread_mutex_t threshold_lock;
50
51 threshold_t *threshold_get (const char *hostname,
52     const char *plugin, const char *plugin_instance,
53     const char *type, const char *type_instance);
54
55 threshold_t *threshold_search (const value_list_t *vl);
56
57 int ut_search_threshold (const value_list_t *vl, 
58   threshold_t *ret_threshold);
59
60 #endif /* UTILS_THRESHOLD_H */
61
62 /* vim: set sw=2 sts=2 ts=8 : */