1sg_get_disk_io_stats(3)    Library Functions Manual    sg_get_disk_io_stats(3)
2
3
4

NAME

6       sg_get_disk_io_stats,  sg_get_disk_io_stats_diff  - get disk io statis‐
7       tics
8

SYNOPSIS

10       #include <statgrab.h>
11
12
13       sg_disk_io_stats *sg_get_disk_io_stats(int *entries);
14
15       sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries);
16

DESCRIPTION

18       Both calls take a pointer to an int, entries, which is filled with  the
19       number  of  disks  the  machine  has.  This  is needed to know how many
20       sg_disk_io_stats structures have been returned. A pointer  is  returned
21       to the first sg_disk_io_stats.
22
23       sg_get_disk_io_stats  returns  the  disk  IO stored in the kernel which
24       holds the amount of data transferred since bootup. On  some  platforms,
25       such as Solaris 7, this value is stored in a 32bit int, so wraps around
26       when it reaches 4GB. Other platforms, such as Solaris 8, hold the value
27       in a 64bit int, which wraps somewhere near 17 million terabytes.
28
29       sg_get_disk_io_stats_diff is the same as sg_get_disk_io_stats except it
30       will return the difference since the last call. So, for instance a call
31       to sg_get_disk_io_stats_diff is made, and called again 5 seconds later.
32       Over that time, 2000 bytes of traffic  were  written  and  10000  bytes
33       read.  write_bytes  will store 2000 bytes, read_bytes will store 10000,
34       and systime will store 5.  This function copes with wrap arounds by the
35       O/S so should be seemless to use.
36
37       On  Solaris libstatgrab will attempt to get the cXtXdXsX representation
38       for the disk_name string. If it fails it will use a name like  sd0.  On
39       some systems programs calling libstatgrab will need elevated privileges
40       to lookup some of the names. The mappings are built up when sg_init  is
41       called.
42

RETURN VALUES

44       All  diskio  statistics  return  a  pointer  to  a  structure  of  type
45       sg_disk_io_stats.
46
47       typedef struct{
48               char *disk_name;
49               long long read_bytes;
50               long long write_bytes;
51               time_t systime;
52       }sg_disk_io_stats;
53
54
55       disk_name
56              The name known to the operating system.  (eg. on linux it  might
57              be hda)
58
59       read_bytes
60              The number of bytes the disk has read.
61
62       write_bytes
63              The number of bytes the disk has written.
64
65       systime
66              The  time  period  over  which  read_bytes  and write_bytes were
67              transferred.
68

BUGS

70       On the very first call sg_get_disk_io_stats_diff will return  the  same
71       as  sg_get_disk_io_stats.   After  the first call it will always return
72       the difference.
73
74       On operating systems that hold only 32bits of data there is  a  problem
75       if  the  values  wrap twice. For example, on Solaris 7 if 9GB is trans‐
76       ferred   and   the    operating    system    wraps    at    4GB,    the
77       sg_get_disk_io_stats_diff function will return 5GB.
78

SEE ALSO

80       statgrab(3)
81

WEBSITE

83       http://www.i-scream.org/libstatgrab/
84
85
86
87i-scream                 $Date: 2005/04/25 11:25:45 $  sg_get_disk_io_stats(3)
Impressum