fbpx

Server Monitoring Commands

Server Monitoring Commands

Disk Stats

Disk Usage detials

df -h

LSOF means list of open files. This command watches total open files on server. A very good article for further reading http://www.catonmat.net/blog/unix-utilities-lsof/

watch --interval=1 --differences "lsof | wc -l"

Disk IO Stats

iotop
sar disk io stats
sar -s 15:00:00 -e 17:00:00

shows the disk I/O stats

watch --interval=1 iostat

12 Useful “df” Commands to Check Disk Space in Linux

General Monitoring

Find Out Who Is Logged on And What They Are Doing

watch --interval=1 "w USERNAME"

Server general stats like: uptime, load average, users, etc

watch --interval=1 "uptime"

Free and consumed ram

watch --interval=1 "free"

Monitor memory, swap, io

watch --interval=1 vmstat -a

shows the servers stats

htop
top -d 1
saidar -c

Regular expression to find a process command -a, view other users processes as well as your. “”-u””, means that information regarding the users running services, amongst other things. “”-x””, displays all processess, including those without controlling terminal sessions.”

ps aux | grep social_moinitoring

CPU model information

grep -i 'Model' /proc/cpuinfo cpu model

MySql Monitoring

List of files and folders with size at 1 second interval

watch --interval=1 "du -ch /var/lib/mysql/"

List of folders only with size at 1 second interval

watch --interval=1 "du -hs /var/lib/mysql/"

shows mysql process list in watch

watch -n 1 --differences "mysql -uYOUR-USERNAME -pYOUR-PASSWORD -e 'show full processlist'"

 
Number of queries running

watch -n 1 "mysql -uYOUR-USERNAME -pYOUR-PASSWORD -e 'show full processlist' | grep Query | wc -l"

Apache Monitoring

Number of apache threads

watch --interval=1 --differences "netstat -plan | grep :80 | wc -l"

Number of apache established threads

watch --interval=1 --differences "netstat -an | grep :80 | grep ESTABLISHED | wc -l"

watch number of apache established and listening threads per user

watch --interval=1 --differences 'netstat -plan|grep :80|grep -E "(EST||LIS)"|awk {"print $5"}|cut -d: -f 1|sort|uniq -c|sort -nk 1 | wc -l'

apache user count, connections, etc

watch --interval=1 apache2ctl status
watch --interval=1 apache2ctl fullstatus

 
ExtendedStatus On apache2ctl needs this block

<Location /server-status>
    SetHandler server-status
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
 </Location>

Firewall & Port Scaning

Check which ports are open on server.

netstat -tulpn

Scan Which ports are open/closed on server

nc -z -v -d -w1 dailypakistan.com.pk 1-1000

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Firewall open ports

nmap -v -sX localhost

Other Services/Application

Memcache Stats

watch --interval=1 "echo stats | nc 127.0.0.1 11211"

If you dont have nc installed. You can get status of memcache via php

watch 'php -r '"'"'$m=new Memcache;$m->connect("127.0.0.1", 11211);print_r($m->getstats());'"'"

 

Share this post