{GPL, other}: Relicense to MIT license.
[collectd.git] / src / utils_cache.h
1 /**
2  * collectd - src/utils_cache.h
3  * Copyright (C) 2007       Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  **/
26
27 #ifndef UTILS_CACHE_H
28 #define UTILS_CACHE_H 1
29
30 #include "plugin.h"
31
32 #define STATE_OKAY     0
33 #define STATE_WARNING  1
34 #define STATE_ERROR    2
35 #define STATE_MISSING 15
36
37 int uc_init (void);
38 int uc_check_timeout (void);
39 int uc_update (const data_set_t *ds, const value_list_t *vl);
40 int uc_get_rate_by_name (const char *name, gauge_t **ret_values, size_t *ret_values_num);
41 gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl);
42
43 int uc_get_names (char ***ret_names, cdtime_t **ret_times, size_t *ret_number);
44
45 int uc_get_state (const data_set_t *ds, const value_list_t *vl);
46 int uc_set_state (const data_set_t *ds, const value_list_t *vl, int state);
47 int uc_get_hits (const data_set_t *ds, const value_list_t *vl);
48 int uc_set_hits (const data_set_t *ds, const value_list_t *vl, int hits);
49 int uc_inc_hits (const data_set_t *ds, const value_list_t *vl, int step);
50
51 int uc_get_history (const data_set_t *ds, const value_list_t *vl,
52     gauge_t *ret_history, size_t num_steps, size_t num_ds);
53 int uc_get_history_by_name (const char *name,
54     gauge_t *ret_history, size_t num_steps, size_t num_ds);
55
56 /*
57  * Meta data interface
58  */
59 int uc_meta_data_exists (const value_list_t *vl, const char *key);
60 int uc_meta_data_delete (const value_list_t *vl, const char *key);
61
62 int uc_meta_data_add_string (const value_list_t *vl,
63     const char *key,
64     const char *value);
65 int uc_meta_data_add_signed_int (const value_list_t *vl,
66     const char *key,
67     int64_t value);
68 int uc_meta_data_add_unsigned_int (const value_list_t *vl,
69     const char *key,
70     uint64_t value);
71 int uc_meta_data_add_double (const value_list_t *vl,
72     const char *key,
73     double value);
74 int uc_meta_data_add_boolean (const value_list_t *vl,
75     const char *key,
76     _Bool value);
77
78 int uc_meta_data_get_string (const value_list_t *vl,
79     const char *key,
80     char **value);
81 int uc_meta_data_get_signed_int (const value_list_t *vl,
82     const char *key,
83     int64_t *value);
84 int uc_meta_data_get_unsigned_int (const value_list_t *vl,
85     const char *key,
86     uint64_t *value);
87 int uc_meta_data_get_double (const value_list_t *vl,
88     const char *key,
89     double *value);
90 int uc_meta_data_get_boolean (const value_list_t *vl,
91     const char *key,
92     _Bool *value);
93
94 /* vim: set shiftwidth=2 softtabstop=2 tabstop=8 : */
95 #endif /* !UTILS_CACHE_H */