| 3 |
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
| 4 |
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
| 5 |
|
|
| 6 |
< |
<refentry id="get_network_stats"> |
| 6 |
> |
<refentry id="sg_get_network_io_stats"> |
| 7 |
|
|
| 8 |
|
<refentryinfo> |
| 9 |
|
<date>$Date$</date> |
| 10 |
|
<releaseinfo>$Id$</releaseinfo> |
| 11 |
|
</refentryinfo> |
| 12 |
< |
|
| 12 |
> |
|
| 13 |
|
<refmeta> |
| 14 |
< |
<refentrytitle>get_network_stats</refentrytitle> |
| 14 |
> |
<refentrytitle>sg_get_network_io_stats</refentrytitle> |
| 15 |
|
<manvolnum>3</manvolnum> |
| 16 |
|
<refmiscinfo>i-scream</refmiscinfo> |
| 17 |
|
</refmeta> |
| 18 |
< |
|
| 18 |
> |
|
| 19 |
|
<refnamediv> |
| 20 |
< |
<refname>get_network_stats</refname> |
| 21 |
< |
<refname>get_network_stats_diff</refname> |
| 20 |
> |
<refname>sg_get_network_io_stats</refname> |
| 21 |
> |
<refname>sg_get_network_io_stats_diff</refname> |
| 22 |
|
<refpurpose>get network statistics</refpurpose> |
| 23 |
|
</refnamediv> |
| 24 |
< |
|
| 24 |
> |
|
| 25 |
|
<refsynopsisdiv> |
| 26 |
|
<funcsynopsis> |
| 27 |
|
<funcsynopsisinfo>#include <statgrab.h></funcsynopsisinfo> |
| 28 |
|
<funcprototype> |
| 29 |
< |
<funcdef>network_stat_t *<function>get_network_stats</function></funcdef> |
| 29 |
> |
<funcdef>sg_network_io_stats *<function>sg_get_network_io_stats</function></funcdef> |
| 30 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
| 31 |
|
</funcprototype> |
| 32 |
|
<funcprototype> |
| 33 |
< |
<funcdef>network_stat_t *<function>get_network_stats_diff</function></funcdef> |
| 33 |
> |
<funcdef>sg_network_io_stats *<function>sg_get_network_io_stats_diff</function></funcdef> |
| 34 |
|
<paramdef>int *<parameter>entries</parameter></paramdef> |
| 35 |
|
</funcprototype> |
| 36 |
|
</funcsynopsis> |
| 37 |
|
</refsynopsisdiv> |
| 38 |
< |
|
| 38 |
> |
|
| 39 |
|
<refsect1> |
| 40 |
|
<title>Description</title> |
| 41 |
|
<para> |
| 42 |
|
Both calls take a pointer to an int, |
| 43 |
|
<parameter>entries</parameter>, which is filled with the number |
| 44 |
|
of network interfaces the machine has. This is needed to know how |
| 45 |
< |
many <structname>network_stat_t</structname> structures have been |
| 45 |
> |
many <structname>sg_network_io_stats</structname> structures have been |
| 46 |
|
returned. A pointer is returned to the first |
| 47 |
< |
<structname>network_stat_t</structname>. |
| 47 |
> |
<structname>sg_network_io_stats</structname>. |
| 48 |
|
</para> |
| 49 |
|
<para> |
| 50 |
< |
<function>get_network_stats</function> returns the network |
| 50 |
> |
<function>sg_get_network_io_stats</function> returns the network |
| 51 |
|
traffic stored in the kernel which holds the amount of data |
| 52 |
|
transferred since bootup. On some platforms, such as Solaris 7, |
| 53 |
|
this value is stored in a 32bit int, so wraps around when it |
| 55 |
|
in a 64bit int, which wraps somewhere near 17 million terabytes. |
| 56 |
|
</para> |
| 57 |
|
<para> |
| 58 |
< |
<function>get_network_stats</function> also returns the number |
| 58 |
> |
<function>sg_get_network_io_stats</function> also returns the number |
| 59 |
|
of packets sent and received, and the number of errors that |
| 60 |
|
have occured. It also makes the number of collisions available. |
| 61 |
|
</para> |
| 62 |
|
<para> |
| 63 |
< |
<function>get_network_stats_diff</function> is the same as |
| 64 |
< |
<function>get_network_stats</function> except it will return the |
| 63 |
> |
<function>sg_get_network_io_stats_diff</function> is the same as |
| 64 |
> |
<function>sg_get_network_io_stats</function> except it will return the |
| 65 |
|
difference since the last call. So, for instance a call to |
| 66 |
< |
<function>get_network_stats_diff</function> is made, and called |
| 66 |
> |
<function>sg_get_network_io_stats_diff</function> is made, and called |
| 67 |
|
again 5 seconds later. Over that time, 20 bytes of traffic was |
| 68 |
|
transmitted and 10 bytes received. Tx will store 20, rx will |
| 69 |
|
store 10 and systime will store 5. This function copes with wrap |
| 70 |
|
arounds by the O/S so should be seemless to use. |
| 71 |
|
</para> |
| 72 |
|
</refsect1> |
| 73 |
< |
|
| 73 |
> |
|
| 74 |
|
<refsect1> |
| 75 |
|
<title>Return Values</title> |
| 76 |
|
|
| 77 |
|
<para> |
| 78 |
|
All network statistics return a pointer to a structure of type |
| 79 |
< |
<structname>network_stat_t</structname>. |
| 79 |
> |
<structname>sg_network_io_stats</structname>. |
| 80 |
|
</para> |
| 81 |
|
|
| 82 |
|
<programlisting> |
| 90 |
|
long long oerrors; |
| 91 |
|
long long collisions; |
| 92 |
|
time_t systime; |
| 93 |
< |
}network_stat_t; |
| 93 |
> |
}sg_network_io_stats; |
| 94 |
|
</programlisting> |
| 95 |
|
|
| 96 |
|
<variablelist> |
| 182 |
|
<listitem> |
| 183 |
|
<para> |
| 184 |
|
The time period over which <parameter>tx</parameter> |
| 185 |
< |
and <parameter>rx</parameter> were transferred. |
| 185 |
> |
and <parameter>rx</parameter> were transferred. |
| 186 |
|
</para> |
| 187 |
|
</listitem> |
| 188 |
|
</varlistentry> |
| 193 |
|
<title>Bugs</title> |
| 194 |
|
<para> |
| 195 |
|
On the very first call |
| 196 |
< |
<function>get_network_stats_diff</function> will return the same |
| 197 |
< |
as <function>get_network_stats</function>. After the first call |
| 196 |
> |
<function>sg_get_network_io_stats_diff</function> will return the same |
| 197 |
> |
as <function>sg_get_network_io_stats</function>. After the first call |
| 198 |
|
it will always return the difference. |
| 199 |
|
</para> |
| 200 |
|
<para> |
| 201 |
|
On operating system that hold only 32bits of data there is a |
| 202 |
|
problem if the values wrap twice. For example, on Solaris 7 if |
| 203 |
|
9GB is transferred and the operating system wraps at 4GB, the |
| 204 |
< |
<function>get_network_stats_diff</function> function will return |
| 204 |
> |
<function>sg_get_network_io_stats_diff</function> function will return |
| 205 |
|
5GB. |
| 206 |
|
</para> |
| 207 |
|
</refsect1> |
| 218 |
|
</member> |
| 219 |
|
</simplelist> |
| 220 |
|
</refsect1> |
| 221 |
< |
|
| 221 |
> |
|
| 222 |
|
<refsect1> |
| 223 |
|
<title>Website</title> |
| 224 |
< |
|
| 224 |
> |
|
| 225 |
|
<simplelist type="vert"> |
| 226 |
|
<member> |
| 227 |
< |
<ulink url="http://www.i-scream.org">http://www.i-scream.org</ulink> |
| 227 |
> |
<ulink url="http://www.i-scream.org/libstatgrab/"> |
| 228 |
> |
http://www.i-scream.org/libstatgrab/ |
| 229 |
> |
</ulink> |
| 230 |
|
</member> |
| 231 |
|
</simplelist> |
| 232 |
|
</refsect1> |