]> granicus.if.org Git - sysstat/blob - iostat.h
sar/sadc: Dereference nr array pointer in struct activity
[sysstat] / iostat.h
1 /*
2  * iostat: report CPU and I/O statistics
3  * (C) 1999-2020 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                 0x000001
13 #define I_D_DISK                0x000002
14 #define I_D_TIMESTAMP           0x000004
15 #define I_D_EXTENDED            0x000008
16 #define I_D_EVERYTHING          0x000010
17 #define I_D_KILOBYTES           0x000020
18 #define I_D_ALL_DIR             0x000040
19 #define I_D_DEBUG               0x000080
20 #define I_D_UNFILTERED          0x000100
21 #define I_D_MEGABYTES           0x000200
22 #define I_D_ALL_DEVICES         0x000400
23 #define I_F_GROUP_DEFINED       0x000800
24 #define I_D_PRETTY              0x001000
25 #define I_D_PERSIST_NAME        0x002000
26 #define I_D_OMIT_SINCE_BOOT     0x004000
27 #define I_D_JSON_OUTPUT         0x008000
28 #define I_D_DEVMAP_NAME         0x010000
29 #define I_D_ISO                 0x020000
30 #define I_D_GROUP_TOTAL_ONLY    0x040000
31 #define I_D_ZERO_OMIT           0x080000
32 #define I_D_UNIT                0x100000
33 #define I_D_SHORT_OUTPUT        0x200000
34
35 #define DISPLAY_CPU(m)                  (((m) & I_D_CPU)              == I_D_CPU)
36 #define DISPLAY_DISK(m)                 (((m) & I_D_DISK)             == I_D_DISK)
37 #define DISPLAY_TIMESTAMP(m)            (((m) & I_D_TIMESTAMP)        == I_D_TIMESTAMP)
38 #define DISPLAY_EXTENDED(m)             (((m) & I_D_EXTENDED)         == I_D_EXTENDED)
39 #define DISPLAY_EVERYTHING(m)           (((m) & I_D_EVERYTHING)       == I_D_EVERYTHING)
40 #define DISPLAY_KILOBYTES(m)            (((m) & I_D_KILOBYTES)        == I_D_KILOBYTES)
41 #define DISPLAY_MEGABYTES(m)            (((m) & I_D_MEGABYTES)        == I_D_MEGABYTES)
42 #define DISPLAY_DEBUG(m)                (((m) & I_D_DEBUG)            == I_D_DEBUG)
43 #define DISPLAY_UNFILTERED(m)           (((m) & I_D_UNFILTERED)       == I_D_UNFILTERED)
44 #define DISPLAY_ALL_DEVICES(m)          (((m) & I_D_ALL_DEVICES)      == I_D_ALL_DEVICES)
45 #define GROUP_DEFINED(m)                (((m) & I_F_GROUP_DEFINED)    == I_F_GROUP_DEFINED)
46 #define DISPLAY_PRETTY(m)               (((m) & I_D_PRETTY)           == I_D_PRETTY)
47 #define DISPLAY_PERSIST_NAME_I(m)       (((m) & I_D_PERSIST_NAME)     == I_D_PERSIST_NAME)
48 #define DISPLAY_OMIT_SINCE_BOOT(m)      (((m) & I_D_OMIT_SINCE_BOOT)  == I_D_OMIT_SINCE_BOOT)
49 #define DISPLAY_DEVMAP_NAME(m)          (((m) & I_D_DEVMAP_NAME)      == I_D_DEVMAP_NAME)
50 #define DISPLAY_ISO(m)                  (((m) & I_D_ISO)              == I_D_ISO)
51 #define DISPLAY_GROUP_TOTAL_ONLY(m)     (((m) & I_D_GROUP_TOTAL_ONLY) == I_D_GROUP_TOTAL_ONLY)
52 #define DISPLAY_ZERO_OMIT(m)            (((m) & I_D_ZERO_OMIT)        == I_D_ZERO_OMIT)
53 #define DISPLAY_JSON_OUTPUT(m)          (((m) & I_D_JSON_OUTPUT)      == I_D_JSON_OUTPUT)
54 #define DISPLAY_UNIT(m)                 (((m) & I_D_UNIT)             == I_D_UNIT)
55 #define DISPLAY_SHORT_OUTPUT(m)         (((m) & I_D_SHORT_OUTPUT)     == I_D_SHORT_OUTPUT)
56 #define USE_ALL_DIR(m)                  (((m) & I_D_ALL_DIR)          == I_D_ALL_DIR)
57
58 #define T_PART          0
59 #define T_DEV           1
60 #define T_PART_DEV      2
61 #define T_GROUP         3
62
63 /* Environment variable */
64 #define ENV_POSIXLY_CORRECT     "POSIXLY_CORRECT"
65
66 /*
67  * Structures for I/O stats.
68  * These are now dynamically allocated.
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 sectors discarded */
76         unsigned long dc_sectors        __attribute__ ((packed));
77         /* # of read operations issued to the device */
78         unsigned long rd_ios            __attribute__ ((packed));
79         /* # of read requests merged */
80         unsigned long rd_merges         __attribute__ ((packed));
81         /* # of write operations issued to the device */
82         unsigned long wr_ios            __attribute__ ((packed));
83         /* # of write requests merged */
84         unsigned long wr_merges         __attribute__ ((packed));
85         /* # of discard operations issued to the device */
86         unsigned long dc_ios            __attribute__ ((packed));
87         /* # of discard requests merged */
88         unsigned long dc_merges         __attribute__ ((packed));
89         /* # of flush requests issued to the device */
90         unsigned long fl_ios            __attribute__ ((packed));
91         /* Time of read requests in queue */
92         unsigned int  rd_ticks          __attribute__ ((packed));
93         /* Time of write requests in queue */
94         unsigned int  wr_ticks          __attribute__ ((packed));
95         /* Time of discard requests in queue */
96         unsigned int  dc_ticks          __attribute__ ((packed));
97         /* Time of flush requests in queue */
98         unsigned int  fl_ticks          __attribute__ ((packed));
99         /* # of I/Os in progress */
100         unsigned int  ios_pgr           __attribute__ ((packed));
101         /* # of ticks total (for this device) for I/O */
102         unsigned int  tot_ticks         __attribute__ ((packed));
103         /* # of ticks requests spent in queue */
104         unsigned int  rq_ticks          __attribute__ ((packed));
105 };
106
107 #define IO_STATS_SIZE   (sizeof(struct io_stats))
108
109 struct io_device {
110         char name[MAX_NAME_LEN];
111         /*
112          * 0: Not a whole device (T_PART)
113          * 1: whole device (T_DEV)
114          * 2: whole device and all its partitions to be read (T_PART_DEV)
115          * 3+: group name (T_GROUP) (4 means 1 device in the group, 5 means 2 devices in the group, etc.)
116          */
117         int dev_tp;
118         /* TRUE if device exists in /proc/diskstats or /sys. Don't apply for groups. */
119         int exist;
120         /* major and minor numbers are set only for partitions (T_PART), not whole devices */
121         int major;
122         int minor;
123         struct io_stats *dev_stats[2];
124         struct io_device *next;
125 };
126
127 struct ext_io_stats {
128         /* r_await */
129         double r_await;
130         /* w_await */
131         double w_await;
132         /* d_await */
133         double d_await;
134         /* f_await */
135         double f_await;
136         /* rsec/s */
137         double rsectors;
138         /* wsec/s */
139         double wsectors;
140         /* dsec/s */
141         double dsectors;
142         /* sec/s */
143         double sectors;
144         /* %rrqm */
145         double rrqm_pc;
146         /* %wrqm */
147         double wrqm_pc;
148         /* %drqm */
149         double drqm_pc;
150         /* rareq-sz */
151         double rarqsz;
152         /* wareq-sz */
153         double warqsz;
154         /* dareq-sz */
155         double darqsz;
156 };
157
158 #endif  /* _IOSTAT_H */