]> granicus.if.org Git - sysstat/blob - iostat.h
sysstat 11.1.4
[sysstat] / iostat.h
1 /*
2  * iostat: report CPU and I/O statistics
3  * (C) 1999-2015 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _IOSTAT_H
7 #define _IOSTAT_H
8
9 #include "common.h"
10
11 /* I_: iostat - D_: Display - F_: Flag */
12 #define I_D_CPU                 0x00001
13 #define I_D_DISK                0x00002
14 #define I_D_TIMESTAMP           0x00004
15 #define I_D_EXTENDED            0x00008
16 #define I_D_PART_ALL            0x00010
17 #define I_D_KILOBYTES           0x00020
18 #define I_F_HAS_SYSFS           0x00040
19 #define I_D_DEBUG               0x00080
20 #define I_D_UNFILTERED          0x00100
21 #define I_D_MEGABYTES           0x00200
22 #define I_D_PARTITIONS          0x00400
23 #define I_F_HAS_DISKSTATS       0x00800
24 #define I_D_HUMAN_READ          0x01000
25 #define I_D_PERSIST_NAME        0x02000
26 #define I_D_OMIT_SINCE_BOOT     0x04000
27 /* Unused                       0x08000 */
28 #define I_D_DEVMAP_NAME         0x10000
29 #define I_D_ISO                 0x20000
30 #define I_D_GROUP_TOTAL_ONLY    0x40000
31 #define I_D_ZERO_OMIT           0x80000
32
33 #define DISPLAY_CPU(m)                  (((m) & I_D_CPU)              == I_D_CPU)
34 #define DISPLAY_DISK(m)                 (((m) & I_D_DISK)             == I_D_DISK)
35 #define DISPLAY_TIMESTAMP(m)            (((m) & I_D_TIMESTAMP)        == I_D_TIMESTAMP)
36 #define DISPLAY_EXTENDED(m)             (((m) & I_D_EXTENDED)         == I_D_EXTENDED)
37 #define DISPLAY_PART_ALL(m)             (((m) & I_D_PART_ALL)         == I_D_PART_ALL)
38 #define DISPLAY_KILOBYTES(m)            (((m) & I_D_KILOBYTES)        == I_D_KILOBYTES)
39 #define DISPLAY_MEGABYTES(m)            (((m) & I_D_MEGABYTES)        == I_D_MEGABYTES)
40 #define HAS_SYSFS(m)                    (((m) & I_F_HAS_SYSFS)        == I_F_HAS_SYSFS)
41 #define DISPLAY_DEBUG(m)                (((m) & I_D_DEBUG)            == I_D_DEBUG)
42 #define DISPLAY_UNFILTERED(m)           (((m) & I_D_UNFILTERED)       == I_D_UNFILTERED)
43 #define DISPLAY_PARTITIONS(m)           (((m) & I_D_PARTITIONS)       == I_D_PARTITIONS)
44 #define HAS_DISKSTATS(m)                (((m) & I_F_HAS_DISKSTATS)    == I_F_HAS_DISKSTATS)
45 #define DISPLAY_HUMAN_READ(m)           (((m) & I_D_HUMAN_READ)       == I_D_HUMAN_READ)
46 #define DISPLAY_PERSIST_NAME_I(m)       (((m) & I_D_PERSIST_NAME)     == I_D_PERSIST_NAME)
47 #define DISPLAY_OMIT_SINCE_BOOT(m)      (((m) & I_D_OMIT_SINCE_BOOT)  == I_D_OMIT_SINCE_BOOT)
48 #define DISPLAY_DEVMAP_NAME(m)          (((m) & I_D_DEVMAP_NAME)      == I_D_DEVMAP_NAME)
49 #define DISPLAY_ISO(m)                  (((m) & I_D_ISO)              == I_D_ISO)
50 #define DISPLAY_GROUP_TOTAL_ONLY(m)     (((m) & I_D_GROUP_TOTAL_ONLY) == I_D_GROUP_TOTAL_ONLY)
51 #define DISPLAY_ZERO_OMIT(m)            (((m) & I_D_ZERO_OMIT)        == I_D_ZERO_OMIT)
52
53 /* Preallocation constants */
54 #define NR_DEV_PREALLOC         4
55
56 /* Environment variable */
57 #define ENV_POSIXLY_CORRECT     "POSIXLY_CORRECT"
58
59 /*
60  * Structures for I/O stats.
61  * The number of structures allocated corresponds to the number of devices
62  * present in the system, plus a preallocation number to handle those
63  * that can be registered dynamically.
64  * The number of devices is found by using /sys filesystem (if mounted).
65  * For each io_stats structure allocated corresponds a io_hdr_stats structure.
66  * A io_stats structure is considered as unused or "free" (containing no stats
67  * for a particular device) if the 'major' field of the io_hdr_stats
68  * structure is set to 0.
69  */
70 struct io_stats {
71         /* # of sectors read */
72         unsigned long rd_sectors        __attribute__ ((aligned (8)));
73         /* # of sectors written */
74         unsigned long wr_sectors        __attribute__ ((packed));
75         /* # of read operations issued to the device */
76         unsigned long rd_ios            __attribute__ ((packed));
77         /* # of read requests merged */
78         unsigned long rd_merges         __attribute__ ((packed));
79         /* # of write operations issued to the device */
80         unsigned long wr_ios            __attribute__ ((packed));
81         /* # of write requests merged */
82         unsigned long wr_merges         __attribute__ ((packed));
83         /* Time of read requests in queue */
84         unsigned int  rd_ticks          __attribute__ ((packed));
85         /* Time of write requests in queue */
86         unsigned int  wr_ticks          __attribute__ ((packed));
87         /* # of I/Os in progress */
88         unsigned int  ios_pgr           __attribute__ ((packed));
89         /* # of ticks total (for this device) for I/O */
90         unsigned int  tot_ticks         __attribute__ ((packed));
91         /* # of ticks requests spent in queue */
92         unsigned int  rq_ticks          __attribute__ ((packed));
93 };
94
95 #define IO_STATS_SIZE   (sizeof(struct io_stats))
96
97 /* Possible values for field "status" in io_hdr_stats structure */
98 #define DISK_UNREGISTERED       0
99 #define DISK_REGISTERED         1
100 #define DISK_GROUP              2
101
102 /*
103  * Each io_stats structure has an associated io_hdr_stats structure.
104  * An io_hdr_stats structure tells if the corresponding device has been
105  * unregistered or not (status field) and also indicates the device name.
106  */
107 struct io_hdr_stats {
108         unsigned int status             __attribute__ ((aligned (4)));
109         unsigned int used               __attribute__ ((packed));
110         char name[MAX_NAME_LEN];
111 };
112
113 #define IO_HDR_STATS_SIZE       (sizeof(struct io_hdr_stats))
114
115 /* List of devices entered on the command line */
116 struct io_dlist {
117         /* Indicate whether its partitions are to be displayed or not */
118         int disp_part                   __attribute__ ((aligned (4)));
119         /* Device name */
120         char dev_name[MAX_NAME_LEN];
121 };
122
123 #define IO_DLIST_SIZE   (sizeof(struct io_dlist))
124
125 #endif  /* _IOSTAT_H */