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