kuznet@ms2.inr.ac.ru
nstat
, ifstat
and rtacct
are simple tools helping
to monitor kernel snmp counters and network interface statistics.
These utilities are very similar, so that I describe
them simultaneously, using name Xstat
in the places which apply
to all of them.
The format of the command is:
Xstat [ OPTIONS ] [ PATTERN [ PATTERN ... ] ]
PATTERN
is shell style pattern, selecting identifier
of SNMP variables or interfaces to show. Variable is displayed
if one of patterns matches its name. If no patterns are given,
Xstat
assumes that user wants to see all the variables.
OPTIONS
is list of single letter options, using common unix
conventions.
-h
- show help page-?
- the same, of course-v
, -V
- print version of Xstat
and exit-z
- dump zero counters too. By default they are not shown.-a
- dump absolute values of counters. By default Xstat
calculates increments since the previous use.-s
- do not update history, so that the next time you will
see counters including values accumulated to the moment
of this measurement too.-n
- do not display anything, only update history.-r
- reset history.-d INTERVAL
- Xstat
is run in daemon mode collecting
statistics. INTERVAL
is interval between measurements
in seconds.-t INTERVAL
- time interval to average rates. Default value
is 60 seconds. -e
- display extended information about errors (ifstat
only).History is just dump saved in file /tmp/.Xstat.uUID
or in file given by environment variables NSTAT_HISTORY
,
IFSTAT_HISTORY
and RTACCT_HISTORY
.
Each time when you use Xstat
values there are updated.
If you use patterns, only the values which you _really_ see
are updated. If you want to skip an unintersting period,
use option -n
, or just output to /dev/null
.
Xstat
understands when history is invalidated by system reboot
or source of information switched between different instances
of daemonic Xstat
and kernel SNMP tables and does not
use invalid history.
Beware, Xstat
will not produce sane output,
when many processes use it simultaneously. If several processes
under single user need this utility they should use environment
variables to put their history in safe places
or to use it with options -a -s
.
Well, that's all. The utility is very simple, but nevertheless very handy.
Output of XSTAT
The first line of output is #
followed by identifier
of source of information, it may be word kernel
, when Xstat
gets information from kernel or some dotted decimal number followed
by parameters, when it obtains information from running Xstat
daemon.
In the case of nstat
the rest of output consists of three columns:
SNMP MIB identifier,
its value (or increment since previous measurement) and average
rate of increase of the counter per second. ifstat
outputs
interface name followed by pairs of counter and rate of its change.
Daemonic Xstat
Xstat
may be started as daemon by any user. This makes sense
to avoid wrapped counters and to obtain reasonable long counters
for large time. Also Xstat
daemon calculates average rates.
For the first goal sampling interval (option -d
) may be large enough,
f.e. for gigabit rates byte counters overflow not more frequently than
each 40 seconds and you may select interval of 20 seconds.
From the other hand, when Xstat
is used for estimating rates
interval should be less than averaging period (option -t
), otherwise
estimation loses in quality.
Client Xstat
, before trying to get information from the kernel,
contacts daemon started by this user, then it tries system wide
daemon, which is supposed to be started by superuser. And only if
none of them replied it gets information from kernel.
Environment
NSTAT_HISTORY
- name of history file for nstat
.
IFSTAT_HISTORY
- name of history file for ifstat
.
RTACCT_HISTORY
- name of history file for rtacct
.