"Fossies" - the Fresh Open Source Software Archive

Member "sysstat-12.1.5/iostat.h" (31 May 2019, 6030 Bytes) of package /linux/misc/sysstat-12.1.5.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "iostat.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 12.0.3_vs_12.1.3.

    1 /*
    2  * iostat: report CPU and I/O statistics
    3  * (C) 1999-2019 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_PART_ALL        0x000010
   17 #define I_D_KILOBYTES       0x000020
   18 #define I_F_HAS_SYSFS       0x000040
   19 #define I_D_DEBUG       0x000080
   20 #define I_D_UNFILTERED      0x000100
   21 #define I_D_MEGABYTES       0x000200
   22 #define I_D_PARTITIONS      0x000400
   23 #define I_F_HAS_DISKSTATS   0x000800
   24 #define I_D_HUMAN_READ      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_PART_ALL(m)     (((m) & I_D_PART_ALL)         == I_D_PART_ALL)
   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 HAS_SYSFS(m)            (((m) & I_F_HAS_SYSFS)        == I_F_HAS_SYSFS)
   43 #define DISPLAY_DEBUG(m)        (((m) & I_D_DEBUG)            == I_D_DEBUG)
   44 #define DISPLAY_UNFILTERED(m)       (((m) & I_D_UNFILTERED)       == I_D_UNFILTERED)
   45 #define DISPLAY_PARTITIONS(m)       (((m) & I_D_PARTITIONS)       == I_D_PARTITIONS)
   46 #define HAS_DISKSTATS(m)        (((m) & I_F_HAS_DISKSTATS)    == I_F_HAS_DISKSTATS)
   47 #define DISPLAY_HUMAN_READ(m)       (((m) & I_D_HUMAN_READ)       == I_D_HUMAN_READ)
   48 #define DISPLAY_PERSIST_NAME_I(m)   (((m) & I_D_PERSIST_NAME)     == I_D_PERSIST_NAME)
   49 #define DISPLAY_OMIT_SINCE_BOOT(m)  (((m) & I_D_OMIT_SINCE_BOOT)  == I_D_OMIT_SINCE_BOOT)
   50 #define DISPLAY_DEVMAP_NAME(m)      (((m) & I_D_DEVMAP_NAME)      == I_D_DEVMAP_NAME)
   51 #define DISPLAY_ISO(m)          (((m) & I_D_ISO)              == I_D_ISO)
   52 #define DISPLAY_GROUP_TOTAL_ONLY(m) (((m) & I_D_GROUP_TOTAL_ONLY) == I_D_GROUP_TOTAL_ONLY)
   53 #define DISPLAY_ZERO_OMIT(m)        (((m) & I_D_ZERO_OMIT)        == I_D_ZERO_OMIT)
   54 #define DISPLAY_JSON_OUTPUT(m)      (((m) & I_D_JSON_OUTPUT)      == I_D_JSON_OUTPUT)
   55 #define DISPLAY_UNIT(m)         (((m) & I_D_UNIT)         == I_D_UNIT)
   56 #define DISPLAY_SHORT_OUTPUT(m)     (((m) & I_D_SHORT_OUTPUT)     == I_D_SHORT_OUTPUT)
   57 
   58 /* Preallocation constants */
   59 #define NR_DEV_PREALLOC     4
   60 
   61 /* Environment variable */
   62 #define ENV_POSIXLY_CORRECT "POSIXLY_CORRECT"
   63 
   64 /*
   65  * Structures for I/O stats.
   66  * The number of structures allocated corresponds to the number of devices
   67  * present in the system, plus a preallocation number to handle those
   68  * that can be registered dynamically.
   69  * The number of devices is found by using /sys filesystem (if mounted).
   70  * For each io_stats structure allocated corresponds a io_hdr_stats structure.
   71  * A io_stats structure is considered as unused or "free" (containing no stats
   72  * for a particular device) if the 'major' field of the io_hdr_stats
   73  * structure is set to 0.
   74  */
   75 struct io_stats {
   76     /* # of sectors read */
   77     unsigned long rd_sectors    __attribute__ ((aligned (8)));
   78     /* # of sectors written */
   79     unsigned long wr_sectors    __attribute__ ((packed));
   80     /* # of sectors discarded */
   81     unsigned long dc_sectors    __attribute__ ((packed));
   82     /* # of read operations issued to the device */
   83     unsigned long rd_ios        __attribute__ ((packed));
   84     /* # of read requests merged */
   85     unsigned long rd_merges     __attribute__ ((packed));
   86     /* # of write operations issued to the device */
   87     unsigned long wr_ios        __attribute__ ((packed));
   88     /* # of write requests merged */
   89     unsigned long wr_merges     __attribute__ ((packed));
   90     /* # of discard operations issued to the device */
   91     unsigned long dc_ios        __attribute__ ((packed));
   92     /* # of discard requests merged */
   93     unsigned long dc_merges     __attribute__ ((packed));
   94     /* Time of read requests in queue */
   95     unsigned int  rd_ticks      __attribute__ ((packed));
   96     /* Time of write requests in queue */
   97     unsigned int  wr_ticks      __attribute__ ((packed));
   98     /* Time of discard requests in queue */
   99     unsigned int  dc_ticks      __attribute__ ((packed));
  100     /* # of I/Os in progress */
  101     unsigned int  ios_pgr       __attribute__ ((packed));
  102     /* # of ticks total (for this device) for I/O */
  103     unsigned int  tot_ticks     __attribute__ ((packed));
  104     /* # of ticks requests spent in queue */
  105     unsigned int  rq_ticks      __attribute__ ((packed));
  106 };
  107 
  108 #define IO_STATS_SIZE   (sizeof(struct io_stats))
  109 
  110 struct ext_io_stats {
  111     /* r_await */
  112     double r_await;
  113     /* w_await */
  114     double w_await;
  115     /* d_await */
  116     double d_await;
  117     /* rsec/s */
  118     double rsectors;
  119     /* wsec/s */
  120     double wsectors;
  121     /* dsec/s */
  122     double dsectors;
  123     /* sec/s */
  124     double sectors;
  125     /* %rrqm */
  126     double rrqm_pc;
  127     /* %wrqm */
  128     double wrqm_pc;
  129     /* %drqm */
  130     double drqm_pc;
  131     /* rareq-sz */
  132     double rarqsz;
  133     /* wareq-sz */
  134     double warqsz;
  135     /* dareq-sz */
  136     double darqsz;
  137 };
  138 
  139 /* Possible values for field "status" in io_hdr_stats structure */
  140 #define DISK_UNREGISTERED   0
  141 #define DISK_REGISTERED     1
  142 #define DISK_GROUP      2
  143 
  144 /*
  145  * Each io_stats structure has an associated io_hdr_stats structure.
  146  * An io_hdr_stats structure tells if the corresponding device has been
  147  * unregistered or not (status field) and also indicates the device name.
  148  */
  149 struct io_hdr_stats {
  150     unsigned int status     __attribute__ ((aligned (4)));
  151     unsigned int used       __attribute__ ((packed));
  152     char name[MAX_NAME_LEN];
  153 };
  154 
  155 #define IO_HDR_STATS_SIZE   (sizeof(struct io_hdr_stats))
  156 
  157 /* List of devices entered on the command line */
  158 struct io_dlist {
  159     /* Indicate whether its partitions are to be displayed or not */
  160     int disp_part           __attribute__ ((aligned (4)));
  161     /* Device name */
  162     char dev_name[MAX_NAME_LEN];
  163 };
  164 
  165 #define IO_DLIST_SIZE   (sizeof(struct io_dlist))
  166 
  167 #endif  /* _IOSTAT_H */