]> granicus.if.org Git - sysstat/blob - sadf.h
sar: Take into account a change of CPU number in sar datafile (4)
[sysstat] / sadf.h
1 /*
2  * sadf: System activity data formatter
3  * (C) 1999-2014 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _SADF_H
7 #define _SADF_H
8
9 #include "sa.h"
10
11 /* DTD version for XML output */
12 #define XML_DTD_VERSION "2.18"
13
14 /* Possible actions for functions used to display reports */
15 #define F_BEGIN 0x01
16 #define F_MAIN  0x02
17 #define F_END   0x04
18
19 /*
20  ***************************************************************************
21  * Output format identification values.
22  ***************************************************************************
23  */
24
25 /* Number of output formats */
26 #define NR_FMT  5
27
28 /* Output formats */
29 #define F_DB_OUTPUT     1
30 #define F_HEADER_OUTPUT 2
31 #define F_PPC_OUTPUT    3
32 #define F_XML_OUTPUT    4
33 #define F_JSON_OUTPUT   5
34
35 /*
36  ***************************************************************************
37  * Generic description of an output format.
38  ***************************************************************************
39  */
40
41 /* Format options */
42
43 /*
44  * Indicate that all statistics data for one activity should be displayed before
45  * displaying stats for next activity. This is what sar does in its report.
46  * Example: If stats for activities A and B at time t and t' have been collected,
47  * setting AO_GROUPED_STATS for a format will result in the following output:
48  * stats for activity A at t
49  * stats for activity A at t'
50  * stats for activity B at t
51  * stats for activity B at t'
52  * Without this option, output would be:
53  * stats for activity A at t
54  * stats for activity B at t
55  * stats for activity A at t'
56  * stats for activity B at t'
57  */
58 #define FO_GROUPED_STATS        0x01
59
60 /*
61  * Indicate that output should stop after the header is displayed.
62  */
63 #define FO_HEADER_ONLY          0x02
64
65 /*
66  * Indicate that a true sysstat activity file but with a bad
67  * format should not yield an error message.
68  */
69 #define FO_BAD_FILE_FORMAT      0x04
70
71 /*
72  * Indicate that timestamp can be displayed in local time instead of UTC
73  * if option -T or -t has been used.
74  */
75 #define FO_LOCAL_TIME           0x08
76
77 /*
78  * Indicate that all activities will be displayed horizontally
79  * if option -h is used.
80  */
81 #define FO_HORIZONTALLY         0x10
82
83 /*
84  * Indicate that the timestamp can be displayed in seconds since the epoch
85  * if option -U has been used.
86  */
87 #define FO_SEC_EPOCH            0x20
88
89 /*
90  * Indicate that the list of fields should be displayed before the first
91  * line of statistics.
92  */
93 #define FO_FIELD_LIST           0x40
94
95 #define DISPLAY_GROUPED_STATS(m)        (((m) & FO_GROUPED_STATS)       == FO_GROUPED_STATS)
96 #define ACCEPT_HEADER_ONLY(m)           (((m) & FO_HEADER_ONLY)         == FO_HEADER_ONLY)
97 #define ACCEPT_BAD_FILE_FORMAT(m)       (((m) & FO_BAD_FILE_FORMAT)     == FO_BAD_FILE_FORMAT)
98 #define ACCEPT_LOCAL_TIME(m)            (((m) & FO_LOCAL_TIME)          == FO_LOCAL_TIME)
99 #define ACCEPT_HORIZONTALLY(m)          (((m) & FO_HORIZONTALLY)        == FO_HORIZONTALLY)
100 #define ACCEPT_SEC_EPOCH(m)             (((m) & FO_SEC_EPOCH)           == FO_SEC_EPOCH)
101 #define DISPLAY_FIELD_LIST(m)           (((m) & FO_FIELD_LIST)          == FO_FIELD_LIST)
102
103 /* Type for all functions used by sadf to display stats in various formats */
104 #define __printf_funct_t void
105
106 /*
107  * Structure used to define a report.
108  * A XML-like report has the following format:
109  *       __
110  *      |
111  *      | Header block
112  *      |  __
113  *      | |
114  *      | | Statistics block
115  *      | |  __
116  *      | | |
117  *      | | | Timestamp block
118  *      | | |  __
119  *      | | | |
120  *      | | | | Activity #1
121  *      | | | |__
122  *      | | | |
123  *      | | | | ...
124  *      | | | |__
125  *      | | | |
126  *      | | | | Activity #n
127  *      | | | |__
128  *      | | |__
129  *      | |__
130  *      | |
131  *      | | Restart messages block
132  *      | |__
133  *      | |
134  *      | | Comments block
135  *      | |__
136  *      |__
137  */
138 struct report_format {
139         /*
140          * This variable contains the identification value (F_...) for this report format.
141          */
142         unsigned int id;
143         /*
144          * Format options (FO_...).
145          */
146         unsigned int options;
147         /*
148          * This function displays the report header
149          * (data displayed once at the beginning of the report).
150          */
151         __printf_funct_t (*f_header) (int *, int, char *, struct file_magic *, struct file_header *,
152                                       __nr_t, struct activity * [], unsigned int []);
153         /*
154          * This function defines the statistics part of the report.
155          * Used only with textual (XML-like) reports.
156          */
157         __printf_funct_t (*f_statistics) (int *, int);
158         /*
159          * This function defines the timestamp part of the report.
160          * Used only with textual (XML-like) reports.
161          */
162         __printf_funct_t (*f_timestamp) (int *, int, char *, char *, int, unsigned long long);
163         /*
164          * This function displays the restart messages.
165          */
166         __printf_funct_t (*f_restart) (int *, int, char *, char *, int, struct file_header *,
167                                        unsigned int);
168         /*
169          * This function displays the comments.
170          */
171         __printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *, struct file_header *);
172 };
173
174 /*
175  ***************************************************************************
176  * Various function prototypes
177  ***************************************************************************
178  */
179
180 extern void
181         xprintf(int, const char *, ...);
182 extern void
183         xprintf0(int, const char *, ...);
184
185 /*
186  * Prototypes used to display restart messages
187  */
188 __printf_funct_t
189         print_db_restart(int *, int, char *, char *, int, struct file_header *, unsigned int);
190 __printf_funct_t
191         print_ppc_restart(int *, int, char *, char *, int, struct file_header *, unsigned int);
192 __printf_funct_t
193         print_xml_restart(int *, int, char *, char *, int, struct file_header *, unsigned int);
194 __printf_funct_t
195         print_json_restart(int *, int, char *, char *, int, struct file_header *, unsigned int);
196
197 /*
198  * Prototypes used to display comments
199  */
200 __printf_funct_t
201         print_db_comment(int *, int, char *, char *, int, char *, struct file_header *);
202 __printf_funct_t
203         print_ppc_comment(int *, int, char *, char *, int, char *, struct file_header *);
204 __printf_funct_t
205         print_xml_comment(int *, int, char *, char *, int, char *, struct file_header *);
206 __printf_funct_t
207         print_json_comment(int *, int, char *, char *, int, char *, struct file_header *);
208
209 /*
210  * Prototypes used to display the statistics part of the report
211  */
212 __printf_funct_t
213         print_xml_statistics(int *, int);
214 __printf_funct_t
215         print_json_statistics(int *, int);
216
217 /*
218  * Prototypes used to display the timestamp part of the report
219  */
220 __printf_funct_t
221         print_xml_timestamp(int *, int, char *, char *, int, unsigned long long);
222 __printf_funct_t
223         print_json_timestamp(int *, int, char *, char *, int, unsigned long long);
224
225 /*
226  * Prototypes used to display the report header
227  */
228 __printf_funct_t
229         print_xml_header(int *, int, char *, struct file_magic *, struct file_header *,
230                          __nr_t, struct activity * [], unsigned int []);
231 __printf_funct_t
232         print_json_header(int *, int, char *, struct file_magic *, struct file_header *,
233                           __nr_t, struct activity * [], unsigned int []);
234 __printf_funct_t
235         print_hdr_header(int *, int, char *, struct file_magic *, struct file_header *,
236                          __nr_t, struct activity * [], unsigned int []);
237
238 #endif  /* _SADF_H */