]> granicus.if.org Git - sysstat/blob - sa.h
sar/sadc: Add stable identifier support for disks statistics
[sysstat] / sa.h
1 /*
2  * sar/sadc: Report system activity
3  * (C) 1999-2019 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _SA_H
7 #define _SA_H
8
9 #include <stdio.h>
10
11 #include "common.h"
12 #include "rd_stats.h"
13 #include "rd_sensors.h"
14
15 /*
16  ***************************************************************************
17  * Activity identification values.
18  ***************************************************************************
19  */
20
21 /* Number of activities */
22 #define NR_ACT          39
23 /* The value below is used for sanity check */
24 #define MAX_NR_ACT      256
25
26 /* Number of functions used to count items */
27 #define NR_F_COUNT      11
28
29 /* Activities */
30 #define A_CPU           1
31 #define A_PCSW          2
32 #define A_IRQ           3
33 #define A_SWAP          4
34 #define A_PAGE          5
35 #define A_IO            6
36 #define A_MEMORY        7
37 #define A_KTABLES       8
38 #define A_QUEUE         9
39 #define A_SERIAL        10
40 #define A_DISK          11
41 #define A_NET_DEV       12
42 #define A_NET_EDEV      13
43 #define A_NET_NFS       14
44 #define A_NET_NFSD      15
45 #define A_NET_SOCK      16
46 #define A_NET_IP        17
47 #define A_NET_EIP       18
48 #define A_NET_ICMP      19
49 #define A_NET_EICMP     20
50 #define A_NET_TCP       21
51 #define A_NET_ETCP      22
52 #define A_NET_UDP       23
53 #define A_NET_SOCK6     24
54 #define A_NET_IP6       25
55 #define A_NET_EIP6      26
56 #define A_NET_ICMP6     27
57 #define A_NET_EICMP6    28
58 #define A_NET_UDP6      29
59 #define A_PWR_CPU       30
60 #define A_PWR_FAN       31
61 #define A_PWR_TEMP      32
62 #define A_PWR_IN        33
63 #define A_HUGE          34
64 #define A_PWR_FREQ      35
65 #define A_PWR_USB       36
66 #define A_FS            37
67 #define A_NET_FC        38
68 #define A_NET_SOFT      39
69
70
71 /* Macro used to flag an activity that should be collected */
72 #define COLLECT_ACTIVITY(m)     act[get_activity_position(act, m, EXIT_IF_NOT_FOUND)]->options |= AO_COLLECTED
73
74 /* Macro used to flag an activity that should be selected */
75 #define SELECT_ACTIVITY(m)      act[get_activity_position(act, m, EXIT_IF_NOT_FOUND)]->options |= AO_SELECTED
76
77
78 /*
79  ***************************************************************************
80  * Flags.
81  ***************************************************************************
82  */
83
84 #define S_F_SINCE_BOOT          0x00000001
85 #define S_F_SA_ROTAT            0x00000002      /* Only used by sadc */
86 #define S_F_DEV_SID             0x00000002      /* Only used by sar/sadf */
87 #define S_F_DEV_PRETTY          0x00000004
88 #define S_F_FORCE_FILE          0x00000008
89 #define S_F_INTERVAL_SET        0x00000010
90 #define S_F_TRUE_TIME           0x00000020
91 #define S_F_LOCK_FILE           0x00000040
92 #define S_F_SEC_EPOCH           0x00000080
93 #define S_F_HDR_ONLY            0x00000100
94 #define S_F_FILE_LOCKED         0x00000200
95 #define S_F_SA_YYYYMMDD         0x00000400
96 #define S_F_HORIZONTALLY        0x00000800
97 #define S_F_COMMENT             0x00001000
98 #define S_F_PERSIST_NAME        0x00002000
99 #define S_F_LOCAL_TIME          0x00004000
100 #define S_F_PREFD_TIME_OUTPUT   0x00008000
101 #define S_F_SVG_SKIP            0x00010000
102 /* Same value as S_F_SVG_SKIP above. Used for a different output format */
103 #define S_F_RAW_DEBUG_MODE      0x00010000
104 #define S_F_SVG_AUTOSCALE       0x00020000
105 #define S_F_SVG_ONE_DAY         0x00040000
106 #define S_F_SVG_SHOW_IDLE       0x00080000
107 #define S_F_UNIT                0x00100000
108 #define S_F_SVG_HEIGHT          0x00200000
109 #define S_F_SVG_PACKED          0x00400000
110 #define S_F_SVG_SHOW_INFO       0x00800000
111 #define S_F_HUMAN_READ          0x01000000
112 #define S_F_ZERO_OMIT           0x02000000
113 #define S_F_SVG_SHOW_TOC        0x04000000
114 #define S_F_FDATASYNC           0x08000000
115 #define S_F_OPTION_A            0x10000000
116 #define S_F_OPTION_P            0x20000000
117 #define S_F_OPTION_I            0x40000000
118
119 #define WANT_SINCE_BOOT(m)              (((m) & S_F_SINCE_BOOT)   == S_F_SINCE_BOOT)
120 #define WANT_SA_ROTAT(m)                (((m) & S_F_SA_ROTAT)     == S_F_SA_ROTAT)
121 #define USE_STABLE_ID(m)                (((m) & S_F_DEV_SID)      == S_F_DEV_SID)
122 #define USE_PRETTY_OPTION(m)            (((m) & S_F_DEV_PRETTY)   == S_F_DEV_PRETTY)
123 #define FORCE_FILE(m)                   (((m) & S_F_FORCE_FILE)   == S_F_FORCE_FILE)
124 #define INTERVAL_SET(m)                 (((m) & S_F_INTERVAL_SET) == S_F_INTERVAL_SET)
125 #define PRINT_TRUE_TIME(m)              (((m) & S_F_TRUE_TIME)    == S_F_TRUE_TIME)
126 #define LOCK_FILE(m)                    (((m) & S_F_LOCK_FILE)    == S_F_LOCK_FILE)
127 #define PRINT_SEC_EPOCH(m)              (((m) & S_F_SEC_EPOCH)    == S_F_SEC_EPOCH)
128 #define DISPLAY_HDR_ONLY(m)             (((m) & S_F_HDR_ONLY)     == S_F_HDR_ONLY)
129 #define FILE_LOCKED(m)                  (((m) & S_F_FILE_LOCKED)  == S_F_FILE_LOCKED)
130 #define USE_SA_YYYYMMDD(m)              (((m) & S_F_SA_YYYYMMDD)  == S_F_SA_YYYYMMDD)
131 #define DISPLAY_HORIZONTALLY(m)         (((m) & S_F_HORIZONTALLY) == S_F_HORIZONTALLY)
132 #define DISPLAY_COMMENT(m)              (((m) & S_F_COMMENT)      == S_F_COMMENT)
133 #define DISPLAY_PERSIST_NAME_S(m)       (((m) & S_F_PERSIST_NAME) == S_F_PERSIST_NAME)
134 #define PRINT_LOCAL_TIME(m)             (((m) & S_F_LOCAL_TIME)   == S_F_LOCAL_TIME)
135 #define USE_PREFD_TIME_OUTPUT(m)        (((m) & S_F_PREFD_TIME_OUTPUT)   == S_F_PREFD_TIME_OUTPUT)
136 #define SKIP_EMPTY_VIEWS(m)             (((m) & S_F_SVG_SKIP)     == S_F_SVG_SKIP)
137 #define DISPLAY_ZERO_OMIT(m)            (((m) & S_F_ZERO_OMIT)    == S_F_ZERO_OMIT)
138 #define DISPLAY_DEBUG_MODE(m)           (((m) & S_F_RAW_DEBUG_MODE) == S_F_RAW_DEBUG_MODE)
139 #define AUTOSCALE_ON(m)                 (((m) & S_F_SVG_AUTOSCALE) == S_F_SVG_AUTOSCALE)
140 #define DISPLAY_ONE_DAY(m)              (((m) & S_F_SVG_ONE_DAY)  == S_F_SVG_ONE_DAY)
141 #define DISPLAY_IDLE(m)                 (((m) & S_F_SVG_SHOW_IDLE) == S_F_SVG_SHOW_IDLE)
142 #define DISPLAY_INFO(m)                 (((m) & S_F_SVG_SHOW_INFO) == S_F_SVG_SHOW_INFO)
143 #define DISPLAY_UNIT(m)                 (((m) & S_F_UNIT)         == S_F_UNIT)
144 #define SET_CANVAS_HEIGHT(m)            (((m) & S_F_SVG_HEIGHT)   == S_F_SVG_HEIGHT)
145 #define PACK_VIEWS(m)                   (((m) & S_F_SVG_PACKED)   == S_F_SVG_PACKED)
146 #define DISPLAY_HUMAN_READ(m)           (((m) & S_F_HUMAN_READ)   == S_F_HUMAN_READ)
147 #define DISPLAY_TOC(m)                  (((m) & S_F_SVG_SHOW_TOC) == S_F_SVG_SHOW_TOC)
148 #define FDATASYNC(m)                    (((m) & S_F_FDATASYNC)    == S_F_FDATASYNC)
149 #define USE_OPTION_A(m)                 (((m) & S_F_OPTION_A)     == S_F_OPTION_A)
150 #define USE_OPTION_P(m)                 (((m) & S_F_OPTION_P)     == S_F_OPTION_P)
151 #define USE_OPTION_I(m)                 (((m) & S_F_OPTION_I)     == S_F_OPTION_I)
152
153 #define AO_F_NULL               0x00000000
154
155 /* Output flags for options -r / -S */
156 #define AO_F_MEMORY             0x00000001
157 #define AO_F_SWAP               0x00000002
158 /* AO_F_MEM_ALL: See opt_flags in struct activity below */
159 #define AO_F_MEM_ALL            (AO_F_MEMORY << 8)
160
161 #define DISPLAY_MEMORY(m)       (((m) & AO_F_MEMORY)    == AO_F_MEMORY)
162 #define DISPLAY_SWAP(m)         (((m) & AO_F_SWAP)      == AO_F_SWAP)
163 #define DISPLAY_MEM_ALL(m)      (((m) & AO_F_MEM_ALL)   == AO_F_MEM_ALL)
164
165 /* Output flags for option -u [ ALL ] */
166 #define AO_F_CPU_DEF            0x00000001
167 #define AO_F_CPU_ALL            0x00000002
168
169 #define DISPLAY_CPU_DEF(m)      (((m) & AO_F_CPU_DEF)     == AO_F_CPU_DEF)
170 #define DISPLAY_CPU_ALL(m)      (((m) & AO_F_CPU_ALL)     == AO_F_CPU_ALL)
171
172 /* Output flags for option -d */
173 #define AO_F_DISK_PART          0x00000001
174
175 #define COLLECT_PARTITIONS(m)   (((m) & AO_F_DISK_PART)   == AO_F_DISK_PART)
176
177 /* Output flags for option -F */
178 #define AO_F_FILESYSTEM         0x00000001
179 #define AO_F_MOUNT              0x00000002
180
181 #define DISPLAY_MOUNT(m)        (((m) & AO_F_MOUNT)       == AO_F_MOUNT)
182
183 /*
184  ***************************************************************************
185  * Various keywords and constants.
186  ***************************************************************************
187  */
188
189 /* Keywords */
190 #define K_A_NULL        "A_NULL"
191 #define K_CPU           "CPU"
192 #define K_DEV           "DEV"
193 #define K_EDEV          "EDEV"
194 #define K_EICMP         "EICMP"
195 #define K_EICMP6        "EICMP6"
196 #define K_EIP           "EIP"
197 #define K_EIP6          "EIP6"
198 #define K_ETCP          "ETCP"
199 #define K_FAN           "FAN"
200 #define K_FC            "FC"
201 #define K_FREQ          "FREQ"
202 #define K_ICMP          "ICMP"
203 #define K_ICMP6         "ICMP6"
204 #define K_IN            "IN"
205 #define K_IP            "IP"
206 #define K_IP6           "IP6"
207 #define K_MOUNT         "MOUNT"
208 #define K_NFS           "NFS"
209 #define K_NFSD          "NFSD"
210 #define K_SID           "SID"
211 #define K_SOCK          "SOCK"
212 #define K_SOCK6         "SOCK6"
213 #define K_SOFT          "SOFT"
214 #define K_SUM           "SUM"
215 #define K_TCP           "TCP"
216 #define K_TEMP          "TEMP"
217 #define K_UDP           "UDP"
218 #define K_UDP6          "UDP6"
219 #define K_XALL          "XALL"
220
221 #define K_INT           "INT"
222 #define K_DISK          "DISK"
223 #define K_XDISK         "XDISK"
224 #define K_SNMP          "SNMP"
225 #define K_IPV6          "IPV6"
226 #define K_POWER         "POWER"
227 #define K_USB           "USB"
228
229 #define K_SKIP_EMPTY    "skipempty"
230 #define K_AUTOSCALE     "autoscale"
231 #define K_ONEDAY        "oneday"
232 #define K_SHOWIDLE      "showidle"
233 #define K_SHOWINFO      "showinfo"
234 #define K_DEBUG         "debug"
235 #define K_HEIGHT        "height="
236 #define K_PACKED        "packed"
237 #define K_SHOWTOC       "showtoc"
238 #define K_CUSTOMCOL     "customcol"
239 #define K_BWCOL         "bwcol"
240 #define K_PCPARCHIVE    "pcparchive="
241
242 /* Environment variables */
243 #define ENV_COLORS_PALETTE      "S_COLORS_PALETTE"
244
245 /* Groups of activities */
246 #define G_DEFAULT       0x00
247 #define G_INT           0x01
248 #define G_DISK          0x02
249 #define G_SNMP          0x04
250 #define G_IPV6          0x08
251 #define G_POWER         0x10
252 #define G_XDISK         0x20
253
254 /* sadc program */
255 #define SADC            "sadc"
256
257 /* Time must have the format HH:MM:SS with HH in 24-hour format */
258 #define DEF_TMSTART     "08:00:00"
259 #define DEF_TMEND       "18:00:00"
260
261 #define UTSNAME_LEN     65
262 #define HEADER_LINE_LEN 512
263
264 /*
265  * Define upper limit for various items.
266  * Made necessary because we have to check the number of
267  * items for each activity when we read a (possibly tainted)
268  * sa data file.
269  */
270 #define MAX_NR_SERIAL_LINES     65536
271 #define MAX_NR_DISKS            (65536 * 4096)
272 #define MAX_NR_IFACES           65536
273 #define MAX_NR_FANS             4096
274 #define MAX_NR_TEMP_SENSORS     4096
275 #define MAX_NR_IN_SENSORS       4096
276 #define MAX_NR_USB              65536
277 #define MAX_NR_FS               (65536 * 4096)
278 #define MAX_NR_FCHOSTS          65536
279
280 /* NR_MAX is the upper limit used for unknown activities */
281 #define NR_MAX          (65536 * 4096)
282 #define NR2_MAX         1024
283
284 /* Maximum number of args that can be passed to sadc */
285 #define MAX_ARGV_NR     32
286
287 /* Miscellaneous constants */
288 #define USE_SADC                0
289 #define USE_SA_FILE             1
290 #define NO_TM_START             0
291 #define NO_TM_END               0
292 #define NO_RESET                0
293 #define NON_FATAL               0
294 #define FATAL                   1
295 #define C_SAR                   0
296 #define C_SADF                  1
297 #define ALL_ACTIVITIES          ~0U
298 #define EXIT_IF_NOT_FOUND       1
299 #define RESUME_IF_NOT_FOUND     0
300
301 #define SOFT_SIZE       0
302 #define HARD_SIZE       1
303
304 #define FIRST   0
305 #define SECOND  1
306
307 #define END_OF_DATA_UNEXPECTED  1
308 #define INCONSISTENT_INPUT_DATA 2
309
310 #define UEOF_STOP       0
311 #define UEOF_CONT       1
312
313 #define CLOSE_XML_MARKUP        0
314 #define OPEN_XML_MARKUP         1
315
316 #define CLOSE_JSON_MARKUP       0
317 #define OPEN_JSON_MARKUP        1
318
319 #define COUNT_ACTIVITIES        0
320 #define COUNT_OUTPUTS           1
321
322 /* Type for all functions reading statistics */
323 #define __read_funct_t  void
324 /* Type for all functions displaying statistics */
325 #define __print_funct_t void
326
327 /* Structure for SVG specific parameters */
328 struct svg_parm {
329         unsigned long long dt;                  /* Interval of time for current sample */
330         unsigned long long ust_time_ref;        /* X axis start time in seconds since the epoch */
331         unsigned long long ust_time_end;        /* X axis end time in seconds since the epoch */
332         unsigned long long ust_time_first;      /* Time (in seconds since the epoch) for first sample */
333         int graph_no;                           /* Total number of views already displayed */
334         int restart;                            /* TRUE if we have just met a RESTART record */
335         int nr_act_dispd;                       /* Number of activities that will be displayed */
336         struct file_header *file_hdr;           /* Pointer on file header structure */
337 };
338
339 /* Structure used when displaying SVG header */
340 struct svg_hdr_parm {
341         int graph_nr;      /* Number of rows of views to display or canvas height entered on the command line */
342         int views_per_row; /* Maximum number of views on a single row */
343         int nr_act_dispd;  /* Number of activities that will be displayed */
344 };
345
346 /*
347  ***************************************************************************
348  * System activity data files
349  *
350  * The rule is: "strict writing, read any", meaning that sar/sadc can
351  * only append data to a datafile whose format is strictly the same as that
352  * of current version (checking FORMAT_MAGIC is not enough), but sar/sadf
353  * can read data from different versions, providing that FORMAT_MAGIC value
354  * has not changed (note that we are talking here of data read from a file,
355  * not data that sar reads from sadc, in which case the "strict" rule applies).
356  *
357  * Format of system activity data files:
358  *       __
359  *      |
360  *      | file_magic structure
361  *      |
362  *      |--
363  *      |
364  *      | file_header structure
365  *      |
366  *      |--                         --|
367  *      |                             |
368  *      | file_activity structure     | * sa_act_nr
369  *      |                             |
370  *      |--                         --|
371  *      |                             |
372  *      | record_header structure     |
373  *      |                             |
374  *      |--                           |
375  *      |(__nr_t)                     |
376  *      |--                           |
377  *      |                             |
378  *      | Statistics structure(s)     | * <count>
379  *      |                             |
380  *      |--                           |
381  *      |(__nr_t)                     |
382  *      |--                           |
383  *      |                             |
384  *      | Statistics structure(s)...  |
385  *      |                             |
386  *      |--                         --|
387  *
388  * Note: For activities with varying number of items, a __nr_t value, giving
389  * the number of items, arrives before the statistics structures so that
390  * we know how many of them have to be read.
391  * NB: This value exists for all the activities even if they share the same
392  * count function (e.g. A_NET_DEV and A_NET_EDEV). Indeed, statistics are not
393  * read atomically and the number of items (e.g. network interfaces) may have
394  * varied in between.
395  *
396  * If the record header's type is R_COMMENT then we find only a comment
397  * following the record_header structure.
398  *
399  * If the record_header's type is R_RESTART then we find only the number of CPU
400  * (of type __nr_t) of the machine following the record_header structure.
401  * This number is 1 for 1 CPU and not an SMP kernel (CPU "all"),
402  * 2 for 1 CPU and SMP kernel (CPU "all" and CPU 0), etc.
403  * Of course we display the real number of CPU (e.g. "1" for 1 CPU and SMP
404  * kernel) with the LINUX RESTART message.
405  ***************************************************************************
406  */
407
408 /*
409  * Sysstat magic number. Should never be modified.
410  * Indicate that the file was created by sysstat.
411  */
412 #define SYSSTAT_MAGIC   0xd596
413 #define SYSSTAT_MAGIC_SWAPPED   (((SYSSTAT_MAGIC << 8) | (SYSSTAT_MAGIC >> 8)) & 0xffff)
414
415 /*
416  * Datafile format magic number.
417  * Modified to indicate that the format of the file is
418  * no longer compatible with that of previous sysstat versions.
419  */
420 #define FORMAT_MAGIC    0x2175
421 #define FORMAT_MAGIC_SWAPPED    (((FORMAT_MAGIC << 8) | (FORMAT_MAGIC >> 8)) & 0xffff)
422
423 /* Previous datafile format magic numbers used by older sysstat versions */
424 #define FORMAT_MAGIC_2171               0x2171
425 #define FORMAT_MAGIC_2171_SWAPPED       (((FORMAT_MAGIC_2171 << 8) | (FORMAT_MAGIC_2171 >> 8)) & 0xffff)
426 #define FORMAT_MAGIC_2173               0x2173
427 #define FORMAT_MAGIC_2173_SWAPPED       (((FORMAT_MAGIC_2173 << 8) | (FORMAT_MAGIC_2173 >> 8)) & 0xffff)
428
429 /* Padding in file_magic structure. See below. */
430 #define FILE_MAGIC_PADDING      48
431
432 /* Structure for file magic header data */
433 struct file_magic {
434         /*
435          * This field identifies the file as a file created by sysstat.
436          */
437         unsigned short sysstat_magic;
438         /*
439          * The value of this field varies whenever datafile format changes.
440          */
441         unsigned short format_magic;
442         /*
443          * Sysstat version used to create the file.
444          */
445         unsigned char sysstat_version;
446         unsigned char sysstat_patchlevel;
447         unsigned char sysstat_sublevel;
448         unsigned char sysstat_extraversion;
449 #define FILE_MAGIC_ULL_NR       0       /* Nr of unsigned long long below */
450 #define FILE_MAGIC_UL_NR        0       /* Nr of unsigned long below */
451 #define FILE_MAGIC_U_NR         5       /* Nr of [unsigned] int below */
452         /*
453          * Size of file's header (size of file_header structure used by file).
454          */
455         unsigned int header_size;
456         /*
457          * Set to non zero if data file has been converted with "sadf -c" from
458          * an old format (version x.y.z) to a newest format (version X.Y.Z).
459          * In this case, the value is: Y*256 + Z + 1.
460          * The FORMAT_MAGIC value of the file can be used to determine X.
461          */
462         unsigned int upgraded;
463         /*
464          * Description of the file_header structure
465          * (nr of "long long", nr of "long" and nr of "int").
466          */
467         unsigned int hdr_types_nr[3];
468         /*
469          * Padding. Reserved for future use while avoiding a format change.
470          * sysstat always reads a number of bytes which is that expected for
471          * current sysstat version (FILE_MAGIC_SIZE). We cannot guess if we
472          * are going to read a file from current, an older or a newer version.
473          */
474         unsigned char pad[FILE_MAGIC_PADDING];
475 };
476
477 #define FILE_MAGIC_SIZE (sizeof(struct file_magic))
478
479 /* Header structure for system activity data file */
480 struct file_header {
481         /*
482          * Timestamp in seconds since the epoch.
483          */
484         unsigned long long sa_ust_time;
485         /*
486          * Number of jiffies per second.
487          */
488         unsigned long sa_hz             __attribute__ ((aligned (8)));
489         /*
490          * Number of [online or offline] CPU (1 .. CPU_NR + 1)
491          * when the datafile has been created.
492          * When reading a datafile, this value is updated (in memory)
493          * whenever a RESTART record is found.
494          * When writing or appending data to a file, this field is updated
495          * neither in file nor in memory.
496          */
497         unsigned int sa_cpu_nr          __attribute__ ((aligned (8)));
498         /*
499          * Number of activities saved in file.
500          */
501         unsigned int sa_act_nr;
502         /*
503          * Current year.
504          */
505         int sa_year;
506         /*
507          * Description of the file_activity and record_header structures
508          * (nr of "long long", nr of "long" and nr of "int").
509          */
510         unsigned int act_types_nr[3];
511         unsigned int rec_types_nr[3];
512         /*
513          * Size of file_activity and record_header structures used by file.
514          */
515         unsigned int act_size;
516         unsigned int rec_size;
517         /*
518          * Current day and month.
519          * No need to save DST (Daylight Saving Time) flag, since it is not taken
520          * into account by the strftime() function used to print the timestamp.
521          */
522         unsigned char sa_day;
523         unsigned char sa_month;
524         /*
525          * Size of a long integer. Useful to know the architecture on which
526          * the datafile was created.
527          */
528         char sa_sizeof_long;
529         /*
530          * Operating system name.
531          */
532         char sa_sysname[UTSNAME_LEN];
533         /*
534          * Machine hostname.
535          */
536         char sa_nodename[UTSNAME_LEN];
537         /*
538          * Operating system release number.
539          */
540         char sa_release[UTSNAME_LEN];
541         /*
542          * Machine architecture.
543          */
544         char sa_machine[UTSNAME_LEN];
545 };
546
547 #define FILE_HEADER_SIZE        (sizeof(struct file_header))
548 #define FILE_HEADER_ULL_NR      1       /* Nr of unsigned long long in file_header structure */
549 #define FILE_HEADER_UL_NR       1       /* Nr of unsigned long in file_header structure */
550 #define FILE_HEADER_U_NR        11      /* Nr of [unsigned] int in file_header structure */
551 /* The values below are used for sanity check */
552 #define MIN_FILE_HEADER_SIZE    0
553 #define MAX_FILE_HEADER_SIZE    8192
554
555
556 /*
557  * Base magical number for activities.
558  */
559 #define ACTIVITY_MAGIC_BASE     0x8a
560 /*
561  * Magical value used for activities with
562  * unknown format (used for sadf -H only).
563  */
564 #define ACTIVITY_MAGIC_UNKNOWN  0x89
565
566 /* List of activities saved in file */
567 struct file_activity {
568         /*
569          * Identification value of activity.
570          */
571         unsigned int id;
572         /*
573          * Activity magical number.
574          */
575         unsigned int magic;
576         /*
577          * Number of items for this activity
578          * when the data file has been created.
579          */
580         __nr_t nr;
581         /*
582          * Number of sub-items for this activity.
583          */
584         __nr_t nr2;
585         /*
586          * Set to TRUE if statistics are preceded by
587          * a value giving the number of structures to read.
588          */
589         int has_nr;
590         /*
591          * Size of an item structure.
592          */
593         int size;
594         /*
595          * Description of the structure containing statistics for the
596          * given activity (nr of "long long", nr of "long" and nr of "int").
597          */
598         unsigned int types_nr[3];
599 };
600
601 #define FILE_ACTIVITY_SIZE      (sizeof(struct file_activity))
602 #define MAX_FILE_ACTIVITY_SIZE  1024    /* Used for sanity check */
603 #define FILE_ACTIVITY_ULL_NR    0       /* Nr of unsigned long long in file_activity structure */
604 #define FILE_ACTIVITY_UL_NR     0       /* Nr of unsigned long in file_activity structure */
605 #define FILE_ACTIVITY_U_NR      9       /* Nr of [unsigned] int in file_activity structure */
606
607
608 /* Record type */
609 /*
610  * R_STATS means that this is a record of statistics.
611  */
612 #define R_STATS         1
613 /*
614  * R_RESTART means that this is a special record containing
615  * a LINUX RESTART message.
616  */
617 #define R_RESTART       2
618 /*
619  * R_LAST_STATS warns sar that this is the last record to be written
620  * to file before a file rotation, and that the next data to come will
621  * be a header file.
622  * Such a record is tagged R_STATS anyway before being written to file.
623  */
624 #define R_LAST_STATS    3
625 /*
626  * R_COMMENT means that this is a special record containing
627  * a comment.
628  */
629 #define R_COMMENT       4
630
631 /* Maximum length of a comment */
632 #define MAX_COMMENT_LEN 64
633
634 /* Header structure for every record */
635 struct record_header {
636         /*
637          * Machine uptime in 1/100th of a second.
638          */
639         unsigned long long uptime_cs;
640         /*
641          * Timestamp (number of seconds since the epoch).
642          */
643         unsigned long long ust_time;
644         /*
645          * Record type: R_STATS, R_RESTART,...
646          */
647         unsigned char record_type;
648         /*
649          * Timestamp: Hour (0-23), minute (0-59) and second (0-59).
650          * Used to determine TRUE time (immutable, non locale dependent time).
651          */
652         unsigned char hour;
653         unsigned char minute;
654         unsigned char second;
655 };
656
657 #define RECORD_HEADER_SIZE      (sizeof(struct record_header))
658 #define MAX_RECORD_HEADER_SIZE  512     /* Used for sanity check */
659 #define RECORD_HEADER_ULL_NR    2       /* Nr of unsigned long long in record_header structure */
660 #define RECORD_HEADER_UL_NR     0       /* Nr of unsigned long in record_header structure */
661 #define RECORD_HEADER_U_NR      0       /* Nr of unsigned int in record_header structure */
662
663
664 /*
665  ***************************************************************************
666  * Generic description of an activity.
667  ***************************************************************************
668  */
669
670 /* Activity options */
671 #define AO_NULL                 0x00
672 /*
673  * Indicate that corresponding activity should be collected by sadc.
674  */
675 #define AO_COLLECTED            0x01
676 /*
677  * Indicate that corresponding activity should be displayed by sar.
678  */
679 #define AO_SELECTED             0x02
680 /*
681  * Indicate that corresponding activity has items that need to be counted.
682  * This means that its @f_count_index values is >= 0.
683  * (We use AO_COUNTED instead of @f_count_index because @f_count_index
684  * is available (initialized) only for sadc).
685  */
686 #define AO_COUNTED              0x04
687 /*
688  * Indicate that activity's metrics have persistent values when devices
689  * are registered again (this means that when the device is registered again,
690  * the metrics pick the values they had when they had been unregistered).
691  * Exclusively used for CPU related statistics at the present time.
692  */
693 #define AO_PERSISTENT           0x08
694 /*
695  * This flag should be set for every activity closing a markup used
696  * by several activities. Used by sadf f_xml_print() functions to
697  * display XML output.
698  */
699 #define AO_CLOSE_MARKUP         0x10
700 /*
701  * Indicate that corresponding activity has multiple different
702  * output formats. This is the case for example for memory activity
703  * with options -r and -R.
704  * PS: Such an activity should appear in the list of activities that
705  * sar -A is supposed to display.
706  */
707 #define AO_MULTIPLE_OUTPUTS     0x20
708 /*
709  * Indicate that one (SVG) graph will be displayed for each
710  * distinct item for this activity (sadf -g).
711  */
712 #define AO_GRAPH_PER_ITEM       0x40
713 /*
714  * Indicate that this activity may have sub-items.
715  */
716 #define AO_MATRIX               0x80
717 /*
718  * Indicate that a list of devices has been entered on the command
719  * line for this activity (see options --dev=, --iface=, ...)
720  */
721 #define AO_LIST_ON_CMDLINE      0x100
722 /*
723  * Indicate that the number of items for this activity should always
724  * be counted, even if the activity is not collected.
725  */
726 #define AO_ALWAYS_COUNTED       0x200
727
728 #define IS_COLLECTED(m)         (((m) & AO_COLLECTED)        == AO_COLLECTED)
729 #define IS_SELECTED(m)          (((m) & AO_SELECTED)         == AO_SELECTED)
730 #define HAS_COUNT_FUNCTION(m)   (((m) & AO_COUNTED)          == AO_COUNTED)
731 #define HAS_PERSISTENT_VALUES(m) (((m) & AO_PERSISTENT)      == AO_PERSISTENT)
732 #define CLOSE_MARKUP(m)         (((m) & AO_CLOSE_MARKUP)     == AO_CLOSE_MARKUP)
733 #define HAS_MULTIPLE_OUTPUTS(m) (((m) & AO_MULTIPLE_OUTPUTS) == AO_MULTIPLE_OUTPUTS)
734 #define ONE_GRAPH_PER_ITEM(m)   (((m) & AO_GRAPH_PER_ITEM)   == AO_GRAPH_PER_ITEM)
735 #define IS_MATRIX(m)            (((m) & AO_MATRIX)           == AO_MATRIX)
736 #define HAS_LIST_ON_CMDLINE(m)  (((m) & AO_LIST_ON_CMDLINE)  == AO_LIST_ON_CMDLINE)
737 #define ALWAYS_COUNT_ITEMS(m)   (((m) & AO_ALWAYS_COUNTED)   == AO_ALWAYS_COUNTED)
738
739 #define _buf0   buf[0]
740 #define _nr0    nr[0]
741
742 /* Structure used to define a bitmap needed by an activity */
743 struct act_bitmap {
744         /*
745          * Bitmap for activities that need one. Remember to allocate it
746          * before use!
747          */
748         unsigned char *b_array;
749         /*
750          * Size of the bitmap in bits. In fact, bitmap is sized to b_size + 1
751          * to take into account CPU "all"
752          */
753         int b_size;
754 };
755
756 /*
757  * Structure used to define an activity.
758  * Note: This structure can be modified without changing the format of data files.
759  */
760 struct activity {
761         /*
762          * This variable contains the identification value (A_...) for this activity.
763          */
764         unsigned int id;
765         /*
766          * Activity options (AO_...)
767          */
768         unsigned int options;
769         /*
770          * Activity magical number. This number changes when activity format in file
771          * is no longer compatible with the format of that same activity from
772          * previous versions.
773          */
774         unsigned int magic;
775         /*
776          * An activity belongs to a group (and only one).
777          * Groups are those selected with option -S of sadc.
778          */
779         unsigned int group;
780         /*
781          * Index in f_count[] array to determine function used to count
782          * the number of items (serial lines, network interfaces, etc.) -> @nr
783          * Such a function should _always_ return a value greater than
784          * or equal to 0.
785          *
786          * A value of -1 indicates that the number of items
787          * is a constant (and @nr is set to this value).
788          *
789          * These functions are called even if corresponding activities have not
790          * been selected, to make sure that all items have been calculated
791          * (including #CPU, etc.)
792          */
793         int f_count_index;
794         /*
795          * The f_count2() function is used to count the number of
796          * sub-items -> @nr2
797          * Such a function should _always_ return a value greater than
798          * or equal to 0.
799          *
800          * A NULL value for this function pointer indicates that the number of items
801          * is a constant (and @nr2 is set to this value).
802          */
803         __nr_t (*f_count2) (struct activity *);
804         /*
805          * This function reads the relevant file and fill the buffer
806          * with statistics corresponding to given activity.
807          */
808         __read_funct_t (*f_read) (struct activity *);
809         /*
810          * This function displays activity statistics onto the screen.
811          */
812         __print_funct_t (*f_print) (struct activity *, int, int, unsigned long long);
813         /*
814          * This function displays average activity statistics onto the screen.
815          */
816         __print_funct_t (*f_print_avg) (struct activity *, int, int, unsigned long long);
817         /*
818          * This function is used by sadf to display activity in a format that can
819          * easily be ingested by a relational database, or a format that can be
820          * handled by pattern processing commands like "awk".
821          */
822         __print_funct_t (*f_render) (struct activity *, int, char *, int, unsigned long long);
823         /*
824          * This function is used by sadf to display activity statistics in XML.
825          */
826         __print_funct_t (*f_xml_print) (struct activity *, int, int, unsigned long long);
827         /*
828          * This function is used by sadf to display activity statistics in JSON.
829          */
830         __print_funct_t (*f_json_print) (struct activity *, int, int, unsigned long long);
831         /*
832          * This function is used by sadf to display activity statistics in SVG.
833          */
834         __print_funct_t (*f_svg_print) (struct activity *, int, int, struct svg_parm *,
835                                         unsigned long long, struct record_header *);
836         /*
837          * This function is used by sadf to display activity statistics in raw format.
838          */
839         __print_funct_t (*f_raw_print) (struct activity *, char *, int);
840         /*
841          * This function is used by sadf to display activity statistics in PCP format.
842          */
843         __print_funct_t (*f_pcp_print) (struct activity *, int, unsigned long long,
844                                         struct record_header *);
845         /*
846          * This function is used by sadf to count the number of new items in current
847          * sample and add them to the linked list @item_list.
848          */
849         __nr_t (*f_count_new) (struct activity *, int);
850         /*
851          * Linked list containing item names. This is either all the different items
852          * found in a file for activities that have a @f_count_function() (used by sadf),
853          * or a list entered on the command line (used by sadf and sar).
854          */
855         struct sa_item *item_list;
856         /*
857          * Number of different items found in file (calculated by sadf).
858          * This is also the number of items in @item_list if this list exists.
859          */
860         __nr_t item_list_sz;
861         /*
862          * Header string displayed by sadf -d.
863          * Header lines for each output (for activities with multiple outputs) are
864          * separated with a '|' character.
865          * For a given output, the first field corresponding to extended statistics
866          * (eg. -r ALL) begins with a '&' character.
867          */
868         char *hdr_line;
869         /*
870          * Description of activity.
871          */
872         char *desc;
873         /*
874          * Name of activity.
875          */
876         char *name;
877         /*
878          * Description of the corresponding structure containing statistics (as defined
879          * in rd_stats.h or rd_sensors.h). Such a structure has 0+ fields of type
880          * "long long", followed by 0+ fields of type "long", followed by 0+ fields of
881          * type "int", followed by 0+ other fields (e.g. of type char). The array below
882          * gives the number of "long long" fields composing the structure, then the number
883          * of "long" fields, then the number of "int" fields.
884          */
885         unsigned int gtypes_nr[3];
886         /*
887          * This array has the same meaning as @gtypes_nr[] above, but the values are those
888          * read from current data file. They may be different from those of @gtypes_nr[]
889          * because we can read data from a different sysstat version (older or newer).
890          */
891         unsigned int ftypes_nr[3];
892         /*
893          * Number of SVG graphs for this activity. The total number of graphs for
894          * the activity can be greater though if flag AO_GRAPH_PER_ITEM is set, in
895          * which case the total number will  be @g_nr * @nr.
896          */
897         int g_nr;
898         /*
899          * Number of items on the system, as counted when the system is initialized.
900          * A negative value (-1) is the default value and indicates that this number
901          * has still not been calculated by the f_count() function.
902          * A value of 0 means that this number has been calculated, but no items have
903          * been found.
904          * A positive value (>0) has either been calculated or is a constant.
905          */
906         __nr_t nr_ini;
907         /*
908          * Number of sub-items on the system.
909          * @nr2 is in fact the second dimension of a matrix of items, the first
910          * one being @nr. @nr is the number of lines, and @nr2 the number of columns.
911          * A negative value (-1) is the default value and indicates that this number
912          * has still not been calculated by the f_count2() function.
913          * A value of 0 means that this number has been calculated, but no sub-items have
914          * been found.
915          * A positive value (>0) has either been calculated or is a constant.
916          * Rules:
917          * 1) IF @nr2 = 0 THEN @nr = 0
918          *    Note: If @nr = 0, then @nr2 is undetermined (may be -1, 0 or >0).
919          * 2) IF @nr > 0 THEN @nr2 > 0.
920          *    Note: If @nr2 > 0 then @nr is undetermined (may be -1, 0 or >0).
921          * 3) IF @nr <= 0 THEN @nr2 = -1 (this is the default value for @nr2,
922          * meaning that it has not been calculated).
923          */
924         __nr_t nr2;
925         /*
926          * Maximum number of elements that sar can handle for this item.
927          * NB: The maximum number of elements that sar can handle for sub-items
928          * is NR2_MAX.
929          */
930         __nr_t nr_max;
931         /*
932          * Number of items, as read and saved in corresponding buffer (@buf: See below).
933          * The value may be zero for a particular sample if no items have been found.
934          */
935         __nr_t nr[3];
936         /*
937          * Number of structures allocated in @buf[*]. This number should be greater
938          * than or equal to @nr[*].
939          */
940         __nr_t nr_allocated;
941         /*
942          * Size of an item.
943          * This is the size of the corresponding structure, as read from or written
944          * to a file, or read from or written by the data collector.
945          */
946         int fsize;
947         /*
948          * Size of an item.
949          * This is the size of the corresponding structure as mapped into memory.
950          * @msize can be different from @fsize when data are read from or written to
951          * a data file from a different sysstat version.
952          */
953         int msize;
954         /*
955          * Optional flags for activity. This is eg. used when AO_MULTIPLE_OUTPUTS
956          * option is set.
957          * 0x0001 - 0x0080 : Multiple outputs (eg. AO_F_MEMORY, AO_F_SWAP...)
958          * 0x0100 - 0x8000 : If bit set then display complete header (hdr_line) for
959          *                   corresponding output
960          * 0x010000+       : Optional flags
961          */
962         unsigned int opt_flags;
963         /*
964          * Buffers that will contain the statistics read. Its size is @nr * @nr2 * @size each.
965          * [0]: used by sadc.
966          * [0] and [1]: current/previous statistics values (used by sar).
967          * [2]: Used by sar to save first collected stats (used later to
968          * compute average).
969          */
970         void *buf[3];
971         /*
972          * Bitmap for activities that need one. Such a bitmap is needed by activity
973          * if @bitmap is not NULL.
974          */
975         struct act_bitmap *bitmap;
976 };
977
978
979 /*
980  ***************************************************************************
981  * Generic description of an output format for sadf (and sar).
982  ***************************************************************************
983  */
984
985 /* Type for all functions used by sadf to display stats in various formats */
986 #define __printf_funct_t void
987 #define __tm_funct_t char *
988
989 /*
990  * Structure used to define a report.
991  * A XML-like report has the following format:
992  *       __
993  *      |
994  *      | Header block
995  *      |  __
996  *      | |
997  *      | | Statistics block
998  *      | |  __
999  *      | | |
1000  *      | | | Timestamp block
1001  *      | | |  __
1002  *      | | | |
1003  *      | | | | Activity #1
1004  *      | | | |__
1005  *      | | | |
1006  *      | | | | ...
1007  *      | | | |__
1008  *      | | | |
1009  *      | | | | Activity #n
1010  *      | | | |__
1011  *      | | |__
1012  *      | |__
1013  *      | |
1014  *      | | Restart messages block
1015  *      | |__
1016  *      | |
1017  *      | | Comments block
1018  *      | |__
1019  *      |__
1020  */
1021 struct report_format {
1022         /*
1023          * This variable contains the identification value (F_...) for this report format.
1024          */
1025         unsigned int id;
1026         /*
1027          * Format options (FO_...).
1028          */
1029         unsigned int options;
1030         /*
1031          * This function displays the report header
1032          * (data displayed once at the beginning of the report).
1033          */
1034         __printf_funct_t (*f_header) (void *, int, char *, struct file_magic *, struct file_header *,
1035                                       struct activity * [], unsigned int [], struct file_activity *);
1036         /*
1037          * This function defines the statistics part of the report.
1038          * Used only with textual (XML-like) reports and PCP archives.
1039          */
1040         __printf_funct_t (*f_statistics) (int *, int, struct activity * [], unsigned int []);
1041         /*
1042          * This function defines the timestamp part of the report.
1043          * Used only with textual (XML-like) reports.
1044          */
1045         __tm_funct_t (*f_timestamp) (void *, int, char *, char *, unsigned long long,
1046                                      struct record_header *, struct file_header *, unsigned int);
1047         /*
1048          * This function displays the restart messages.
1049          */
1050         __printf_funct_t (*f_restart) (int *, int, char *, char *, int,
1051                                        struct file_header *, struct record_header *);
1052         /*
1053          * This function displays the comments.
1054          */
1055         __printf_funct_t (*f_comment) (int *, int, char *, char *, int, char *,
1056                                        struct file_header *, struct record_header *);
1057         /*
1058          * This is the main function used to display all the statistics for current format.
1059          */
1060         void (*f_display) (int, char *, struct file_activity *, struct file_magic *,
1061                            struct tm *, void *);
1062 };
1063
1064
1065 /* Possible actions for functions used to display reports */
1066 #define F_BEGIN 0x01
1067 #define F_MAIN  0x02
1068 #define F_END   0x04
1069
1070 /*
1071  ***************************************************************************
1072  * SVG output definitions
1073  ***************************************************************************
1074  */
1075
1076 /*
1077  *   ^
1078  * 1 | General header
1079  *   v
1080  *   ^
1081  * 9 | One line from table of contents (if any)
1082  *   v
1083  *   ^   ^   ^
1084  *   |   | 4 | Graph title
1085  *   |   |   v
1086  *   |   |   ^    |                                Caption
1087  *   | 3 |   |    |
1088  *   |   |   |  G |Y
1089  * 2 |   | 5 |  r |
1090  *   |   |   |  a |A
1091  *   |   |   |  d |x
1092  *   |   |   |  . |i
1093  *   |   |   |    |s          X Axis
1094  *   |   |   v    |-------------------------------
1095  *   |   |              Grad.
1096  *   |   v   <---><------------------------------>
1097  *   |         6                8
1098  *   | Gap
1099  *   v<---------------------------------------------------------------> Gap
1100  *                                    7
1101  *    <--------------------------------------------------------------------->
1102  *                                      8
1103  */
1104
1105 /* #8 */
1106 #define SVG_G_XSIZE     720
1107 /* #6 */
1108 #define SVG_M_XSIZE     70
1109 /* #7 */
1110 #define SVG_V_XSIZE     1050
1111 /* #8 */
1112 #define SVG_T_XSIZE     1060
1113
1114 /* #5 */
1115 #define SVG_G_YSIZE     200
1116 /* #1 */
1117 #define SVG_H_YSIZE     60
1118 /* #4 */
1119 #define SVG_M_YSIZE     50
1120 /* #2 */
1121 #define SVG_T_YSIZE     310
1122 /* #3 */
1123 #define SVG_V_YSIZE     300
1124 /* #9 */
1125 #define SVG_C_YSIZE     20
1126
1127 /* Grid: Nr of horizontal lines */
1128 #define SVG_H_GRIDNR    3
1129 /* Grid: Nr of vertical lines */
1130 #define SVG_V_GRIDNR    10
1131
1132 /* Block size used to allocate arrays for graphs data */
1133 #define CHUNKSIZE       4096
1134
1135 /* Maximum number of views on a single row */
1136 #define MAX_VIEWS_ON_A_ROW      6
1137
1138 #define SVG_LINE_GRAPH  1
1139 #define SVG_BAR_GRAPH   2
1140
1141 /* Maximum number of horizontal lines for the background grid */
1142 #define MAX_HLINES_NR   10
1143
1144 /* Color palette constants */
1145 #define SVG_COLORS_IDX_MASK     0x0f
1146 #define SVG_COL_PALETTE_SIZE    24
1147 #define SVG_COL_PALETTE_NR      3
1148 #define SVG_COL_BCKGRD_IDX      16
1149 #define SVG_COL_AXIS_IDX        17
1150 #define SVG_COL_GRID_IDX        18
1151 #define SVG_COL_TITLE_IDX       19
1152 #define SVG_COL_INFO_IDX        20
1153 #define SVG_COL_DEFAULT_IDX     21
1154 #define SVG_COL_HEADER_IDX      22
1155 #define SVG_COL_ERROR_IDX       23
1156
1157 #define SVG_DEFAULT_COL_PALETTE 0
1158 #define SVG_CUSTOM_COL_PALETTE  1
1159 #define SVG_BW_COL_PALETTE      2
1160
1161 #define MAYBE   0x80
1162
1163 /*
1164  ***************************************************************************
1165  * Macro functions definitions.
1166  *
1167  * Note: Using 'do ... while' makes the macros safer to use
1168  * (remember that macro use is followed by a semicolon).
1169  ***************************************************************************
1170  */
1171
1172 /* Close file descriptors */
1173 #define CLOSE_ALL(_fd_)         do {                    \
1174                                         close(_fd_[0]); \
1175                                         close(_fd_[1]); \
1176                                 } while (0)
1177
1178 #define CLOSE(_fd_)             if (_fd_ >= 0)          \
1179                                         close(_fd_)
1180
1181
1182 /*
1183  ***************************************************************************
1184  * Various structure definitions.
1185  ***************************************************************************
1186  */
1187
1188 /* Structure for timestamps */
1189 struct tstamp {
1190         int tm_sec;
1191         int tm_min;
1192         int tm_hour;
1193         int use;
1194 };
1195
1196 /* Structure for items in list */
1197 struct sa_item {
1198         char *item_name;
1199         struct sa_item *next;
1200 };
1201
1202
1203 /*
1204  ***************************************************************************
1205  * Functions prototypes.
1206  ***************************************************************************
1207  */
1208
1209 /*
1210  * Prototypes used to count new items
1211  */
1212 __nr_t count_new_net_dev
1213         (struct activity *, int);
1214 __nr_t count_new_net_edev
1215         (struct activity *, int);
1216 __nr_t count_new_filesystem
1217         (struct activity *, int);
1218 __nr_t count_new_fchost
1219         (struct activity *, int);
1220 __nr_t count_new_disk
1221         (struct activity *, int);
1222
1223 /* Functions used to count number of items */
1224 __nr_t wrap_get_cpu_nr
1225         (struct activity *);
1226 __nr_t wrap_get_irq_nr
1227         (struct activity *);
1228 __nr_t wrap_get_serial_nr
1229         (struct activity *);
1230 __nr_t wrap_get_disk_nr
1231         (struct activity *);
1232 __nr_t wrap_get_iface_nr
1233         (struct activity *);
1234 __nr_t wrap_get_fan_nr
1235         (struct activity *);
1236 __nr_t wrap_get_temp_nr
1237         (struct activity *);
1238 __nr_t wrap_get_in_nr
1239         (struct activity *);
1240 __nr_t wrap_get_freq_nr
1241         (struct activity *);
1242 __nr_t wrap_get_usb_nr
1243         (struct activity *);
1244 __nr_t wrap_get_filesystem_nr
1245         (struct activity *);
1246 __nr_t wrap_get_fchost_nr
1247         (struct activity *);
1248
1249 /* Functions used to read activities statistics */
1250 __read_funct_t wrap_read_stat_cpu
1251         (struct activity *);
1252 __read_funct_t wrap_read_stat_pcsw
1253         (struct activity *);
1254 __read_funct_t wrap_read_stat_irq
1255         (struct activity *);
1256 __read_funct_t wrap_read_swap
1257         (struct activity *);
1258 __read_funct_t wrap_read_paging
1259         (struct activity *);
1260 __read_funct_t wrap_read_io
1261         (struct activity *);
1262 __read_funct_t wrap_read_meminfo
1263         (struct activity *);
1264 __read_funct_t wrap_read_kernel_tables
1265         (struct activity *);
1266 __read_funct_t wrap_read_loadavg
1267         (struct activity *);
1268 __read_funct_t wrap_read_tty_driver_serial
1269         (struct activity *);
1270 __read_funct_t wrap_read_disk
1271         (struct activity *);
1272 __read_funct_t wrap_read_net_dev
1273         (struct activity *);
1274 __read_funct_t wrap_read_net_edev
1275         (struct activity *);
1276 __read_funct_t wrap_read_net_nfs
1277         (struct activity *);
1278 __read_funct_t wrap_read_net_nfsd
1279         (struct activity *);
1280 __read_funct_t wrap_read_net_sock
1281         (struct activity *);
1282 __read_funct_t wrap_read_net_ip
1283         (struct activity *);
1284 __read_funct_t wrap_read_net_eip
1285         (struct activity *);
1286 __read_funct_t wrap_read_net_icmp
1287         (struct activity *);
1288 __read_funct_t wrap_read_net_eicmp
1289         (struct activity *);
1290 __read_funct_t wrap_read_net_tcp
1291         (struct activity *);
1292 __read_funct_t wrap_read_net_etcp
1293         (struct activity *);
1294 __read_funct_t wrap_read_net_udp
1295         (struct activity *);
1296 __read_funct_t wrap_read_net_sock6
1297         (struct activity *);
1298 __read_funct_t wrap_read_net_ip6
1299         (struct activity *);
1300 __read_funct_t wrap_read_net_eip6
1301         (struct activity *);
1302 __read_funct_t wrap_read_net_icmp6
1303         (struct activity *);
1304 __read_funct_t wrap_read_net_eicmp6
1305         (struct activity *);
1306 __read_funct_t wrap_read_net_udp6
1307         (struct activity *);
1308 __read_funct_t wrap_read_cpuinfo
1309         (struct activity *);
1310 __read_funct_t wrap_read_fan
1311         (struct activity *);
1312 __read_funct_t wrap_read_temp
1313         (struct activity *);
1314 __read_funct_t wrap_read_in
1315         (struct activity *);
1316 __read_funct_t wrap_read_meminfo_huge
1317         (struct activity *);
1318 __read_funct_t wrap_read_cpu_wghfreq
1319         (struct activity *);
1320 __read_funct_t wrap_read_bus_usb_dev
1321         (struct activity *);
1322 __read_funct_t wrap_read_filesystem
1323         (struct activity *);
1324 __read_funct_t wrap_read_fchost
1325         (struct activity *);
1326 __read_funct_t wrap_read_softnet
1327         (struct activity *);
1328
1329 /* Other functions */
1330 int check_alt_sa_dir
1331         (char *, int, int);
1332 void enum_version_nr
1333         (struct file_magic *);
1334 int get_activity_nr
1335         (struct activity * [], unsigned int, int);
1336 int get_activity_position
1337         (struct activity * [], unsigned int, int);
1338 void handle_invalid_sa_file
1339         (int, struct file_magic *, char *, int);
1340 void print_collect_error
1341         (void);
1342 int set_default_file
1343         (char *, int, int);
1344 int write_all
1345         (int, const void *, int);
1346
1347 #ifndef SOURCE_SADC
1348 int add_list_item
1349         (struct sa_item **, char *, int);
1350 void allocate_bitmaps
1351         (struct activity * []);
1352 void allocate_structures
1353         (struct activity * []);
1354 int check_disk_reg
1355         (struct activity *, int, int, int);
1356 void check_file_actlst
1357         (int *, char *, struct activity * [], unsigned int, struct file_magic *,
1358          struct file_header *, struct file_activity **, unsigned int [], int, int *, int *);
1359 int check_net_dev_reg
1360         (struct activity *, int, int, int);
1361 int check_net_edev_reg
1362         (struct activity *, int, int, int);
1363 double compute_ifutil
1364         (struct stats_net_dev *, double, double);
1365 void copy_structures
1366         (struct activity * [], unsigned int [], struct record_header [], int, int);
1367 int datecmp
1368         (struct tm *, struct tstamp *, int);
1369 void display_sa_file_version
1370         (FILE *, struct file_magic *);
1371 void free_bitmaps
1372         (struct activity * []);
1373 void free_structures
1374         (struct activity * []);
1375 char *get_devname
1376         (unsigned int, unsigned int, int);
1377 char *get_sa_devname
1378         (unsigned int, unsigned int, unsigned long long [], unsigned int, unsigned int);
1379 void get_file_timestamp_struct
1380         (unsigned int, struct tm *, struct file_header *);
1381 unsigned long long get_global_cpu_statistics
1382         (struct activity *, int, int, unsigned int, unsigned char []);
1383 void get_global_soft_statistics
1384         (struct activity *, int, int, unsigned int, unsigned char []);
1385 void get_itv_value
1386         (struct record_header *, struct record_header *, unsigned long long *);
1387 void init_custom_color_palette
1388         (void);
1389 int next_slice
1390         (unsigned long long, unsigned long long, int, long);
1391 void parse_sa_devices
1392         (char *, struct activity *, int, int *, int);
1393 int parse_sar_opt
1394         (char * [], int *, struct activity * [], unsigned int *, int);
1395 int parse_sar_I_opt
1396         (char * [], int *, unsigned int *, struct activity * []);
1397 int parse_sa_P_opt
1398         (char * [], int *, unsigned int *, struct activity * []);
1399 int parse_sar_m_opt
1400         (char * [], int *, struct activity * []);
1401 int parse_sar_n_opt
1402         (char * [], int *, struct activity * []);
1403 int parse_timestamp
1404         (char * [], int *, struct tstamp *, const char *);
1405 void print_report_hdr
1406         (unsigned int, struct tm *, struct file_header *);
1407 void print_sar_comment
1408         (int *, int, char *, char *, int, char *, struct file_header *,
1409          struct record_header *);
1410 __printf_funct_t print_sar_restart
1411         (int *, int, char *, char *, int, struct file_header *, struct record_header *);
1412 int print_special_record
1413         (struct record_header *, unsigned int, struct tstamp *, struct tstamp *,
1414          int, int, struct tm *, char *, int, struct file_magic *,
1415          struct file_header *, struct activity * [], struct report_format *, int, int);
1416 int read_file_stat_bunch
1417         (struct activity * [], int, int, int, struct file_activity *, int, int,
1418          char *, struct file_magic *, int);
1419 __nr_t read_nr_value
1420         (int, char *, struct file_magic *, int, int, int);
1421 int read_record_hdr
1422         (int, void *, struct record_header *, struct file_header *, int, int,
1423          int, size_t);
1424 void reallocate_all_buffers
1425         (struct activity *, __nr_t);
1426 void replace_nonprintable_char
1427         (int, char *);
1428 int sa_fread
1429         (int, void *, size_t, int, int);
1430 int sa_get_record_timestamp_struct
1431         (unsigned int, struct record_header *, struct tm *);
1432 int sa_open_read_magic
1433         (int *, char *, struct file_magic *, int, int *, int);
1434 int search_list_item
1435         (struct sa_item *, char *);
1436 void select_all_activities
1437         (struct activity * []);
1438 void select_default_activity
1439         (struct activity * []);
1440 void set_bitmaps
1441         (struct activity * [], unsigned int *);
1442 void set_hdr_rectime
1443         (unsigned int, struct tm *, struct file_header *);
1444 void set_record_timestamp_string
1445         (unsigned int, struct record_header *, char *, char *, int, struct tm *);
1446 void swap_struct
1447         (unsigned int [], void *, int);
1448 #endif /* SOURCE_SADC undefined */
1449 #endif  /* _SA_H */