2 * sadf: System activity data formatter
3 * (C) 1999-2019 by Sebastien Godard (sysstat <at> orange.fr)
11 /* DTD version for XML output */
12 #define XML_DTD_VERSION "3.7"
14 /* Various constants */
18 #define IGNORE_NOTHING 0
19 #define IGNORE_RESTART 1
20 #define DONT_READ_CPU_NR 2
21 #define IGNORE_COMMENT 4
22 #define SET_TIMESTAMPS 8
25 ***************************************************************************
26 * Output format identification values.
27 ***************************************************************************
30 /* Number of output formats */
35 #define F_HEADER_OUTPUT 2
36 #define F_PPC_OUTPUT 3
37 #define F_XML_OUTPUT 4
38 #define F_JSON_OUTPUT 5
39 #define F_CONV_OUTPUT 6
40 #define F_SVG_OUTPUT 7
41 #define F_RAW_OUTPUT 8
42 #define F_PCP_OUTPUT 9
47 * Indicate that a decimal point should be used to make output
50 #define FO_LC_NUMERIC_C 0x01
53 * Indicate that output should stop after the header is displayed.
55 #define FO_HEADER_ONLY 0x02
58 * Indicate that a true sysstat activity file but with a bad
59 * format should not yield an error message.
61 #define FO_BAD_FILE_FORMAT 0x04
64 * Indicate that timestamp can be displayed in local time instead of UTC
65 * if option -T or -t has been used.
67 #define FO_LOCAL_TIME 0x08
70 * Indicate that all activities will be displayed horizontally
71 * if option -h is used.
73 #define FO_HORIZONTALLY 0x10
76 * Indicate that the timestamp can be displayed in seconds since the epoch
77 * if option -U has been used.
79 #define FO_SEC_EPOCH 0x20
82 * Indicate that the list of fields should be displayed before the first
85 #define FO_FIELD_LIST 0x40
88 * Indicate that flag AO_CLOSE_MARKUP (set for activities that need it)
89 * should be taken into account for this output format.
91 #define FO_TEST_MARKUP 0x80
94 * Indicate that timestamp cannot be displayed in the original local time
95 * of the data file creator.
97 #define FO_NO_TRUE_TIME 0x100
100 * Indicate that the number of different items should be counted and
101 * a list created (see @item_list and @item_list_sz in struct activity).
103 #define FO_ITEM_LIST 0x200
105 #define SET_LC_NUMERIC_C(m) (((m) & FO_LC_NUMERIC_C) == FO_LC_NUMERIC_C)
106 #define ACCEPT_HEADER_ONLY(m) (((m) & FO_HEADER_ONLY) == FO_HEADER_ONLY)
107 #define ACCEPT_BAD_FILE_FORMAT(m) (((m) & FO_BAD_FILE_FORMAT) == FO_BAD_FILE_FORMAT)
108 #define ACCEPT_LOCAL_TIME(m) (((m) & FO_LOCAL_TIME) == FO_LOCAL_TIME)
109 #define ACCEPT_HORIZONTALLY(m) (((m) & FO_HORIZONTALLY) == FO_HORIZONTALLY)
110 #define ACCEPT_SEC_EPOCH(m) (((m) & FO_SEC_EPOCH) == FO_SEC_EPOCH)
111 #define DISPLAY_FIELD_LIST(m) (((m) & FO_FIELD_LIST) == FO_FIELD_LIST)
112 #define TEST_MARKUP(m) (((m) & FO_TEST_MARKUP) == FO_TEST_MARKUP)
113 #define REJECT_TRUE_TIME(m) (((m) & FO_NO_TRUE_TIME) == FO_NO_TRUE_TIME)
114 #define CREATE_ITEM_LIST(m) (((m) & FO_ITEM_LIST) == FO_ITEM_LIST)
118 ***************************************************************************
119 * Various function prototypes
120 ***************************************************************************
124 (char [], struct activity *[]);
127 * Prototypes used to display restart messages
129 __printf_funct_t print_db_restart
130 (int *, int, char *, char *, int, struct file_header *);
131 __printf_funct_t print_ppc_restart
132 (int *, int, char *, char *, int, struct file_header *);
133 __printf_funct_t print_xml_restart
134 (int *, int, char *, char *, int, struct file_header *);
135 __printf_funct_t print_json_restart
136 (int *, int, char *, char *, int, struct file_header *);
137 __printf_funct_t print_raw_restart
138 (int *, int, char *, char *, int, struct file_header *);
141 * Prototypes used to display comments
143 __printf_funct_t print_db_comment
144 (int *, int, char *, char *, int, char *, struct file_header *);
145 __printf_funct_t print_ppc_comment
146 (int *, int, char *, char *, int, char *, struct file_header *);
147 __printf_funct_t print_xml_comment
148 (int *, int, char *, char *, int, char *, struct file_header *);
149 __printf_funct_t print_json_comment
150 (int *, int, char *, char *, int, char *, struct file_header *);
151 __printf_funct_t print_sar_comment
152 (int *, int, char *, char *, int, char *, struct file_header *);
153 __printf_funct_t print_raw_comment
154 (int *, int, char *, char *, int, char *, struct file_header *);
157 * Prototypes used to display the statistics part of the report
159 __printf_funct_t print_xml_statistics
160 (int *, int, struct activity * [], unsigned int []);
161 __printf_funct_t print_json_statistics
162 (int *, int, struct activity * [], unsigned int []);
163 __printf_funct_t print_pcp_statistics
164 (int *, int, struct activity * [], unsigned int []);
167 * Prototypes used to display the timestamp part of the report
169 __tm_funct_t print_db_timestamp
170 (void *, int, char *, char *, unsigned long long,
171 struct record_header *, struct file_header *, unsigned int);
172 __tm_funct_t print_ppc_timestamp
173 (void *, int, char *, char *, unsigned long long,
174 struct record_header *, struct file_header *, unsigned int);
175 __tm_funct_t print_xml_timestamp
176 (void *, int, char *, char *, unsigned long long,
177 struct record_header *, struct file_header *, unsigned int);
178 __tm_funct_t print_json_timestamp
179 (void *, int, char *, char *, unsigned long long,
180 struct record_header *, struct file_header *, unsigned int);
181 __tm_funct_t print_raw_timestamp
182 (void *, int, char *, char *, unsigned long long,
183 struct record_header *, struct file_header *, unsigned int);
184 __tm_funct_t print_pcp_timestamp
185 (void *, int, char *, char *, unsigned long long,
186 struct record_header *, struct file_header *, unsigned int);
189 * Prototypes used to display the report header
191 __printf_funct_t print_xml_header
192 (void *, int, char *, struct file_magic *, struct file_header *,
193 struct activity * [], unsigned int [], struct file_activity *);
194 __printf_funct_t print_json_header
195 (void *, int, char *, struct file_magic *, struct file_header *,
196 struct activity * [], unsigned int [], struct file_activity *);
197 __printf_funct_t print_hdr_header
198 (void *, int, char *, struct file_magic *, struct file_header *,
199 struct activity * [], unsigned int [], struct file_activity *);
200 __printf_funct_t print_svg_header
201 (void *, int, char *, struct file_magic *, struct file_header *,
202 struct activity * [], unsigned int [], struct file_activity *);
203 __printf_funct_t print_pcp_header
204 (void *, int, char *, struct file_magic *, struct file_header *,
205 struct activity * [], unsigned int [], struct file_activity *);
208 * Main display functions
210 void logic1_display_loop
211 (int, char *, struct file_activity *, struct file_magic *,
212 struct tm *, struct tm *, void *);
213 void logic2_display_loop
214 (int, char *, struct file_activity *, struct file_magic *,
215 struct tm *, struct tm *, void *);
216 void svg_display_loop
217 (int, char *, struct file_activity *, struct file_magic *,
218 struct tm *, struct tm *, void *);