1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/*
* Copyright (c) 2013 Red Hat.
* Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* common data structures for pmlogextract
*/
#ifndef _LOGGER_H
#define _LOGGER_H
extern int sflag; /* -s from command line */
extern int vflag; /* -v from command line */
extern int wflag; /* -w from command line */
/*
* Global rewrite specifications
*/
typedef struct {
int flags; /* GLOBAL_* flags */
struct timeval time; /* timestamp shift */
char hostname[PM_LOG_MAXHOSTLEN];
char tz[PM_TZ_MAXLEN];
} global_t;
/* values for global_t flags */
#define GLOBAL_CHANGE_TIME 1
#define GLOBAL_CHANGE_HOSTNAME 2
#define GLOBAL_CHANGE_TZ 4
extern global_t global;
/*
* Rewrite specifications for an instance domain
*/
typedef struct indomspec {
struct indomspec *i_next;
int indom_flags; /* INDOM_* flags */
int *inst_flags; /* INST_* flags */
pmInDom old_indom;
pmInDom new_indom; /* old_indom if no change */
int numinst;
int *old_inst; /* filled from pmGetInDomArchive() */
char **old_iname; /* filled from pmGetInDomArchive() */
int *new_inst;
char **new_iname;
} indomspec_t;
/* values for indomspec_t indom_flags */
#define INDOM_ADD 1
#define INDOM_DELETE 2
#define INDOM_DUPLICATE 4
/* values for indomspec_t inst_flags[] */
#define INST_CHANGE_INST 16
#define INST_CHANGE_INAME 32
#define INST_DELETE 64
extern indomspec_t *indom_root;
/*
* Rewrite specifications for a metric
*/
typedef struct metricspec {
struct metricspec *m_next;
int flags; /* METRIC_* flags */
int output; /* OUTPUT_* values */
int one_inst; /* for OUTPUT_ONE INST */
char *one_name; /* for OUTPUT_ONE NAME */
char *old_name;
char *new_name;
pmDesc old_desc;
pmDesc new_desc;
indomspec_t *ip; /* for instance id changes */
} metricspec_t;
/* values for metricspec_t flags[] */
#define METRIC_CHANGE_PMID 1
#define METRIC_CHANGE_NAME 2
#define METRIC_CHANGE_TYPE 4
#define METRIC_CHANGE_INDOM 8
#define METRIC_CHANGE_SEM 16
#define METRIC_CHANGE_UNITS 32
#define METRIC_DELETE 64
#define METRIC_RESCALE 128
/* values for output when indom (numval >= 1) => PM_INDOM_NULL (numval = 1) */
#define OUTPUT_ALL 0
#define OUTPUT_FIRST 1
#define OUTPUT_LAST 2
#define OUTPUT_ONE 3
#define OUTPUT_MIN 4
#define OUTPUT_MAX 5
#define OUTPUT_SUM 6
#define OUTPUT_AVG 7
extern metricspec_t *metric_root;
/*
* Input archive control
*/
typedef struct {
int ctx;
__pmContext *ctxp;
char *name;
pmLogLabel label;
__pmPDU *metarec;
__pmPDU *logrec;
pmResult *rp;
int mark; /* need EOL marker */
} inarch_t;
extern inarch_t inarch; /* input archive */
/*
* Output archive control
*/
typedef struct {
char *name; /* base name of output archive */
__pmLogCtl logctl; /* libpcp control */
} outarch_t;
extern outarch_t outarch; /* output archive */
/* size of a string length field */
#define LENSIZE 4
/* generic error message buffer */
extern char mess[256];
/* yylex() gets intput from here ... */
extern char *configfile;
extern FILE *fconfig;
extern int lineno;
extern FILE *yyin;
extern void yyerror(char *);
extern void yywarn(char *);
extern void yysemantic(char *);
extern int yylex(void);
extern int yyparse(void);
#define W_START 1
#define W_NEXT 2
#define W_NONE 3
extern int _pmLogGet(__pmLogCtl *, int, __pmPDU **);
extern int _pmLogPut(FILE *, __pmPDU *);
extern int _pmLogRename(const char *, const char *);
extern int _pmLogRemove(const char *);
extern pmUnits ntoh_pmUnits(pmUnits);
#define ntoh_pmInDom(indom) ntohl(indom)
#define ntoh_pmID(pmid) ntohl(pmid)
extern metricspec_t *start_metric(pmID);
extern indomspec_t *start_indom(pmInDom);
extern int change_inst_by_inst(pmInDom, int, int);
extern int change_inst_by_name(pmInDom, char *, char *);
extern int inst_name_eq(const char *, const char *);
extern char *SemStr(int);
extern void newvolume(int);
extern void do_desc(void);
extern void do_indom(void);
extern void do_result(void);
extern void abandon(void);
#endif /* _LOGGER_H */
|