]> granicus.if.org Git - sysstat/blob - format.c
Update year in (C) message
[sysstat] / format.c
1 /*
2  * format.c: Output format definitions for sadf and sar
3  * (C) 2011-2017 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 + FO_BAD_FILE_FORMAT,
44         .f_header       = print_hdr_header,
45         .f_statistics   = NULL,
46         .f_timestamp    = NULL,
47         .f_restart      = NULL,
48         .f_comment      = NULL
49 };
50
51 /*
52  * Database friendly format.
53  */
54 struct report_format db_fmt = {
55         .id             = F_DB_OUTPUT,
56         .options        = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_HORIZONTALLY +
57                           FO_SEC_EPOCH + FO_FIELD_LIST,
58         .f_header       = NULL,
59         .f_statistics   = NULL,
60         .f_timestamp    = print_db_timestamp,
61         .f_restart      = print_db_restart,
62         .f_comment      = print_db_comment
63 };
64
65 /*
66  * Format easily handled by pattern processing commands like awk.
67  */
68 struct report_format ppc_fmt = {
69         .id             = F_PPC_OUTPUT,
70         .options        = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_SEC_EPOCH,
71         .f_header       = NULL,
72         .f_statistics   = NULL,
73         .f_timestamp    = print_ppc_timestamp,
74         .f_restart      = print_ppc_restart,
75         .f_comment      = print_ppc_comment
76 };
77
78 /*
79  * XML output.
80  */
81 struct report_format xml_fmt = {
82         .id             = F_XML_OUTPUT,
83         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP,
84         .f_header       = print_xml_header,
85         .f_statistics   = print_xml_statistics,
86         .f_timestamp    = print_xml_timestamp,
87         .f_restart      = print_xml_restart,
88         .f_comment      = print_xml_comment
89 };
90
91 /*
92  * JSON output.
93  */
94 struct report_format json_fmt = {
95         .id             = F_JSON_OUTPUT,
96         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_TEST_MARKUP,
97         .f_header       = print_json_header,
98         .f_statistics   = print_json_statistics,
99         .f_timestamp    = print_json_timestamp,
100         .f_restart      = print_json_restart,
101         .f_comment      = print_json_comment
102 };
103
104 /*
105  * Convert an old datafile to up-to-date format.
106  */
107 struct report_format conv_fmt = {
108         .id             = F_CONV_OUTPUT,
109         .options        = FO_BAD_FILE_FORMAT,
110         .f_header       = NULL,
111         .f_statistics   = NULL,
112         .f_timestamp    = NULL,
113         .f_restart      = NULL,
114         .f_comment      = NULL
115 };
116
117 /*
118  * SVG output.
119  */
120 struct report_format svg_fmt = {
121         .id             = F_SVG_OUTPUT,
122         .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME,
123         .f_header       = print_svg_header,
124         .f_statistics   = NULL,
125         .f_timestamp    = NULL,
126         .f_restart      = NULL,
127         .f_comment      = NULL
128 };
129
130 /*
131  * Raw output.
132  */
133 struct report_format raw_fmt = {
134         .id             = F_RAW_OUTPUT,
135         .options        = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_SEC_EPOCH,
136         .f_header       = NULL,
137         .f_statistics   = NULL,
138         .f_timestamp    = print_raw_timestamp,
139         .f_restart      = print_raw_restart,
140         .f_comment      = print_raw_comment
141 };
142
143 /*
144  * Array of output formats.
145  */
146 struct report_format *fmt[NR_FMT] = {
147         &hdr_fmt,
148         &db_fmt,
149         &ppc_fmt,
150         &xml_fmt,
151         &json_fmt,
152         &conv_fmt,
153         &svg_fmt,
154         &raw_fmt
155 };
156 #endif
157
158 #ifdef SOURCE_SAR
159 /*
160  * Special output format for sar.
161  * Used only for functions to display special
162  * (RESTART and COMMENT) records.
163  */
164 struct report_format sar_fmt = {
165         .id             = 0,
166         .options        = 0,
167         .f_header       = NULL,
168         .f_statistics   = NULL,
169         .f_timestamp    = NULL,
170         .f_restart      = print_sar_restart,
171         .f_comment      = print_sar_comment
172 };
173 #endif