Posts
Wiki
LINUX SERVER DIAGNOSTIC CHECKLIST
(Started by martingpmd on a thread about this.)
Something blew up on your server? Whoosh! Start diagnostic with this:
GENERAL TIPS
Check this first
Is network up?
Is DNS, other essential services up?
Memory, disk free space
What is listening, where
USE OSI MODEL FOR TROUBLESHOOTING, LUKE!!
What components must run on this server
Website, static files, databases, etc.
What components it consists of
Apache, Nginx, MySQL, Postgresql, Exim, etc.
Check if all those daemons are running
Check limits for stack, simultaneously open files, etc.
Find log files
Use your head
LONG DIAGNOSTIC CHECKLIST
# Disk space, note that on many distribution by default ~5 of disk space is reseved for root only
df -h
# Memory
free -m
# Processes
ps ax | wc -l
top
htop
# List arguments passed to program
cat /proc/<PID>/cmdline
# File permissions
# Make sure your daemon can write anything it needs to
# General info on permissions: http://nixsrv.com/llthw/ex23
# limits, maybe you app wants to create more files than it is allowed by default
# log on as user under which daemon runs and issue
ulimit -a
# Some service dies? Check its logfiles
# Apache
# Determine how many apache threads are running (if you are not using mod_status)
ps -e | grep apache2 | wc -l
# Errors (look for 500 errors caused by erroneous code on the server)
cat /var/log/apache2/error.log
# High hit rate (Check for MaxClients warningdamn in your apache error logs)
grep MaxClients /var/log/apache2/error.log
# Check for bots/spiders, you might need to lower your MaxClients settings
tail -f /var/log/apache2/access.log
# Check recent logs
ls -lrt /var/log/
# Maybe your service does not write logs in /var/log? Check with
sudo find / -type d \( -wholename '/dev' -o -wholename '/proc' -o -wholename '/sys' \) -prune -o -mmin -10 -print
# General info on logs
http://nixsrv.com/llthw/ex18
# Check for log rotation issues
# Check your cronjobs, if your server is going down at a certain time, this could be result of a cronjob eating up too many resources
ls -la /var/spool/cron/*
ls -la /etc/cron*
# General info on scheduled jobs (crojobs and atjobs)
http://nixsrv.com/llthw/ex17
# Check Kernel Messages
dmesg
# Check inodes, not that 5% of disk sp
df -i
# Install Systat for collective stats (cpu, i/o, memory, networking)
http://www.thegeekstuff.com/2011/03/sar-examples/
# Or even better, install notmal monitoring system like Zabbix already
http://www.zabbix.com/download.php
# If you suspect a DDOS attack (TODO: better use ss, non netstat)
# Number of active, and recently torn down TCP sessions
netstat -ant | egrep -i '(ESTABLISHED|WAIT|CLOSING)' | wc -l
# Number of sessions waiting for ACK (SYN Flood)
netstat -ant | egrep -i '(SYN)' | wc -l
# List listening TCP sockets
netstat -ant | egrep -i '(LISTEN)'
# Exim
# Count of 'stuck' emails
exim -bpc
# Delay, ID, sender & receiver per 'stuck' email
exim -bp