forked from sysstat/sysstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sadf.h
237 lines (210 loc) · 6.72 KB
/
sadf.h
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/*
* sadf: System activity data formatter
* (C) 1999-2013 by Sebastien Godard (sysstat <at> orange.fr)
*/
#ifndef _SADF_H
#define _SADF_H
#include "sa.h"
/* DTD version for XML output */
#define XML_DTD_VERSION "2.17"
/* Possible actions for functions used to display reports */
#define F_BEGIN 0x01
#define F_MAIN 0x02
#define F_END 0x04
/*
***************************************************************************
* Output format identification values.
***************************************************************************
*/
/* Number of output formats */
#define NR_FMT 5
/* Output formats */
#define F_DB_OUTPUT 1
#define F_HEADER_OUTPUT 2
#define F_PPC_OUTPUT 3
#define F_XML_OUTPUT 4
#define F_JSON_OUTPUT 5
/*
***************************************************************************
* Generic description of an output format.
***************************************************************************
*/
/* Format options */
/*
* Indicate that all statistics data for one activity should be displayed before
* displaying stats for next activity. This is what sar does in its report.
* Example: If stats for activities A and B at time t and t' have been collected,
* setting AO_GROUPED_STATS for a format will result in the following output:
* stats for activity A at t
* stats for activity A at t'
* stats for activity B at t
* stats for activity B at t'
* Without this option, output would be:
* stats for activity A at t
* stats for activity B at t
* stats for activity A at t'
* stats for activity B at t'
*/
#define FO_GROUPED_STATS 0x01
/*
* Indicate that output should stop after the header is displayed.
*/
#define FO_HEADER_ONLY 0x02
/*
* Indicate that a true sysstat activity file but with a bad
* format should not yield an error message.
*/
#define FO_BAD_FILE_FORMAT 0x04
/*
* Indicate that timestamp can be displayed in local time instead of UTC
* if option -T or -t has been used.
*/
#define FO_LOCAL_TIME 0x08
/*
* Indicate that all activities will be displayed horizontally
* if option -h is used.
*/
#define FO_HORIZONTALLY 0x10
/*
* Indicate that the timestamp can be displayed in seconds since the epoch
* if option -U has been used.
*/
#define FO_SEC_EPOCH 0x20
/*
* Indicate that the list of fields should be displayed before the first
* line of statistics.
*/
#define FO_FIELD_LIST 0x40
#define DISPLAY_GROUPED_STATS(m) (((m) & FO_GROUPED_STATS) == FO_GROUPED_STATS)
#define ACCEPT_HEADER_ONLY(m) (((m) & FO_HEADER_ONLY) == FO_HEADER_ONLY)
#define ACCEPT_BAD_FILE_FORMAT(m) (((m) & FO_BAD_FILE_FORMAT) == FO_BAD_FILE_FORMAT)
#define ACCEPT_LOCAL_TIME(m) (((m) & FO_LOCAL_TIME) == FO_LOCAL_TIME)
#define ACCEPT_HORIZONTALLY(m) (((m) & FO_HORIZONTALLY) == FO_HORIZONTALLY)
#define ACCEPT_SEC_EPOCH(m) (((m) & FO_SEC_EPOCH) == FO_SEC_EPOCH)
#define DISPLAY_FIELD_LIST(m) (((m) & FO_FIELD_LIST) == FO_FIELD_LIST)
/* Type for all functions used by sadf to display stats in various formats */
#define __printf_funct_t void
/*
* Structure used to define a report.
* A XML-like report has the following format:
* __
* |
* | Header block
* | __
* | |
* | | Statistics block
* | | __
* | | |
* | | | Timestamp block
* | | | __
* | | | |
* | | | | Activity #1
* | | | |__
* | | | |
* | | | | ...
* | | | |__
* | | | |
* | | | | Activity #n
* | | | |__
* | | |__
* | |__
* | |
* | | Restart messages block
* | |__
* | |
* | | Comments block
* | |__
* |__
*/
struct report_format {
/*
* This variable contains the identification value (F_...) for this report format.
*/
unsigned int id;
/*
* Format options (FO_...).
*/
unsigned int options;
/*
* This function displays the report header
* (data displayed once at the beginning of the report).
*/
__printf_funct_t (*f_header) (int *, int, char *, struct file_magic *, struct file_header *,
__nr_t, struct activity * [], unsigned int []);
/*
* This function defines the statistics part of the report.
* Used only with textual (XML-like) reports.
*/
__printf_funct_t (*f_statistics) (int *, int);
/*
* This function defines the timestamp part of the report.
* Used only with textual (XML-like) reports.
*/
__printf_funct_t (*f_timestamp) (int *, int, char *, char *, int, unsigned long long);
/*
* This function displays the restart messages.
*/
__printf_funct_t (*f_restart) (int *, int, char *, char *, int, struct file_header *);
/*
* This function displays the comments.
*/
__printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *, struct file_header *);
};
/*
***************************************************************************
* Various function prototypes
***************************************************************************
*/
extern void
xprintf(int, const char *, ...);
extern void
xprintf0(int, const char *, ...);
/*
* Prototypes used to display restart messages
*/
__printf_funct_t
print_db_restart(int *, int, char *, char *, int, struct file_header *);
__printf_funct_t
print_ppc_restart(int *, int, char *, char *, int, struct file_header *);
__printf_funct_t
print_xml_restart(int *, int, char *, char *, int, struct file_header *);
__printf_funct_t
print_json_restart(int *, int, char *, char *, int, struct file_header *);
/*
* Prototypes used to display comments
*/
__printf_funct_t
print_db_comment(int *, int, char *, char *, int, char *, struct file_header *);
__printf_funct_t
print_ppc_comment(int *, int, char *, char *, int, char *, struct file_header *);
__printf_funct_t
print_xml_comment(int *, int, char *, char *, int, char *, struct file_header *);
__printf_funct_t
print_json_comment(int *, int, char *, char *, int, char *, struct file_header *);
/*
* Prototypes used to display the statistics part of the report
*/
__printf_funct_t
print_xml_statistics(int *, int);
__printf_funct_t
print_json_statistics(int *, int);
/*
* Prototypes used to display the timestamp part of the report
*/
__printf_funct_t
print_xml_timestamp(int *, int, char *, char *, int, unsigned long long);
__printf_funct_t
print_json_timestamp(int *, int, char *, char *, int, unsigned long long);
/*
* Prototypes used to display the report header
*/
__printf_funct_t
print_xml_header(int *, int, char *, struct file_magic *, struct file_header *,
__nr_t, struct activity * [], unsigned int []);
__printf_funct_t
print_json_header(int *, int, char *, struct file_magic *, struct file_header *,
__nr_t, struct activity * [], unsigned int []);
__printf_funct_t
print_hdr_header(int *, int, char *, struct file_magic *, struct file_header *,
__nr_t, struct activity * [], unsigned int []);
#endif /* _SADF_H */