]> granicus.if.org Git - sysstat/blob - format.c
Merge pull request #346 from Kwstubbs/Kwstubbs/add-codeql-workflow
[sysstat] / format.c
1 /*
2  * format.c: Output format definitions for sadf and sar
3  * (C) 2011-2022 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
5  ***************************************************************************
6  * This program is free software; you can redistribute it and/or modify it *
7  * under the terms of the GNU General Public License as published  by  the *
8  * Free Software Foundation; either version 2 of the License, or (at  your *
9  * option) any later version.                                              *
10  *                                                                         *
11  * This program is distributed in the hope that it  will  be  useful,  but *
12  * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
14  * for more details.                                                       *
15  *                                                                         *
16  * You should have received a copy of the GNU General Public License along *
17  * with this program; if not, write to the Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA              *
19  ***************************************************************************
20  */
21
22 #ifdef SOURCE_SADF
23 #include "sadf.h"
24 #endif
25
26 #ifdef SOURCE_SAR
27 #include "sa.h"
28 #endif
29
30 /*
31  ***************************************************************************
32  * Definitions of output formats.
33  * See sadf.h file for format structure definition.
34  ***************************************************************************
35  */
36
37 #ifdef SOURCE_SADF
38 /*
39  * Display only datafile header.
40  */
41 struct report_format hdr_fmt = {
42         .id             = F_HEADER_OUTPUT,
43         .options        = FO_HEADER_ONLY,
44         .f_header       = print_hdr_header,
45         .f_statistics   = NULL,
46         .f_timestamp    = NULL,
47         .f_restart      = NULL,
48         .f_comment      = NULL,
49         .f_display      = NULL
50 };
51
52 /*
53  * Database friendly format.
54  */
55 struct report_format db_fmt = {
56         .id             = F_DB_OUTPUT,
57         .options        = FO_LOCAL_TIME + FO_HORIZONTALLY +
58                           FO_SEC_EPOCH + FO_FIELD_LIST,
59         .f_header       = NULL,
60         .f_statistics   = NULL,
61         .f_timestamp    = print_db_timestamp,
62         .f_restart      = print_db_restart,
63         .f_comment      = print_db_comment,
64         .f_display      = logic2_display_loop
65 };
66
67 /*
68  * Format easily handled by pattern processing commands like awk.
69  */
70 struct report_format ppc_fmt = {
71         .id             = F_PPC_OUTPUT,
72         .options        = FO_LOCAL_TIME + FO_SEC_EPOCH,
73         .f_header       = NULL,
74         .f_statistics   = NULL,
75         .f_timestamp    = print_ppc_timestamp,
76         .f_restart      = print_ppc_restart,
77         .f_comment      = print_ppc_comment,
78         .f_display      = logic2_display_loop
79 };
80
81 /*
82  * XML output.
83  */
84 struct report_format xml_fmt = {
85         .id             = F_XML_OUTPUT,
86         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP,
87         .f_header       = print_xml_header,
88         .f_statistics   = print_xml_statistics,
89         .f_timestamp    = print_xml_timestamp,
90         .f_restart      = print_xml_restart,
91         .f_comment      = print_xml_comment,
92         .f_display      = logic1_display_loop
93 };
94
95 /*
96  * JSON output.
97  */
98 struct report_format json_fmt = {
99         .id             = F_JSON_OUTPUT,
100         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP +
101                           FO_LC_NUMERIC_C,
102         .f_header       = print_json_header,
103         .f_statistics   = print_json_statistics,
104         .f_timestamp    = print_json_timestamp,
105         .f_restart      = print_json_restart,
106         .f_comment      = print_json_comment,
107         .f_display      = logic1_display_loop
108 };
109
110 /*
111  * Convert an old datafile to up-to-date format.
112  */
113 struct report_format conv_fmt = {
114         .id             = F_CONV_OUTPUT,
115         .options        = 0,
116         .f_header       = NULL,
117         .f_statistics   = NULL,
118         .f_timestamp    = NULL,
119         .f_restart      = NULL,
120         .f_comment      = NULL,
121         .f_display      = NULL
122 };
123
124 /*
125  * SVG output.
126  */
127 struct report_format svg_fmt = {
128         .id             = F_SVG_OUTPUT,
129         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME +
130                           FO_LC_NUMERIC_C,
131         .f_header       = print_svg_header,
132         .f_statistics   = NULL,
133         .f_timestamp    = NULL,
134         .f_restart      = NULL,
135         .f_comment      = NULL,
136         .f_display      = svg_display_loop
137 };
138
139 /*
140  * Raw output.
141  */
142 struct report_format raw_fmt = {
143         .id             = F_RAW_OUTPUT,
144         .options        = FO_LOCAL_TIME + FO_SEC_EPOCH,
145         .f_header       = NULL,
146         .f_statistics   = NULL,
147         .f_timestamp    = print_raw_timestamp,
148         .f_restart      = print_raw_restart,
149         .f_comment      = print_raw_comment,
150         .f_display      = logic2_display_loop
151 };
152
153 /*
154  * PCP output.
155  */
156 struct report_format pcp_fmt = {
157         .id             = F_PCP_OUTPUT,
158         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME +
159                           FO_ITEM_LIST + FO_FULL_ORDER,
160         .f_header       = print_pcp_header,
161         .f_statistics   = print_pcp_statistics,
162         .f_timestamp    = print_pcp_timestamp,
163         .f_restart      = print_pcp_restart,
164         .f_comment      = print_pcp_comment,
165         .f_display      = logic1_display_loop
166 };
167
168 /*
169  * Array of output formats.
170  */
171 struct report_format *fmt[NR_FMT] = {
172         &hdr_fmt,
173         &db_fmt,
174         &ppc_fmt,
175         &xml_fmt,
176         &json_fmt,
177         &conv_fmt,
178         &svg_fmt,
179         &raw_fmt,
180         &pcp_fmt
181 };
182 #endif
183
184 #ifdef SOURCE_SAR
185 /*
186  * Special output format for sar.
187  * Used only for functions to display special
188  * (RESTART and COMMENT) records.
189  */
190 struct report_format sar_fmt = {
191         .id             = F_SAR_OUTPUT,
192         .options        = 0,
193         .f_header       = NULL,
194         .f_statistics   = NULL,
195         .f_timestamp    = NULL,
196         .f_restart      = print_sar_restart,
197         .f_comment      = print_sar_comment
198 };
199 #endif