Find website that causes connections or apache load in server

by rajesh 2012-07-28 19:15:07

Here are some of the commands that will help us analyze server load

On cpanel server:
/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status


httpd fullstatus | grep "-" | awk {'print $12'} | sort | uniq -c | sort -n


For finding IPs connecting to server:
Total unique IPS:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

Total ips, with number of requests:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c


To check all other important parameters like mysql slow queries, SYN connections, exim queue

HTTPD='/usr/local/apache/conf/httpd.conf'; PHP=`php -i | grep php.ini | grep "Configuration" | cut -d ">" -f2 | cut -c 2- | tail -n 1`; MYSQL='/etc/my.cnf'; IOSTAT=( $(iostat 1 2 | grep iowait -A1 | awk '{print $4}' | grep -v system) ); echo -e "\n=== SERVER STATS ===\n"; echo -e "Host: `hostname`"; echo "CPUs: `cat /proc/cpuinfo | grep processor -c`"; echo "I/O Wait: `echo ${IOSTAT[1]}`"; echo -e "\n=== Disk Space Usage ===\n"; df -h; echo -e "\n=== MySQL Database queries ===\n"; mysqladmin proc stat; echo -e "\n=== Exim Stats ===\n"; echo -e "Emails in queue: `exim -bpc`"; echo -e "Exim procs: `ps faux | grep exim -c`"; echo -e "\n=== Number of SYN connections ===\n"; netstat -nap | grep SYN | wc -l; echo -e "\n=== Top 10 SYN Flood Conections ===\n"; netstat -tn 2>/dev/null | grep SYN | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head; echo -e "\n=== PHP Info ===\n"; egrep 'max_execution_time|max_input_time|memory_limit' $PHP; echo -e "\n=== Number of Apache Processes ===\n"; ps faux | grep httpd -c | grep -v grep; echo -e "\n=== Top 10 connections to apache ===\n"; netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head; echo -e "\n=== Current Memory Usage ===\n"; free -m; echo -e "\n=== Apache Configuation ===\n"; httpd -V | grep MPM; egrep 'MaxClients|KeepAlive|MaxRequestsPerChild|Timeout|Servers|Threads|ServerLimit' $HTTPD | grep -v SSL; echo -e "\n=== MySQL Configuration ===\n"; grep max_connections $MYSQL;
1093
like
0
dislike
0
mail
flag

You must LOGIN to add comments