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