]> granicus.if.org Git - sysstat/blob - sadf.h
cef63b6e768b48918e57ce7c116411eaa81a7871
[sysstat] / sadf.h
1 /*
2  * sadf: System activity data formatter
3  * (C) 1999-2017 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _SADF_H
7 #define _SADF_H
8
9 #include "sa.h"
10
11 /* DTD version for XML output */
12 #define XML_DTD_VERSION "3.4"
13
14 /* Various constants */
15 #define DO_SAVE         0
16 #define DO_RESTORE      1
17
18 #define IGNORE_NOTHING          0
19 #define IGNORE_RESTART          1
20 #define DONT_READ_VOLATILE      2
21 #define IGNORE_COMMENT          4
22 #define SET_TIMESTAMPS          8
23
24 /*
25  ***************************************************************************
26  * Output format identification values.
27  ***************************************************************************
28  */
29
30 /* Number of output formats */
31 #define NR_FMT  8
32
33 /* Output formats */
34 #define F_DB_OUTPUT     1
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
43 /* Format options */
44
45 /*
46  * Indicate that all statistics data for one activity should be displayed before
47  * displaying stats for next activity. This is what sar does in its report.
48  * Example: If stats for activities A and B at time t and t' have been collected,
49  * setting AO_GROUPED_STATS for a format will result in the following output:
50  * stats for activity A at t
51  * stats for activity A at t'
52  * stats for activity B at t
53  * stats for activity B at t'
54  * Without this option, output would be:
55  * stats for activity A at t
56  * stats for activity B at t
57  * stats for activity A at t'
58  * stats for activity B at t'
59  */
60 #define FO_GROUPED_STATS        0x01
61
62 /*
63  * Indicate that output should stop after the header is displayed.
64  */
65 #define FO_HEADER_ONLY          0x02
66
67 /*
68  * Indicate that a true sysstat activity file but with a bad
69  * format should not yield an error message.
70  */
71 #define FO_BAD_FILE_FORMAT      0x04
72
73 /*
74  * Indicate that timestamp can be displayed in local time instead of UTC
75  * if option -T or -t has been used.
76  */
77 #define FO_LOCAL_TIME           0x08
78
79 /*
80  * Indicate that all activities will be displayed horizontally
81  * if option -h is used.
82  */
83 #define FO_HORIZONTALLY         0x10
84
85 /*
86  * Indicate that the timestamp can be displayed in seconds since the epoch
87  * if option -U has been used.
88  */
89 #define FO_SEC_EPOCH            0x20
90
91 /*
92  * Indicate that the list of fields should be displayed before the first
93  * line of statistics.
94  */
95 #define FO_FIELD_LIST           0x40
96
97 /*
98  * Indicate that flag AO_CLOSE_MARKUP (set for activities that need it)
99  * should be taken into account for this output format.
100  */
101 #define FO_TEST_MARKUP          0x80
102
103 /*
104  * Indicate that timestamp cannot be displayed in the original local time
105  * of the data file creator.
106  */
107 #define FO_NO_TRUE_TIME         0x100
108
109 #define DISPLAY_GROUPED_STATS(m)        (((m) & FO_GROUPED_STATS)       == FO_GROUPED_STATS)
110 #define ACCEPT_HEADER_ONLY(m)           (((m) & FO_HEADER_ONLY)         == FO_HEADER_ONLY)
111 #define ACCEPT_BAD_FILE_FORMAT(m)       (((m) & FO_BAD_FILE_FORMAT)     == FO_BAD_FILE_FORMAT)
112 #define ACCEPT_LOCAL_TIME(m)            (((m) & FO_LOCAL_TIME)          == FO_LOCAL_TIME)
113 #define ACCEPT_HORIZONTALLY(m)          (((m) & FO_HORIZONTALLY)        == FO_HORIZONTALLY)
114 #define ACCEPT_SEC_EPOCH(m)             (((m) & FO_SEC_EPOCH)           == FO_SEC_EPOCH)
115 #define DISPLAY_FIELD_LIST(m)           (((m) & FO_FIELD_LIST)          == FO_FIELD_LIST)
116 #define TEST_MARKUP(m)                  (((m) & FO_TEST_MARKUP)         == FO_TEST_MARKUP)
117 #define REJECT_TRUE_TIME(m)             (((m) & FO_NO_TRUE_TIME)        == FO_NO_TRUE_TIME)
118
119
120 /*
121  ***************************************************************************
122  * Various function prototypes
123  ***************************************************************************
124  */
125
126 void convert_file
127         (char [], struct activity *[]);
128
129 /*
130  * Prototypes used to display restart messages
131  */
132 __printf_funct_t print_db_restart
133         (int *, int, char *, char *, int, struct file_header *);
134 __printf_funct_t print_ppc_restart
135         (int *, int, char *, char *, int, struct file_header *);
136 __printf_funct_t print_xml_restart
137         (int *, int, char *, char *, int, struct file_header *);
138 __printf_funct_t print_json_restart
139         (int *, int, char *, char *, int, struct file_header *);
140 __printf_funct_t print_raw_restart
141         (int *, int, char *, char *, int, struct file_header *);
142
143 /*
144  * Prototypes used to display comments
145  */
146 __printf_funct_t print_db_comment
147         (int *, int, char *, char *, int, char *, struct file_header *);
148 __printf_funct_t print_ppc_comment
149         (int *, int, char *, char *, int, char *, struct file_header *);
150 __printf_funct_t print_xml_comment
151         (int *, int, char *, char *, int, char *, struct file_header *);
152 __printf_funct_t print_json_comment
153         (int *, int, char *, char *, int, char *, struct file_header *);
154 __printf_funct_t print_sar_comment
155         (int *, int, char *, char *, int, char *, struct file_header *);
156 __printf_funct_t print_raw_comment
157         (int *, int, char *, char *, int, char *, struct file_header *);
158
159 /*
160  * Prototypes used to display the statistics part of the report
161  */
162 __printf_funct_t print_xml_statistics
163         (int *, int);
164 __printf_funct_t print_json_statistics
165         (int *, int);
166
167 /*
168  * Prototypes used to display the timestamp part of the report
169  */
170 __tm_funct_t print_db_timestamp
171         (void *, int, char *, char *, unsigned long long, struct file_header *, unsigned int);
172 __tm_funct_t print_ppc_timestamp
173         (void *, int, char *, char *, unsigned long long, struct file_header *, unsigned int);
174 __tm_funct_t print_xml_timestamp
175         (void *, int, char *, char *, unsigned long long, struct file_header *, unsigned int);
176 __tm_funct_t print_json_timestamp
177         (void *, int, char *, char *, unsigned long long, struct file_header *, unsigned int);
178 __tm_funct_t print_raw_timestamp
179         (void *, int, char *, char *, unsigned long long, struct file_header *, unsigned int);
180
181 /*
182  * Prototypes used to display the report header
183  */
184 __printf_funct_t print_xml_header
185         (void *, int, char *, struct file_magic *, struct file_header *,
186          struct activity * [], unsigned int []);
187 __printf_funct_t print_json_header
188         (void *, int, char *, struct file_magic *, struct file_header *,
189          struct activity * [], unsigned int []);
190 __printf_funct_t print_hdr_header
191         (void *, int, char *, struct file_magic *, struct file_header *,
192          struct activity * [], unsigned int []);
193 __printf_funct_t print_svg_header
194         (void *, int, char *, struct file_magic *, struct file_header *,
195          struct activity * [], unsigned int []);
196
197 #endif  /* _SADF_H */