1 /*****************************************************************************
2 * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************
8 * Revision 1.2 2001/03/04 13:01:55 oetiker
9 * Aberrant Behavior Detection support. A brief overview added to rrdtool.pod.
10 * Major updates to rrd_update.c, rrd_create.c. Minor update to other core files.
11 * This is backwards compatible! But new files using the Aberrant stuff are not readable
12 * by old rrdtool versions. See http://cricket.sourceforge.net/aberrant/rrd_hw.htm
13 * -- Jake Brutlag <jakeb@corp.webtv.net>
15 * Revision 1.1.1.1 2001/02/25 22:25:06 oetiker
18 *****************************************************************************/
28 # include "ntconfig.h"
35 #ifdef MUST_DISABLE_SIGFPE
39 #ifdef MUST_DISABLE_FPMASK
40 #include <floatingpoint.h>
51 # include <sys/param.h>
65 # include <sys/time.h>
68 # include <sys/times.h>
70 #if HAVE_SYS_RESOURCE_H
71 # include <sys/resource.h>
72 #if (defined(__svr4__) && defined(__sun__))
73 /* Solaris headers (pre 2.6) don't have a getrusage prototype.
75 extern int getrusage(int, struct rusage *);
76 #endif /* __svr4__ && __sun__ */
83 /* unix-only includes */
85 int isnan(double value);
90 /* Win32 only includes */
92 #include <float.h> /* for _isnan */
94 #define finite _finite
95 #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
98 /* local include files -- need to be after the system ones */
100 #include "rrd_format.h"
103 #define max(a,b) ((a) > (b) ? (a) : (b))
107 #define min(a,b) ((a) < (b) ? (a) : (b))
110 #define DIM(x) (sizeof(x)/sizeof(x[0]))
112 /* rrd info interface */
113 enum info_type { RD_I_VAL=0,
117 typedef union infoval {
123 typedef struct info_t {
131 info_t *rrd_info(int, char **);
133 /* HELPER FUNCTIONS */
134 int GifSize(FILE *, long *, long *);
135 int PngSize(FILE *, long *, long *);
136 int PngSize(FILE *, long *, long *);
139 void gdImagePng(gdImagePtr im, FILE *out);
141 int rrd_create_fn(char *file_name, rrd_t *rrd);
142 int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
143 time_t *start,time_t *end,
145 unsigned long *ds_cnt,
149 void rrd_free(rrd_t *rrd);
150 void rrd_init(rrd_t *rrd);
152 int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
153 int readfile(char *file, char **buffer, int skipfirst);
155 #define RRD_READONLY 0
156 #define RRD_READWRITE 1
158 enum cf_en cf_conv(char *string);
159 enum dst_en dst_conv(char *string);
160 long ds_match(rrd_t *rrd,char *ds_nam);
161 double rrd_diff(char *a, char *b);
163 /* functions added for aberrant behavior detection.
164 * implemented for the most part in rrd_hw.c */
165 int update_aberrant_CF(rrd_t *rrd, rrd_value_t pdp_val, enum cf_en current_cf,
166 unsigned long cdp_idx, unsigned long rra_idx, unsigned long ds_idx,
167 unsigned short CDP_scratch_idx, rrd_value_t *seasonal_coef);
168 int create_hw_contingent_rras(rrd_t *rrd, unsigned short period,
169 unsigned long hashed_name);
170 int lookup_seasonal(rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start,
171 FILE *rrd_file, unsigned long offset, rrd_value_t **seasonal_coef);
172 void erase_violations(rrd_t *rrd, unsigned long cdp_idx, unsigned long rra_idx);
173 int apply_smoother(rrd_t *rrd, unsigned long rra_idx, unsigned long rra_start,
176 /* a standard fixed-capacity FIFO queue implementation */
177 typedef struct FIFOqueue {
179 int capacity, head, tail;
182 int queue_alloc(FIFOqueue **q,int capacity);
183 void queue_dealloc(FIFOqueue *q);
184 void queue_push(FIFOqueue *q, rrd_value_t value);
185 int queue_isempty(FIFOqueue *q);
186 rrd_value_t queue_pop(FIFOqueue *q);
188 #define BURNIN_CYCLES 3