~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to myrrd/rrd_graph.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-01-30 21:59:13 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050130215913-xc3ke963bw49b3k4
Tags: 2:3.0-5
* Updated README.Debian file so users will understand what to do at
  install, closes: #291794, #287802.
* Updated ntop init script to give better output.
* Also changed log directory from /var/lib/ntop to /var/log/ntop,
  closes: #252352.
* Quoted the interface list to allow whitespace, closes: #267248.
* Added a couple of logcheck ignores, closes: #269321, #269319.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 * RRDtool 1.0.42  Copyright Tobias Oetiker, 1997 - 2000
 
3
 ****************************************************************************
 
4
 * rrd__graph.h  
 
5
 ****************************************************************************/
 
6
#ifdef  __cplusplus
 
7
extern "C" {
 
8
#endif
 
9
 
 
10
#ifndef _RRD_GRAPH_H
 
11
#define _RRD_GRAPH_H
 
12
 
 
13
 
 
14
#define DEF_NAM_FMT "%29[_A-Za-z0-9]"
 
15
 
 
16
enum tmt_en {TMT_SECOND=0,TMT_MINUTE,TMT_HOUR,TMT_DAY,
 
17
             TMT_WEEK,TMT_MONTH,TMT_YEAR};
 
18
 
 
19
enum grc_en {GRC_CANVAS=0,GRC_BACK,GRC_SHADEA,GRC_SHADEB,
 
20
             GRC_GRID,GRC_MGRID,GRC_FONT,GRC_FRAME,GRC_ARROW,__GRC_END__};
 
21
 
 
22
 
 
23
enum gf_en {GF_PRINT=0,GF_GPRINT,GF_COMMENT,GF_HRULE,GF_VRULE,GF_LINE1,
 
24
            GF_LINE2,GF_LINE3,GF_AREA,GF_STACK, GF_DEF, GF_CDEF, GF_XPORT };
 
25
 
 
26
enum op_en {OP_NUMBER=0,OP_VARIABLE,OP_INF,OP_PREV,OP_PREV_OTHER,OP_NEGINF,
 
27
            OP_UNKN,OP_NOW,OP_TIME,OP_LTIME,OP_ADD,OP_MOD,
 
28
            OP_SUB,OP_MUL,
 
29
            OP_DIV,OP_SIN, OP_DUP, OP_EXC, OP_POP,
 
30
            OP_COS,OP_LOG,OP_EXP,OP_LT,OP_LE,OP_GT,OP_GE,OP_EQ,OP_IF,
 
31
            OP_MIN,OP_MAX,OP_LIMIT, OP_FLOOR, OP_CEIL,
 
32
            OP_UN,OP_END};
 
33
 
 
34
enum if_en {IF_GIF=0,IF_PNG=1,IF_GD=2};
 
35
 
 
36
typedef struct rpnp_t {
 
37
    enum op_en   op;
 
38
    double val; /* value for a OP_NUMBER */
 
39
    long ptr; /* pointer into the gdes array for OP_VAR */
 
40
    double *data; /* pointer to the current value from OP_VAR DAS*/
 
41
    long ds_cnt;   /* data source count for data pointer */
 
42
    long step; /* time step for OP_VAR das */
 
43
} rpnp_t;
 
44
 
 
45
 
 
46
typedef struct col_trip_t {
 
47
    int red; /* red = -1 is no color */
 
48
    int green;
 
49
    int blue;
 
50
    int i; /* color index assigned in gif image i=-1 is unasigned*/
 
51
} col_trip_t;
 
52
 
 
53
 
 
54
typedef struct xlab_t {
 
55
    long         minsec;       /* minimum sec per pix */
 
56
    enum tmt_en  gridtm;       /* grid interval in what ?*/
 
57
    long         gridst;       /* how many whats per grid*/
 
58
    enum tmt_en  mgridtm;      /* label interval in what ?*/
 
59
    long         mgridst;      /* how many whats per label*/
 
60
    enum tmt_en  labtm;        /* label interval in what ?*/
 
61
    long         labst;        /* how many whats per label*/
 
62
    long         precis;       /* label precision -> label placement*/
 
63
    char         *stst;        /* strftime string*/
 
64
} xlab_t;
 
65
 
 
66
typedef struct ylab_t {
 
67
    double   grid;    /* grid spacing */
 
68
    int      lfac[4]; /* associated label spacing*/
 
69
} ylab_t;
 
70
 
 
71
/* this structure describes the elements which can make up a graph.
 
72
   because they are quite diverse, not all elements will use all the
 
73
   possible parts of the structure. */
 
74
#ifdef HAVE_SNPRINTF
 
75
#define FMT_LEG_LEN 200
 
76
#else
 
77
#define FMT_LEG_LEN 2000
 
78
#endif
 
79
 
 
80
typedef  struct graph_desc_t {
 
81
    enum gf_en     gf;         /* graphing function */
 
82
    char           vname[30];  /* name of the variable */
 
83
    long           vidx;       /* gdes reference */
 
84
    char           rrd[255];   /* name of the rrd_file containing data */
 
85
    char           ds_nam[DS_NAM_SIZE]; /* data source name */
 
86
    long           ds;         /* data source number */
 
87
    enum cf_en     cf;         /* consolidation function */
 
88
    col_trip_t     col;        /* graph color */
 
89
    char           format[FMT_LEG_LEN+5]; /* format for PRINT AND GPRINT */
 
90
    char           legend[FMT_LEG_LEN+5]; /* legend*/
 
91
    gdPoint        legloc;     /* location of legend */   
 
92
    double         yrule;      /* value for y rule line */
 
93
    time_t         xrule;      /* value for x rule line */
 
94
    rpnp_t         *rpnp;     /* instructions for CDEF function */
 
95
 
 
96
    /* description of data fetched for the graph element */
 
97
    time_t         start,end; /* timestaps for first and last data element */
 
98
    unsigned long  step;      /* time between samples */
 
99
    unsigned long  ds_cnt; /* how many data sources are there in the fetch */
 
100
    long           data_first; /* first pointer to this data */
 
101
    char           **ds_namv; /* name of datasources  in the fetch. */
 
102
    rrd_value_t    *data; /* the raw data drawn from the rrd */
 
103
    rrd_value_t    *p_data; /* processed data, xsize elments */
 
104
 
 
105
} graph_desc_t;
 
106
 
 
107
#define ALTYGRID          0x01  /* use alternative y grid algorithm */
 
108
#define ALTAUTOSCALE      0x02  /* use alternative algorithm to find lower and upper bounds */
 
109
#define ALTAUTOSCALE_MAX  0x04  /* use alternative algorithm to find upper bounds */
 
110
#define NOLEGEND          0x08  /* use no legend */
 
111
 
 
112
 
 
113
typedef struct image_desc_t {
 
114
 
 
115
    /* configuration of graph */
 
116
 
 
117
    char           graphfile[MAXPATH]; /* filename for graphic */
 
118
    long           xsize,ysize;    /* graph area size in pixels */
 
119
    col_trip_t     graph_col[__GRC_END__]; /* real colors for the graph */   
 
120
    char           ylegend[200];   /* legend along the yaxis */
 
121
    char           title[200];     /* title for graph */
 
122
    int            draw_x_grid;      /* no x-grid at all */
 
123
    int            draw_y_grid;      /* no x-grid at all */
 
124
    xlab_t         xlab_user;      /* user defined labeling for xaxis */
 
125
    char           xlab_form[200]; /* format for the label on the xaxis */
 
126
 
 
127
    double         ygridstep;      /* user defined step for y grid */
 
128
    int            ylabfact;       /* every how many y grid shall a label be written ? */
 
129
 
 
130
    time_t         start,end;      /* what time does the graph cover */
 
131
    unsigned long           step;           /* any preference for the default step ? */
 
132
    rrd_value_t    minval,maxval;  /* extreme values in the data */
 
133
    int            rigid;          /* do not expand range even with 
 
134
                                      values outside */
 
135
    char*          imginfo;         /* construct an <IMG ... tag and return 
 
136
                                      as first retval */
 
137
    int            lazy;           /* only update the gif if there is reasonable
 
138
                                      probablility that the existing one is out of date */
 
139
    int            logarithmic;    /* scale the yaxis logarithmic */
 
140
    enum if_en     imgformat;         /* image format */
 
141
 
 
142
char* bkg_image; /* background image source */
 
143
char* ovl_image; /* overlay image source */
 
144
char* unit; /* measured value unit */
 
145
 
 
146
    /* status information */
 
147
            
 
148
    long           xorigin,yorigin;/* where is (0,0) of the graph */
 
149
    long           xgif,ygif;      /* total size of the gif */
 
150
    int            interlaced;     /* will the graph be interlaced? */
 
151
    double         magfact;        /* numerical magnitude*/
 
152
    long         base;            /* 1000 or 1024 depending on what we graph */
 
153
    char           symbol;         /* magnitude symbol for y-axis */
 
154
    int            unitsexponent;    /* 10*exponent for units on y-asis */
 
155
    int            extra_flags;    /* flags for boolean options */
 
156
    /* data elements */
 
157
 
 
158
    long  prt_c;                  /* number of print elements */
 
159
    long  gdes_c;                  /* number of graphics elements */
 
160
    graph_desc_t   *gdes;          /* points to an array of graph elements */
 
161
 
 
162
} image_desc_t;
 
163
 
 
164
/* Prototypes */
 
165
int xtr(image_desc_t *,time_t);
 
166
int ytr(image_desc_t *, double);
 
167
enum gf_en gf_conv(char *);
 
168
enum if_en if_conv(char *);
 
169
enum tmt_en tmt_conv(char *);
 
170
enum grc_en grc_conv(char *);
 
171
int im_free(image_desc_t *);
 
172
void auto_scale( image_desc_t *,  double *, char **, double *);
 
173
void si_unit( image_desc_t *);
 
174
void expand_range(image_desc_t *);
 
175
void reduce_data( enum cf_en,  unsigned long,  time_t *, time_t *,  unsigned long *,  unsigned long *,  rrd_value_t **);
 
176
int data_fetch( image_desc_t *);
 
177
long find_var(image_desc_t *, char *);
 
178
long lcd(long *);
 
179
int data_calc( image_desc_t *);
 
180
int data_proc( image_desc_t *);
 
181
time_t find_first_time( time_t,  enum tmt_en,  long);
 
182
time_t find_next_time( time_t,  enum tmt_en,  long);
 
183
void gator( gdImagePtr, int, int);
 
184
int tzoffset(time_t);
 
185
int print_calc(image_desc_t *, char ***);
 
186
int leg_place(image_desc_t *);
 
187
int horizontal_grid(gdImagePtr, image_desc_t *);
 
188
int horizontal_mrtg_grid(gdImagePtr, image_desc_t *);
 
189
int horizontal_log_grid(gdImagePtr, image_desc_t *);
 
190
void vertical_grid( gdImagePtr, image_desc_t *);
 
191
void axis_paint( image_desc_t *, gdImagePtr);
 
192
void grid_paint( image_desc_t *, gdImagePtr);
 
193
gdImagePtr MkLineBrush(image_desc_t *,long, enum gf_en);
 
194
void copyImage(gdImagePtr gif, char *bkg_image, int copy_white);
 
195
int lazy_check(image_desc_t *);
 
196
int graph_paint(image_desc_t *, char ***);
 
197
int gdes_alloc(image_desc_t *);
 
198
int scan_for_col(char *, int, char *);
 
199
int rrd_graph(int, char **, char ***, int *, int *);
 
200
int bad_format(char *);
 
201
rpnp_t * str2rpn(image_desc_t *,char *);
 
202
 
 
203
 
 
204
#define ALTYGRID          0x01  /* use alternative y grid algorithm */
 
205
#define ALTAUTOSCALE      0x02  /* use alternative algorithm to find lower and upper bounds */
 
206
#define ALTAUTOSCALE_MAX  0x04  /* use alternative algorithm to find upper bounds */
 
207
#define NOLEGEND          0x08  /* use no legend */
 
208
#define ALTYMRTG          0x10  /* simulate mrtg's scaling */
 
209
#define NOMINOR           0x20  /* Turn off minor gridlines */
 
210
 
 
211
 
 
212
#endif
 
213
 
 
214
 
 
215
#ifdef  __cplusplus
 
216
}
 
217
#endif