Check Linux server status

vmstat, iostat, top…etc are useful to check server load, I/O or memory usage.

iostat
r/s and w/s
the number of read and write requests sent to the device per second
await
the number of requests waiting in the device’s queue
svctm
the number of miliseconds spent servicing requests, from beginning to end
util
the percentage of the device utilization

vmstat
procs
r: processes are waiting for the CPU time
b: processes are in sleep (means they are waiting for I/O)
io
bi/bo: how many blocks reading in/out the device
system
in: number of interrupts per second
cs: context switches per second

Here are some good sites showing how to use them

http://www.cyberciti.biz/tips/linux-disk-performance-monitoring-howto.html
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
http://www.linuxforums.org/articles/using-top-more-efficiently_89.html
http://software.intel.com/en-us/blogs/2011/02/09/using-linux-top-to-troubleshoot-multi-core-scalability-issues-at-dreamworks-animation/

Good article about I/O scheduler
http://www.linuxjournal.com/article/6931

manipulating strings

1. cut

Ex. #echo “192.168.1.10:8080″| cut -d: -f1
192.168.1.10

Ex. User with uniq & sort

Ex. #netstat -nap|less|grep ‘192.168’| awk ‘{print $5}’|uniq -c|sort -nr -k 1

2. sed

match a string and replace it

echo “I love poem”|sed ‘s/peom/music/’

ldconfig — change lib path

Sometimes it’s preferred to install libraries into non-default locations, such as /usr/local/,
but how to let the system know where to find them?

ldconfig can be used to change the lib path,

Ex. To have the system be able to find libraries under /usr/local/lib for myapp

vi /etc/ld.so.conf.d/myapp.conf
/usr/local/lib
#ldconfig

To check result
#ldconfig -v

# ldconfig -l /path/to/lib/missing.lib.so

Great articles about shared libraries.
http://www.cyberciti.biz/faq/linux-setting-changing-library-path/
http://www.cyberciti.biz/tips/linux-shared-library-management.html

Linux Network command –tcpdump

Examples:

Show details of packets
#tcpdump -nnvvXS

tcpdump

show specific type of connection
#tcpdump icmp/tcp/udp

Add more options with source/destination IP/port, write to file
tcpdump -nnvvXS src 1.2.3.4 and port 3306 -w /tmp/test.pcap

Read tcpdump log from the file
tcpdump -qns -0 A -r /tmp/test.pcap

tcpick -C -yP -r /tmp/test.pcap

ngrep
ngrep -d any -W byline dst 1.2.3.4 > /tmp/test.pcap