---
title: "查看linux 线程 "
author: "FutureInHands"
date: "2011-11-22T11:35:26Z"
tags: []
categories: ["操作系统"]
slug: "linux"
draft: false
lastmod: "2011-11-22T11:35:26Z"
id: 1271837
url: "https://futureinhands.iteye.com/blog/1271837"
---

### [查看linux 线程](http://futureinhands.iteye.com/blog/1152814)

- **博客分类：**
- [linux](http://futureinhands.iteye.com/category/128012)

3中方法：

1\. cat /proc/${pid}/status

2\. pstree -p ${pid}

3\. top -p ${pid} 再按H

    或者直接输入 top -bH -d 3 -p ${pid}

查看进程工作

strace -p ${pid}

开启iptables日志  
iptables -t raw -I PREROUTING 1 -p tcp --syn -m statistic --mode nth --every 5000 -j LOG --log-prefix "IPTABLES DETECTING SYN: "  
tail /var/log/message  
关闭iptables日志  
iptables -t raw -F

查看是否被攻击  
netstat -n -p TCP | grep SYN\_RECV | grep :80 | wc -l  
netstat -tn|grep ESTABLISH|wc -l  
查出服务器是否受到DOS攻击 （看SYN\_RECV）  
netstat -an |awk '{print $6}'|sort|uniq -c|sort -rn  
   5116 TIME\_WAIT  
   1624 ESTABLISHED  
    531 FIN\_WAIT1  
    512 FIN\_WAIT2  
    126 SYN\_RECV  
     10 CLOSING  
      9 LISTEN

查出服务器异常IP链接  
netstat -an | awk '{print $5}' | cut -d":" -f1 | sort | uniq -c | sort -rn | head