How to view and tune Apache state related commands under CentOS


1. View the number of Apache connections

ps aux | grep httpd | wc -l

2. Real time monitoring of Apache connections

watch -n 1 -d “pgrep httpd|wc -l”

3. View server network

netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’

4. View the amount of memory occupied by Apache

ps aux|grep -v grep|awk ‘/httpd/{sum+=$6;n++};END{print sum/n}’