Wednesday, March 31, 2010

FreeBSD Statistic Tools

On this page I provide a list of statistical tools for FreeBSD to monitor your
system. There are a lot of them, so if I missed one please mail me (ronald at
echteman dot nl).

fstat The fstat utility identifies open files.
gstat The gstat utility can be used to monitor I/O transactions of geom(4)
devices.
iostat
The iostat utility displays kernel I/O statistics on terminal, device and cpu
operations.
netstat The netstat command symbolically displays the contents of various
network-related data structures.
nfsstat The nfsstat command displays statistics kept about NFS client and server
activity.
pstat The pstat utility displays open file entry, swap space utilization,
terminal state, and vnode data structures.
top Top displays the top processes on the system and periodically updates this
information.
systat The systat utility displays various system statistics in a screen oriented fashion.
vmstat The vmstat utility reports certain kernel statistics kept about process,
virtual memory, disk, trap and cpu activity.

  • fstat

    The fstat utility identifies open files.
    USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
    ronald   fstat       1087 root /             2 drwxr-xr-x     512  r
    ronald   fstat       1087   wd /usr     824321 drwxr-xr-x    3584  r
    ronald   fstat       1087 text /usr     1038656 -r-xr-sr-x   14624  r
    ronald   fstat       1087    0 /dev        126 crw--w----   ttyp1 rw
    ronald   fstat       1087    1 /dev        126 crw--w----   ttyp1 rw
    ronald   fstat       1087    2 /dev        126 crw--w----   ttyp1 rw
    ronald   fstat       1087    3 /dev         15 crw-r-----     mem  r
    ronald   fstat       1087    4 /dev         16 crw-r-----    kmem  r
    ronald   fstat       1087    5 /          8700 -rw-r--r--   40960  r
    ronald   vim         1025 root /             2 drwxr-xr-x     512  r
    ronald   vim         1025   wd /tmp          2 drwxrwxrwt     512  r
    ronald   vim         1025 text /usr     329983 -rwxr-xr-x  1266616  r
    ronald   vim         1025    0 /dev        129 crw--w----   ttyp3 rw
    ronald   vim         1025    1 /dev        129 crw--w----   ttyp3 rw
    
    

  • gstat

    The gstat utility can be used to monitor I/O transactions of geom(4) devices.
    dT: 0.504  flag_I 500000us  sizeof 240  i -1
     L(q)  ops/s    r/s   kBps   ms/r    w/s   kBps   ms/w   %busy Name
        1     91     91    964    3.6      0      0    0.0   33.2| ad0
        1     91     91    964    3.7      0      0    0.0   33.4| ad0s1
        0      0      0      0    0.0      0      0    0.0    0.0| acd0
        0      0      0      0    0.0      0      0    0.0    0.0| ad0s1a
        0      0      0      0    0.0      0      0    0.0    0.0| ad0s1b
        0      0      0      0    0.0      0      0    0.0    0.0| ad0s1c
        0      0      0      0    0.0      0      0    0.0    0.0| ad0s1d
        1     91     91    964    3.7      0      0    0.0   33.7| ad0s1e
        0      0      0      0    0.0      0      0    0.0    0.0| md0
    
  • iostat

    The iostat utility displays kernel I/O statistics on terminal, device and cpu
    operations.
          tty             ad0              fd0             cpu
     tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
      16  567 13.22  17  0.22   0.00   0  0.00   9  0  3  1 86
     821  880 64.00   0  0.02   0.00   0  0.00   8  0  3  1 89
     844  864  0.00   0  0.00   0.00   0  0.00   7  0  3  1 89
     945  965 64.00   0  0.02   0.00   0  0.00   6  0  4  1 89
     961  981 64.00   0  0.02   0.00   0  0.00   6  0  3  3 88
     961  981  0.00   0  0.00   0.00   0  0.00   6  0  2  1 90
     961  981 64.00   0  0.02   0.00   0  0.00   8  0  2  1 89
    
    
  • netstat

    The netstat command symbolically displays the contents of various
    network-related data structures. There are a number of output formats,
    depending on the options for the information presented.
    Active Internet connections
    Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
    tcp4       0      0  192.168.0.2.63566      193.69.116.13.http     CLOSE_WAIT
    tcp4       0      0  192.168.0.2.52783      216.239.41.104.http    ESTABLISHED
    tcp4       0      0  192.168.0.2.49413      solo.cs.vu.nl.imap     ESTABLISHED
    tcp4       0      0  192.168.0.2.65519      ronald.echteman..imap  ESTABLISHED
    tcp4       0      0  192.168.0.2.49324      ronald.echteman..imap  ESTABLISHED
    tcp4       0      0  192.168.0.2.50677      192.168.0.1.ssh        ESTABLISHED
    udp4       0      0  localhost.ntp          *.*                    
    udp4       0      0  192.168.0.2.ntp        *.*                    
    udp4       0      0  localhost.domain       *.*                    
    udp4       0      0  192.168.0.2.domain     *.*                    
    Active UNIX domain sockets
    Address  Type   Recv-Q Send-Q    Inode     Conn     Refs  Nextref Addr
    c15fe348 stream      0      0        0 c15fed20        0        0 /tmp/.X11-unix/X0
    c15fed20 stream      0      0        0 c15fe348        0        0
    c19ed118 stream      0      0        0 c15fd1a4        0        0
    c15fd1a4 stream      0      0        0 c19ed118        0        0
    c15fe118 stream      0      0        0 c15fe3d4        0        0
    
  • nfsstat

    The nfsstat command displays statistics kept about NFS client and server
    activity.
    Client Info:
    Rpc Counts:
      Getattr   Setattr    Lookup  Readlink      Read     Write    Create    Remove
            0         0         0         0         0         0         0         0
       Rename      Link   Symlink     Mkdir     Rmdir   Readdir  RdirPlus    Access
            0         0         0         0         0         0         0         0
        Mknod    Fsstat    Fsinfo  PathConf    Commit
            0         0         0         0         0
    Rpc Info:
     TimedOut   Invalid X Replies   Retries  Requests
            0         0         0         0         0
    Cache Info:
    Attr Hits    Misses Lkup Hits    Misses BioR Hits    Misses BioW Hits    Misses
            0         0         0         0         0         0         0         0
    BioRLHits    Misses BioD Hits    Misses DirE Hits    Misses
            0         0         0         0         0         0
    
    Server Info:
      Getattr   Setattr    Lookup  Readlink      Read     Write    Create    Remove
            0         0         0         0         0         0         0         0
       Rename      Link   Symlink     Mkdir     Rmdir   Readdir  RdirPlus    Access
            0         0         0         0         0         0         0         0
        Mknod    Fsstat    Fsinfo  PathConf    Commit
            0         0         0         0         0
    Server Ret-Failed
                    0
    Server Faults
                0
    Server Cache Stats:
       Inprog      Idem  Non-idem    Misses
            0         0         0         0
    Server Write Gathering:
     WriteOps  WriteRPC   Opsaved
            0         0         0
    

  • pstat

    The pstat utility displays open file entry, swap space utilization, terminal
    state, and vnode data structures.
      LINE RAW CAN OUT IHIWT ILOWT OHWT LWT     COL STATE  SESS      PGID DISC
      ttyv0  0   0   0  7680  6720 2052 256       0 OCc         683   694 term
      ttyv1  0   0   0  7680  6720 2052 256       0 OCc         684   711 term
      ttyv2  0   0   0  7680  6720 2052 256       7 OCc         685   685 term
      ttyv3  0   0   0  7680  6720 2052 256       7 OCc         686   686 term
      ttyv4  0   0   0  7680  6720 2052 256       7 OCc         687   687 term
      ttyv5  0   0   0  7680  6720 2052 256       7 OCc         688   688 term
      ttyv6  0   0   0  7680  6720 2052 256       7 OCc         689   689 term
      ttyv7  0   0   0  7680  6720 2052 256       7 OCc         690   690 term
      ttyv8  0   0   0  7680  6720 1296 256       2 OCc           0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
        0,0  0   0   0     0     0    0   0       0 -             0     0 term
    consolectl  0   0   0  7680  6720 1296 256       0 -             0     0 term
      ttyp0  0   0   0  7680  6720 2052 256       0 OCc         729   943 term
      ttyp1  0   0  76  7680  6720 2052 256       0 OCc         754  1279 term
      ttyp2  0   0   0  7680  6720 2052 256   96221 OCc         778  1217 term
      ttyp3  0   0   0  7680  6720 2052 256       0 OCc         807   807 term
      cuaa0  0   0   0  7680  6720 1296 256     336 OCcXl         0     0 term
      ttyp4  0   0   0  7680  6720 2052 256       0 OCc        1210  1216 term
    
  • top

    Top displays the top processes on the system and periodically updates this
    information.
    last pid:  1421;  load averages:  0.02,  0.08,  0.08    up 0+01:42:59  11:49:46
    61 processes:  1 running, 60 sleeping
    CPU states:  5.4% user,  0.0% nice,  1.2% system,  0.0% interrupt, 93.4% idle
    Mem: 83M Active, 213M Inact, 62M Wired, 13M Cache, 48M Buf, 824K Free
    Swap: 743M Total, 743M Free
    
      PID USERNAME PRI NICE   SIZE    RES STATE    TIME   WCPU    CPU COMMAND
     1216 ronald    -8    0  6844K  1048K pcmwr    1:25  2.34%  2.34% mpg123
      734 ronald    76    0 51104K 44804K select   2:33  0.00%  0.00% opera
      710 ronald    76  -10 17292K 16096K select   2:29  0.00%  0.00% XFree86
      777 ronald    76    0  4888K  3280K select   0:46  0.00%  0.00% xterm
      723 ronald    76    0  6588K  4236K select   0:14  0.00%  0.00% icewm
     1218 root       5    0  1256K   840K ttyin    0:06  0.00%  0.00% tip
      806 ronald    76    0  4888K  3344K select   0:05  0.00%  0.00% xterm
      753 ronald    76    0  5284K  3712K select   0:03  0.00%  0.00% xterm
      521 root      76    0  1588K  1080K select   0:00  0.00%  0.00% ntpd
      727 ronald    76    0  4904K  3252K select   0:00  0.00%  0.00% xterm
     1410 ronald    76    0  7276K  4652K select   0:00  0.00%  0.00% vim
      724 ronald    76    0  2564K  1580K select   0:00  0.00%  0.00% ssh-agent
      754 ronald     5    0  2192K  1676K ttyin    0:00  0.00%  0.00% bash
      807 ronald     8    0  2196K  1708K wait     0:00  0.00%  0.00% bash
     1209 ronald    76    0  4888K  3648K select   0:00  0.00%  0.00% xterm
      684 root       8    0  1616K  1164K wait     0:00  0.00%  0.00% login
      328 bind      76    0  2760K  2076K select   0:00  0.00%  0.00% named
    

  • systat

    The systat utility displays various system statistics in a screen oriented
    fashion.
        6 users    Load  0.08  0.23  0.26                  Aug 12 10:47
    
    Mem:KB    REAL            VIRTUAL                     VN PAGER  SWAP PAGER
            Tot   Share      Tot    Share    Free         in  out     in  out
    Act   81112    5180   147268     9244   24120 count
    All  376852    6864  2954884    12200         pages
                                                                     Interrupts
    Proc:r  p  d  s  w    Csw  Trp  Sys  Int  Sof  Flt        cow     386 total
               3 56       645   17  721  642   14       57968 wire    250 0: clk
                                                        81664 act         1: atkb
     1.2%Sys   0.8%Intr  0.8%User  0.0%Nice 97.2%Idl   217284 inact       6: fdc0
    |    |    |    |    |    |    |    |    |    |      20720 cache       7: ppc0
    =                                                    3400 free    128 8: rtc
                                                              daefr     7 11: pcm
    Namei         Name-cache    Dir-cache                     prcfr       12: psm
        Calls     hits    %     hits    %                     react       13: npx
                                                              pdwak     1 14: ata
                                              zfod            pdpgs       15: ata
    Disks   ad0   fd0                         ofod            intrn
    KB/t  16.00  0.00                         %slo-z    48784 buf
    tps       1     0                         tfree         1 dirtybuf
    MB/s   0.02  0.00                                   26886 desiredvnodes
    % busy    0     0                                   20241 numvnodes
                                                         3786 freevnodes
    
  • vmstat

    The vmstat utility reports certain kernel statistics kept about process,
    virtual memory, disk, trap and cpu activity.
     procs      memory      page                    disks     faults      cpu
     r b w     avm    fre  flt  re  pi  po  fr  sr ad0 fd0   in   sy  cs us sy id
     1 2 0  138200  20520   48   0   0   0  81  41   0   0  809 1780 1151 10  5 86
     0 2 0  138200  20520    1   0   0   0   1   0   0   0  633  514 590  1  1 98
     0 2 0  138200  20520    0   0   0   0   0   0   0   0  632  469 587  0  1 98
     0 2 0  138200  20520    0   0   0   0   0   0   0   0  687  681 716  1  2 97
     0 2 0  138200  20520    0   0   0   0   1   0   1   0  673  704 686  1  1 98
     2 3 0  139372  20176   79   0   0   0  46   0   3   0  644 1017 654  2  3 95
     0 3 0  139432  18364   12   0   0   0   7   0  67   0  701 14122 2141 56 23 20
     2 2 0  139868  16748   37   0   0   0   0   0  35   0  667 12963 2603 66 20 13
     2 2 0  139920  15648    5   0   0   0  69   0  50   0  682 15063 1930 65 23 12
     0 2 0  138200  14104    6   0   0   0 262   0 124   0  759 10485 1937 30 16 55
    
    

No comments: