2 * sadf: System activity data formatter
3 * (C) 1999-2013 by Sebastien Godard (sysstat <at> orange.fr)
11 /* DTD version for XML output */
12 #define XML_DTD_VERSION "2.18"
14 /* Possible actions for functions used to display reports */
20 ***************************************************************************
21 * Output format identification values.
22 ***************************************************************************
25 /* Number of output formats */
30 #define F_HEADER_OUTPUT 2
31 #define F_PPC_OUTPUT 3
32 #define F_XML_OUTPUT 4
33 #define F_JSON_OUTPUT 5
36 ***************************************************************************
37 * Generic description of an output format.
38 ***************************************************************************
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'
58 #define FO_GROUPED_STATS 0x01
61 * Indicate that output should stop after the header is displayed.
63 #define FO_HEADER_ONLY 0x02
66 * Indicate that a true sysstat activity file but with a bad
67 * format should not yield an error message.
69 #define FO_BAD_FILE_FORMAT 0x04
72 * Indicate that timestamp can be displayed in local time instead of UTC
73 * if option -T or -t has been used.
75 #define FO_LOCAL_TIME 0x08
78 * Indicate that all activities will be displayed horizontally
79 * if option -h is used.
81 #define FO_HORIZONTALLY 0x10
84 * Indicate that the timestamp can be displayed in seconds since the epoch
85 * if option -U has been used.
87 #define FO_SEC_EPOCH 0x20
90 * Indicate that the list of fields should be displayed before the first
93 #define FO_FIELD_LIST 0x40
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)
103 /* Type for all functions used by sadf to display stats in various formats */
104 #define __printf_funct_t void
107 * Structure used to define a report.
108 * A XML-like report has the following format:
114 * | | Statistics block
117 * | | | Timestamp block
120 * | | | | Activity #1
126 * | | | | Activity #n
131 * | | Restart messages block
138 struct report_format {
140 * This variable contains the identification value (F_...) for this report format.
144 * Format options (FO_...).
146 unsigned int options;
148 * This function displays the report header
149 * (data displayed once at the beginning of the report).
151 __printf_funct_t (*f_header) (int *, int, char *, struct file_magic *, struct file_header *,
152 __nr_t, struct activity * [], unsigned int []);
154 * This function defines the statistics part of the report.
155 * Used only with textual (XML-like) reports.
157 __printf_funct_t (*f_statistics) (int *, int);
159 * This function defines the timestamp part of the report.
160 * Used only with textual (XML-like) reports.
162 __printf_funct_t (*f_timestamp) (int *, int, char *, char *, int, unsigned long long);
164 * This function displays the restart messages.
166 __printf_funct_t (*f_restart) (int *, int, char *, char *, int, struct file_header *);
168 * This function displays the comments.
170 __printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *, struct file_header *);
174 ***************************************************************************
175 * Various function prototypes
176 ***************************************************************************
180 xprintf(int, const char *, ...);
182 xprintf0(int, const char *, ...);
185 * Prototypes used to display restart messages
188 print_db_restart(int *, int, char *, char *, int, struct file_header *);
190 print_ppc_restart(int *, int, char *, char *, int, struct file_header *);
192 print_xml_restart(int *, int, char *, char *, int, struct file_header *);
194 print_json_restart(int *, int, char *, char *, int, struct file_header *);
197 * Prototypes used to display comments
200 print_db_comment(int *, int, char *, char *, int, char *, struct file_header *);
202 print_ppc_comment(int *, int, char *, char *, int, char *, struct file_header *);
204 print_xml_comment(int *, int, char *, char *, int, char *, struct file_header *);
206 print_json_comment(int *, int, char *, char *, int, char *, struct file_header *);
209 * Prototypes used to display the statistics part of the report
212 print_xml_statistics(int *, int);
214 print_json_statistics(int *, int);
217 * Prototypes used to display the timestamp part of the report
220 print_xml_timestamp(int *, int, char *, char *, int, unsigned long long);
222 print_json_timestamp(int *, int, char *, char *, int, unsigned long long);
225 * Prototypes used to display the report header
228 print_xml_header(int *, int, char *, struct file_magic *, struct file_header *,
229 __nr_t, struct activity * [], unsigned int []);
231 print_json_header(int *, int, char *, struct file_magic *, struct file_header *,
232 __nr_t, struct activity * [], unsigned int []);
234 print_hdr_header(int *, int, char *, struct file_magic *, struct file_header *,
235 __nr_t, struct activity * [], unsigned int []);