首页 > 系统服务 > 详细

linux下定时监控tcp连接数的方法和步骤

时间:2017-02-28 15:29:43      阅读:320      评论:0      收藏:0      [点我收藏+]

1. 编写监控脚本 tcp_statistics.sh
echo `date +"%F %H:%M:%S"` "TCP-ALL" `netstat -anotp |awk ‘/tcp/ {print $6}‘|wc -l` >> tcp_count.txt
echo `date +"%F %H:%M:%S"` "TCP-LISTEN" `netstat -anotp|grep "LISTEN" |wc -l` >>tcp_count.txt
echo `date +"%F %H:%M:%S"` "TCP-ESTABLISHED" `netstat -anotp | grep "ESTABLISHED" |wc -l ` >> tcp_count.txt
echo `date +"%F %H:%M:%S"` "TCP_TIME_WAIT" `netstat -anotp |grep "TIME_WAIT" |wc -l  ` >> tcp_count.txt
echo `date +"%F %H:%M:%S"` "TCP_CLOSE_WAIT" `netstat -anotp |grep "CLOSE_WAIT" |wc -l` >> tcp_count.txt

2. 更改文件权限
chmod 777 tcp_statistics.sh

3. 加入定时任务
crontab -e
*/1 * * * * sh /root/tcp_statistics.sh

3. 重启定时服务
service crond restart

linux下定时监控tcp连接数的方法和步骤

原文:http://www.cnblogs.com/wenchunl/p/6478880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!