--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/stat.rst Sun Sep 04 09:43:28 2011 +0300
@@ -0,0 +1,212 @@
+.. -*- coding: utf-8 -*-
+
+================
+ OS statistics.
+================
+.. contents::
+
+CPU consumption.
+================
+
+Linux interactive.
+------------------
+::
+
+ $ top
+ $ htop
+
+ http://htop.sourceforge.net/
+ home page
+
+Linux static.
+-------------
+::
+
+ $ ps -eo %cpu,pid,cmd --sort=%cpu
+
+FreeBSD interactive.
+--------------------
+::
+
+ $ top
+
+Windows.
+--------
+::
+
+ cmd> taskmgr
+
+Solaris.
+--------
+
+Interactive::
+
+ $ perfmeter
+
+Static::
+
+ $ prstat
+
+ $ mpstat <num> <seconds>
+
+See
+
+ http://developers.sun.com/solaris/articles/prstat.html
+ Topping top in Solaris 8 with prstat.
+
+Memory consumption.
+===================
+
+Linux interactive.
+------------------
+::
+
+ $ top
+
+Linux static.
+-------------
+
+Vitual and resident memory size::
+
+ $ ps -eo vsz,rsz,pid,cmd --sort=vsz --width 3000
+
+Swap size and usage::
+
+ $ free
+
+FreeBSD interactive.
+--------------------
+::
+
+ $ top
+
+FreeBSD static.
+---------------
+
+Swap size::
+
+ $ swapinfo
+ $ pstat -s
+
+Swap usage::
+
+ $ vmstat
+
+Solaris.
+--------
+::
+
+ $ sar -g
+
+ $ vmstat
+
+ $ prstat -s size
+
+ $ prstat -a
+
+Windows.
+--------
+::
+
+ cmd> taskmgr
+
+and add colums TODO.
+
+Opened file by process.
+=======================
+
+Linux.
+------
+::
+
+ $ lsof -p <pid>
+
+FreeBSD.
+--------
+::
+
+ $ fstat -p <pid>
+
+Windows interactive.
+--------------------
+
+procexp.exe from Sysinternals.
+
+Windows static.
+---------------
+
+handle.exe from Sysinternals::
+
+ cmd> handle -p 1265
+ C: File (RW-) C:\Program Files\Common Files\GTK\2.0\bin
+ 288: Section \BaseNamedObjects\mmGlobalPnpInfo
+
+Opened file by user.
+====================
+
+FreeBSD.
+--------
+::
+
+ $ fstat -u <user>
+
+Opened network connection by process.
+=====================================
+
+Linux.
+------
+::
+
+ $ lsof -i[46][protocol][@{hostname|hostaddr}][:{service|port}]
+
+46 - IPV4 or IPV6
+protocol - tcp, udp
+
+FreeBSD.
+--------
+
+TODO
+
+Windows.
+--------
+::
+
+ cmd> netstat -o
+ Type Local addr Remote addr State PID
+ TCP user:1154 localhost:1153 ESTABLISHED 1512
+ TCP user:5152 localhost:1052 CLOSE_WAIT 1524
+ TCP user:1036 services.int:5222 ESTABLISHED 1188
+
+Locked file by process.
+=======================
+
+Linux.
+------
+::
+
+ $ lsof <file>
+
+FreeBSD.
+--------
+
+TODO
+
+Solaris.
+--------
+
+TODO
+
+Windows interactive.
+--------------------
+
+procexp.exe from Sysinternals.
+
+Windows static.
+---------------
+
+handle.exe from Sysinternals::
+
+ cmd> handle d:\home
+ ispell.exe pid: 244 784: D:\home\drivers\token_api\src
+ Far.exe pid: 432 10C: D:\home\drivers\token_api
+