Sunday, April 20, 2014

Apache processes, process size, IP clients, and status

To help monitor apache performance, here are some useful command line recipes.

Show how many apache processes are running

ps aux | grep [h]ttpd | wc -l
The bracketed [h] prevents the grep process itself from being counted.

Show the average apache process size in MB

ps aux | grep [h]ttpd | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'

Show the top 10 apache client IPs by number of sockets

/bin/netstat -ntp | /bin/awk '$4 ~/:(80|443)$/ {print $5}' | /bin/sed 's/.*ffff://' | /bin/cut -d: -f 1 | /bin/sort | /usr/bin/uniq -c | /bin/sort -nr | /usr/bin/head

Show full status

apachectl fullstatus

No comments:

Post a Comment