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