调试使用总结

一、查看php-fpm/php-cgi进程数
ps -ef | grep php-fpm | grep pool | wc -l

二、php-fpm进程平均占用内存
ps --no-headers -o "red,cmd" -C php-fpm | awk '{sum+=$1} END {printf ("%d%s\n",sum/NR/1024,"M")}'

三、通过ps找出消耗内存的元凶
ps -A --sort -rss -o comm,pmem,pcpu | uniq -c | head -15

四、查看已有多少个php-cgi/php-fpm进程数用来处理tcp请求
netstat -anp | grep php-fpm | grep tcp | grep pool| wc -l

五、查看端口被哪个pid占用
fuser -n tcp 80

六、查看较多的SYN连接
netstat -an | grep SYN |awk '{print $5}' | aek -F:'{print $1}'|sort|uniq -c|sort -nr|more

七、查看端口和对应程序:
netstat -tlnap

八、显示所属user进程打开的文件
lsof -u www

九、查看cpu信息
cat /proc/cpuinfo 、 /proc/meminfo

十、抓包工具的使用
tcpdump -A -i eth0 //ASCII显示
tcpdump -XX -i eth0 //HEX and ASCII显示
tcpdump -w test.pcap -i eth0 // 将数据保存
tcpdump -r test.pcap //从文件读取数据
tcpdump -n -i eth0 //抓取IP地址包
tcpdump -i eth0 tcp //抓取tcp包
tcpdump -i eth0 port 22
tcpdump -i eth0 src 192.168.0.2
tcpdump -i eth0 dst 192.168.0.2

十一、通过strace调试php

strace -c -p $(pgrep -n php-fpm)
strace -c -p $(pgrep -n php-cgi)
https://www.cnblogs.com/JohnABC/p/5680470.html
http://blog.csdn.net/fantexi1984/article/details/78556800
https://segmentfault.com/a/1190000005931147
http://blog.csdn.net/terry_water/article/details/50233927
https://huoding.com/2015/10/16/474
http://blog.p2hp.com/archives/4866
https://www.cnblogs.com/leezhxing/p/4519313.html
https://segmentfault.com/a/1190000005345510
http://blog.csdn.net/dc_726/article/details/12340349
http://my.csdn.net/dc_726(博主其他资料查看)
http://blog.haohtml.com/archives/11162
https://blog.haohtml.com/archives/9666
https://blog.haohtml.com/archives/7059
http://www.cnblogs.com/lost-1987/articles/3800139.html
http://blog.csdn.net/qq624202120/article/details/60957634
http://blog.163.com/zhu329599788@126/blog/static/66693350201611146261856/
sudo HTTP_HOST=127.0.0.1 REQUEST_URI=/index.php strace -t -f -o strace.txt /amu/php/bin/php /amu/code/php/index.php >> 22.html

你可能感兴趣的:(调试使用总结)