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