York's Blog

Linux System Diagnostic Tools

| Comments

Show utilization of each CPU individually.

mpstat -P ALL

Sampling CPU usage in 2 seconds frame for 5 times

sar -u 2 5

Can also be found in logs

sar - f /var/log/sysstat/sa09

See who is eating CPU

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

Show I/O stats every 5 seconds

iostat -xtc 5

Show resource stats using megabyte as unit

vmstat -S M 2 5

Show NFS stats

nfstat

Find memory used by a process using pmap

pmap <pid>

Display sockets summary

ss -s

Show open sockets with process name

ss -pl

show all ports connected from remote 192.168.1.5:http port

ss dst 192.168.1.5:http
ss dst 192.168.1.5:smtp 
ss dst 192.168.1.5:443

Find out all ips connected to ip address x.x.x.x, where x.x.x.x is the machine's ip address

ss src x.x.x.x

Show all connections

netstat -nat

Detect DDoS attack

netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n

Summary statistics by protocol

netstat -s

View system call stacks of a process

strace -o output.txt /bin/foo
strace -p 12345 -s 80 -o /tmp/debug.httpd.txt
strace -e trace=open,read -p 22254 -s 80 -o debug.http.txt

Comments

comments powered by Disqus