681397dd571480b2087a09e64da7b802392edb93
[rrdtool.git] / src / rrd_client.h
1 /**
2  * RRDTool - src/rrd_client.h
3  * Copyright (C) 2008-2010  Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to
7  * deal in the Software without restriction, including without limitation the
8  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9  * sell copies of the Software, and to permit persons to whom the Software is
10  * 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 DEALINGS
21  * IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at verplant.org>
25  **/
26
27 #ifndef __RRD_CLIENT_H
28 #define __RRD_CLIENT_H 1
29
30 #ifndef WIN32
31 # ifdef HAVE_STDINT_H
32 #  include <stdint.h>
33 # else
34 #   ifdef HAVE_INTTYPES_H
35 #      include <inttypes.h>
36 #   else
37 #      error "you should have stdint.h or inttypes.h to compile this"
38 #   endif
39 # endif
40 #else
41 #       include <stdlib.h>
42         typedef signed char     int8_t;
43         typedef unsigned char   uint8_t;
44         typedef signed int      int16_t;
45         typedef unsigned int    uint16_t;
46         typedef signed long int         int32_t;
47         typedef unsigned long int       uint32_t;
48         typedef signed long long int    int64_t;
49         typedef unsigned long long int  uint64_t;
50 #endif
51
52 /* max length of socket command or response */
53 #define RRD_CMD_MAX 4096
54
55 #ifndef RRDCACHED_DEFAULT_ADDRESS
56 # define RRDCACHED_DEFAULT_ADDRESS "unix:/tmp/rrdcached.sock"
57 #endif
58
59 #define RRDCACHED_DEFAULT_PORT "42217"
60 #define ENV_RRDCACHED_ADDRESS "RRDCACHED_ADDRESS"
61
62
63 // Windows version has no daemon/client support
64
65 #ifndef WIN32
66 int rrdc_connect (const char *addr);
67 int rrdc_is_connected(const char *daemon_addr);
68 int rrdc_disconnect (void);
69
70 int rrdc_update (const char *filename, int values_num,
71         const char * const *values);
72
73 rrd_info_t * rrdc_info (const char *filename);
74 time_t rrdc_last (const char *filename);
75 time_t rrdc_first (const char *filename, int rraindex);
76 int rrdc_create (const char *filename,
77     unsigned long pdp_step,
78     time_t last_up,
79     int no_overwrite,
80     int argc,
81     const char **argv);
82
83
84 int rrdc_flush (const char *filename);
85 int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename);
86
87 int rrdc_fetch (const char *filename,
88     const char *cf,
89     time_t *ret_start, time_t *ret_end,
90     unsigned long *ret_step,
91     unsigned long *ret_ds_num,
92     char ***ret_ds_names,
93     rrd_value_t **ret_data);
94
95 #else
96 #       define rrdc_flush_if_daemon(a,b) 0
97 #       define rrdc_connect(a) 0
98 #       define rrdc_is_connected(a) 0
99 #       define rrdc_flush(a) 0
100 #       define rrdc_update(a,b,c) 0
101 #endif
102
103 struct rrdc_stats_s
104 {
105   const char *name;
106   uint16_t type;
107 #define RRDC_STATS_TYPE_GAUGE   0x0001
108 #define RRDC_STATS_TYPE_COUNTER 0x0002
109   uint16_t flags;
110   union
111   {
112     uint64_t counter;
113     double   gauge;
114   } value;
115   struct rrdc_stats_s *next;
116 };
117 typedef struct rrdc_stats_s rrdc_stats_t;
118
119 int rrdc_stats_get (rrdc_stats_t **ret_stats);
120 void rrdc_stats_free (rrdc_stats_t *ret_stats);
121
122 #endif /* __RRD_CLIENT_H */
123 /*
124  * vim: set sw=2 sts=2 ts=8 et fdm=marker :
125  */