summaryrefslogtreecommitdiff
path: root/src/pmlogreduce/pmlogreduce.h
blob: c6545185a2abbf81073dc209f21c39d5fd991041 (plain)
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
#include "pmapi.h"
#include "impl.h"

#define NUM_SEC_PER_DAY		86400

/*
 * Value control for a metric-instance and the last observed input value.
 * Used for rate conversion and supression of repeating values for
 * instantaneous and discrete metrics
 */
typedef struct value {
    struct value	*next;		/* next for this metric */
    int			inst;		/* instance id */
    pmAtomValue		value;		/* last output value */
    struct timeval	timestamp;	/* time of last output value */
    /*
     * last interval value interpretation ... set in doscan() and used in
     * rewrite()
     */
    int			control;
    int			nobs;		/* number of observations */
    int			nwrap;		/* number of counter wraps */
    pmAtomValue		pvalue;		/* used for counter wrap detection */
} value_t;

/*
 * control values ... bit fields
 */
#define V_INIT	1
#define V_SEEN	2

/*
 * instance domain control
 */
typedef struct {
    int		indom;
    int		numinst;
    int		*inst;
    char	**name;
} indom_t;

/*
 * Metric control record in metric hash list
 */
typedef struct {
    pmDesc	idesc;		/* input archive descriptor */
    pmDesc	odesc;		/* output archive descriptor */
    value_t	*first;		/* list of values, one per instance */
    indom_t	*idp;		/* instance domain control, if any */
    int		mode;		/* have to skip or rewrite the value format */
} metric_t;
#define MODE_NORMAL	0
#define MODE_REWRITE	1
#define MODE_SKIP	2

extern __pmTimeval	current;	/* most recent timestamp overall */
extern char		*iname;		/* name of input archive */
extern pmLogLabel	ilabel;		/* input archive label */
extern int		numpmid;	/* all metrics from the input archive */
extern pmID		*pmidlist;	/* ditto */
extern char		**namelist;	/* ditto */
extern metric_t		*metriclist;	/* ditto */
extern __pmLogCtl	logctl;		/* output archive control */
extern double		targ;		/* -t arg - interval b/n output samples */
extern int		sarg;		/* -s arg - finish after X samples */
extern char		*Sarg;		/* -S arg - window start */
extern char		*Targ;		/* -T arg - window end */
extern char		*Aarg;		/* -A arg - output time alignment */
extern int		varg;		/* -v arg - switch log vol every X */
extern int		zarg;		/* -z arg - use archive timezone */
extern char		*tz;		/* -Z arg - use timezone from user */


extern int	_pmLogGet(__pmLogCtl *, int, __pmPDU **);
extern int	_pmLogPut(FILE *, __pmPDU *);
extern void	newlabel(void);
extern void	writelabel(void);
extern void	newvolume(char *, __pmTimeval *);

extern pmResult *rewrite(pmResult *);
extern void	rewrite_free(void);

extern void	dometric(const char *);
extern void	doindom(pmResult *);
extern void	doscan(struct timeval *);