forked from sysstat/sysstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.c
120 lines (111 loc) · 3.35 KB
/
format.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* format.c: Output format definitions for sadf
* (C) 2011-2015 by Sebastien GODARD (sysstat <at> orange.fr)
*
***************************************************************************
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************
*/
#include "sadf.h"
/*
***************************************************************************
* Definitions of output formats.
* See sadf.h file for format structure definition.
***************************************************************************
*/
/*
* Display only datafile header.
*/
struct report_format hdr_fmt = {
.id = F_HEADER_OUTPUT,
.options = FO_HEADER_ONLY + FO_BAD_FILE_FORMAT,
.f_header = print_hdr_header,
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = NULL,
.f_comment = NULL
};
/*
* Database friendly format.
*/
struct report_format db_fmt = {
.id = F_DB_OUTPUT,
.options = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_HORIZONTALLY +
FO_SEC_EPOCH + FO_FIELD_LIST,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = print_db_restart,
.f_comment = print_db_comment
};
/*
* Format easily handled by pattern processing commands like awk.
*/
struct report_format ppc_fmt = {
.id = F_PPC_OUTPUT,
.options = FO_GROUPED_STATS + FO_LOCAL_TIME + FO_SEC_EPOCH,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = print_ppc_restart,
.f_comment = print_ppc_comment
};
/*
* XML output.
*/
struct report_format xml_fmt = {
.id = F_XML_OUTPUT,
.options = FO_HEADER_ONLY + FO_LOCAL_TIME,
.f_header = print_xml_header,
.f_statistics = print_xml_statistics,
.f_timestamp = print_xml_timestamp,
.f_restart = print_xml_restart,
.f_comment = print_xml_comment
};
/*
* JSON output.
*/
struct report_format json_fmt = {
.id = F_JSON_OUTPUT,
.options = FO_HEADER_ONLY + FO_LOCAL_TIME,
.f_header = print_json_header,
.f_statistics = print_json_statistics,
.f_timestamp = print_json_timestamp,
.f_restart = print_json_restart,
.f_comment = print_json_comment
};
/*
* Display only datafile header.
*/
struct report_format conv_fmt = {
.id = F_CONV_OUTPUT,
.options = FO_BAD_FILE_FORMAT,
.f_header = NULL,
.f_statistics = NULL,
.f_timestamp = NULL,
.f_restart = NULL,
.f_comment = NULL
};
/*
* Array of output formats.
*/
struct report_format *fmt[NR_FMT] = {
&hdr_fmt,
&db_fmt,
&ppc_fmt,
&xml_fmt,
&json_fmt,
&conv_fmt
};