Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1509406
  • 博文数量: 228
  • 博客积分: 1698
  • 博客等级: 上尉
  • 技术积分: 3241
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-24 21:49
个人简介

Linux

文章分类

全部博文(228)

文章存档

2017年(1)

2016年(43)

2015年(102)

2014年(44)

2013年(5)

2012年(30)

2011年(3)

分类: LINUX

2016-11-29 23:32:11

转自:http://blog.yufeng.info/archives/1280

systemtap发行版本提供了个工具socktop, 位于 /usr/share/doc/systemtap/examples/network/socktop, 可以查看unix域套接字的发送和接受情况,比如说A程序是否送出,B程序是否接收到。

点击(此处)折叠或打开

  1. # Socktop systemtap script
  2. # Copyright (C) 2006 IBM Corp.
  3. #
  4. # This file is part of systemtap, and is free software. You can
  5. # redistribute it and/or modify it under the terms of the GNU General
  6. # Public License (GPL); either version 2, or (at your option) any
  7. # later version.

  8. ###
  9. ### socktop – Combination shell/systemtap script to track reads and writes
  10. ### on sockets by process. Can be filtered by process IDs and
  11. ### names, protocols, protocol families, users and socket type.
  12. ###

  13. $ uname -r
  14. 2.6.18-164.el5
  15.  
  16. $ rpm -i kernel-debuginfo-common-2.6.18-164.el5.x86_64.rpm
  17. $ rpm -i kernel-debuginfo-2.6.18-164.el5.x86_64.rpm
  18.  
  19. #使用帮助
  20. $ /usr/share/doc/systemtap/examples/network/socktop -h
  21. USAGE: socktop [-d] [-i interval] [-N num] [-P protocol]... [-f family]...
  22.                [-t stype]... [-n pname]... [-p pid]... [-u username]... [-h]
  23.     -d # print network device traffic (default: off)
  24.     -i interval # interval in seconds between printing (default: 5)
  25.     -N num # number of top processes and devices to print (default: 10)
  26.     -f family # this protocol family only (default: all)
  27.     -P protocol # this protocol only (default: all)
  28.     -t stype # this socket type only (default: all)
  29.     -n pname # this process name only (default: all)
  30.     -p pid # this process ID only (default: all)
  31.     -u username # this user only (default: all)
  32.     -c count # number of iteration
  33.     -m mod_name # generate instrumentation (but do not run)
  34.     -h # print this help text
  35.  
  36. Protocol Families:
  37.     LOCAL, INET, INET6, IPX, NETLINK, X25, AX25, ATMPVC, APPLETALK, PACKET
  38.  
  39. Protocols:
  40.     TCP, UDP, SCTP, IP, FC, ... (see /etc/protocols for complete list)
  41.  
  42. Socket Types:
  43.     STREAM, DGRAM, RAW, RDM, SEQPACKET, DCCP, PACKET
  44. 上面的使用写的很明白了,我们要过滤的是unix套接字, 每5秒报告下情况, 还顺手把网络设备的流量打出来。

  45. view sourceprint?
  46. $sudo /usr/share/doc/systemtap/examples/network/socktop -f LOCAL -i 5 -d
  47. ======================= Thu Mar 31 21:23:03 2011 ========================
  48. ------------------------------- PROCESSES -------------------------------
  49. PID UID #SEND #RECV SEND_KB RECV_KB PROT FAMILY COMMAND
  50. 24821 50453 1 0 0 0 IP LOCAL crond
  51. 3840 0 0 2 0 0 IP LOCAL syslog-ng
  52.  
  53. -------------------------------- DEVICES --------------------------------
  54. DEV #XMIT #RECV XMIT_KB RECV_KB
  55. eth0 457 250 102 38
  56. bond0 457 0 102 0
  57. lo 24 24 2 2
  58. eth1 0 10 0 0
  59. =========================================================================
  60. 我们很清楚的看到了,crond在发,syslog-ng在收。

阅读(5125) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~