This commit is contained in:
dxin
2025-10-24 18:18:40 +08:00
parent 0122347908
commit 30d0f291ab
3 changed files with 317 additions and 2 deletions

112
问IA.md
View File

@@ -230,4 +230,114 @@ python服务的nginx日志内容
客户端IP: 10.0.0.8 | 用户: - | 时间: 23/Sep/2025:20:20:40 +0800 | 请求方法和路径: "GET /internal/search/18d2fad9-12b6-4f91-80fb-7304adf0bcd7 HTTP/1.1" | 状态码: 200 | 响应大小: 868211 | XFF: "-" | 客户端UA: "Go-http-client/1.1" | 上游服务器: 10.0.0.13:7001 | 上游响应耗时: 0.103 | 请求总耗时: 0.103 | Host: 10.0.0.3
客户端IP: 10.0.0.8 | 用户: - | 时间: 23/Sep/2025:20:20:40 +0800 | 请求方法和路径: "GET /internal/search/18d2fad9-12b6-4f91-80fb-7304adf0bcd7 HTTP/1.1" | 状态码: 200 | 响应大小: 868211 | XFF: "-" | 客户端UA: "Go-http-client/1.1" | 上游服务器: 10.0.0.13:7001 | 上游响应耗时: 0.107 | 请求总耗时: 0.107 | Host: 10.0.0.3
客户端IP: 10.0.0.8 | 用户: - | 时间: 23/Sep/2025:20:20:41 +0800 | 请求方法和路径: "GET /internal/search/18d2fad9-12b6-4f91-80fb-7304adf0bcd7 HTTP/1.1" | 状态码: 200 | 响应大小: 868211 | XFF: "-" | 客户端UA: "Go-http-client/1.1" | 上游服务器: 10.0.0.13:7001 | 上游响应耗时: 0.084 | 请求总耗时: 0.084 | Host: 10.0.0.3
客户端IP: 10.0.0.8 | 用户: - | 时间: 23/Sep/2025:20:20:41 +0800 | 请求方法和路径: "GET /internal/search/18d2fad9-12b6-4f91-80fb-7304adf0bcd7 HTTP/1.1" | 状态码: 200 | 响应大小: 868211 | XFF: "-" | 客户端UA: "Go-http-client/1.1" | 上游服务器: 10.0.0.13:7001 | 上游响应耗时: 0.293 | 请求总耗时: 0.294 | Host: 10.0.0.3
客户端IP: 10.0.0.8 | 用户: - | 时间: 23/Sep/2025:20:20:41 +0800 | 请求方法和路径: "GET /internal/search/18d2fad9-12b6-4f91-80fb-7304adf0bcd7 HTTP/1.1" | 状态码: 200 | 响应大小: 868211 | XFF: "-" | 客户端UA: "Go-http-client/1.1" | 上游服务器: 10.0.0.13:7001 | 上游响应耗时: 0.293 | 请求总耗时: 0.294 | Host: 10.0.0.3
分析一下这个内存变化:(base) [root@prod-lessie-server02 ~]#free -h
total used free shared buff/cache available
Mem: 15Gi 15Gi 133Mi 1.0Mi 237Mi 98Mi
Swap: 8.0Gi 8.0Gi 0.0Ki
(base) [root@prod-lessie-server02 ~]#ps aux|grep 7001
root 158009 0.0 0.0 35908 10420 ? S Oct21 0:12 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158011 0.8 90.3 22549000 14317120 ? Sl Oct21 24:39 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158012 0.3 0.7 4111768 117868 ? Sl Oct21 9:26 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158013 0.4 1.5 5852256 243708 ? Sl Oct21 12:08 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158014 0.5 1.6 6056408 260252 ? Sl Oct21 13:51 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158160 0.0 0.2 2404712 39116 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158186 0.0 0.7 2404684 119708 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158218 0.0 0.1 2404716 31388 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158253 0.0 0.2 2406028 35400 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 1028724 0.0 0.0 6408 384 pts/0 D+ 18:37 0:00 grep --color=auto 7001
(base) [root@prod-lessie-server02 ~]#ps aux|grep 7001
root 158009 0.0 0.0 35908 11316 ? S Oct21 0:12 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158012 0.3 0.7 4111768 119916 ? Sl Oct21 9:27 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158013 0.4 1.5 5852256 246652 ? Sl Oct21 12:11 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158014 0.5 1.6 6056408 261532 ? Sl Oct21 13:53 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158160 0.0 0.2 2404712 39244 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158186 0.0 0.7 2404684 119324 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158218 0.0 0.2 2404716 31772 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158253 0.0 0.2 2406028 35400 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 1028770 0.0 0.0 6408 2176 pts/0 S+ 18:39 0:00 grep --color=auto 7001
(base) [root@prod-lessie-server02 ~]#free -h
total used free shared buff/cache available
Mem: 15Gi 2.0Gi 12Gi 1.0Mi 961Mi 13Gi
Swap: 8.0Gi 3.9Gi 4.1Gi
(base) [root@prod-lessie-server02 ~]#
(base) [root@prod-lessie-server02 ~]#ps auxf|grep 7001
root 1029136 0.0 0.0 6408 2304 pts/0 S+ 18:39 0:00 | | \_ grep --color=auto 7001
root 158009 0.0 0.0 35908 14004 ? S Oct21 0:12 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158012 0.3 0.7 4111768 121836 ? Sl Oct21 9:27 \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158160 0.0 0.2 2404712 39244 ? Sl Oct21 0:06 | \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158013 0.4 1.5 5852256 248700 ? Sl Oct21 12:11 \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158218 0.0 0.2 2404716 31772 ? Sl Oct21 0:06 | \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158014 0.5 1.6 6056408 264348 ? Sl Oct21 13:53 \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158253 0.0 0.2 2406028 35400 ? Sl Oct21 0:06 | \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 1028807 50.5 3.4 3214636 553780 ? Sl 18:39 0:08 \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 1029008 0.0 2.9 2408940 466648 ? Sl 18:39 0:00 \_ /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
root 158186 0.0 0.7 2404652 120604 ? Sl Oct21 0:06 /data/webapps/prod_lessie_sourcing_agents/venv/bin/python /data/webapps/prod_lessie_sourcing_agents/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:7001 --timeout 300 dialogue.app:app --max-requests 500 --max-requests-jitter 50
(base) [root@prod-lessie-server02 ~]#
(base) [root@prod-lessie-server02 ~]#free -h
total used free shared buff/cache available
Mem: 15Gi 2.1Gi 12Gi 1.0Mi 1.0Gi 13Gi
Swap: 8.0Gi 3.9Gi 4.1Gi 从工作进程上分析,从内存占用大到恢复是什么原因
给我一个sh脚本每分钟记录这个项目的各个进程、子进程的内存cpu使用情况并且将结果保存在文件中。
要求每次记录要时间内存格式化成GBcpu格式化成百分比日志类似
====2025-10-01 10:00:00 ====
主进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
分析变化:
1、哪个子进程使用了更多的内存哪个进程使用了更多的CPU
2、相比上次查询哪个子进程使用了资源变化了多少
3、相比上次查询哪个子进程没了哪个子进程出现了
====2025-10-01 10:00:00 ====
====2025-10-01 10:01:00 ====
主进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
子进程名xxx | PID: xxx | 内存使用情况xxx | CPU使用情况xxx
分析变化:
1、哪个子进程使用了更多的内存哪个进程使用了更多的CPU
2、相比上次查询哪个子进程使用了资源变化了多少
3、相比上次查询哪个子进程没了哪个子进程出现了
====2025-10-01 10:01:00 ====