工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.51099.com 注册 | 登陆
浏览模式: 标准 | 列表2009年09月的文章

systat命令监测网络流量

systat命令监测网络流量

使用方法为:
systat -if 3

http://pagesperso-orange.fr/sebastien.godard/download.html

iftop 流量监测

iftop

iftop 官方网站:
http://www.ex-parrot.com/~pdw/iftop/

安装iftop,,必须先安装libpcap
http://www.tcpdump.org/release/

wget http://www.tcpdump.org/release/libpcap-0.9.8.tar.gz
tar -zxvf libpcap-0.9.8.tar.gz

cd libpcap-0.9.8
./configure
make;make install

pcap安装完成,再来安装iftop
wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz
tar zxvf iftop-0.17.tar.gz
cd iftop-0.17
./configure
make;make install


[root@localhost libpcap-1.0.0]# make
gcc -O2 -fPIC -I.  -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -c ./pcap-linux.c
gcc -O2 -fPIC -I.  -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -c ./pcap-usb-linux.c
gcc -O2 -fPIC -I.  -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -c ./fad-getad.c
In file included from ./fad-getad.c:67:
/usr/include/linux/if_packet.h:52: error: expected specifier-qualifier-list before '__u32'
make: *** [fad-getad.o] Error 1

A:

#include <linux/types.h>
加入到
/usr/include/linux/if_packet.h
的最顶端.

ifstat流量监测

http://gael.roualland.free.fr/ifstat/

http://gael.roualland.free.fr/ifstat/ifstat-1.1.tar.gz
  tar xzvf ifstat-1.1.tar.gz
  cd ifstat-1.1
  ./configure
  make
  make install
然后 man ifstat
-t 显示时间 格式:HH:MM:SS   
-i 指定的网卡 ,如果有多块网卡 以","分隔
-T 显示所有接口的带宽.
# ifstat -t -i eth0 -T   

Linux查看CPU信息 转

Linux下如何查看CPU信息, 包括位数和多核信息
# uname -a
Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
(查看当前操作系统内核信息)
# cat /etc/issue | grep Linux
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
(查看当前操作系统发行版信息)
# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      8  Intel(R) Xeon(R) CPU            E5410   @ 2.33GHz
(看到有8个逻辑CPU, 也知道了CPU型号)
# cat /proc/cpuinfo | grep physical | uniq -c
      4 physical id      : 0
      4 physical id      : 1
(说明实际上是两颗4核的CPU)
# getconf LONG_BIT
32
(说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit)
# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
8
(结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit)
最后再完整看cpu物理信息, 不过大部分我们都不关心而已.
# dmidecode | grep -A48 'Processor Information$'

SHELL参数介绍

如同ls 命令可以接受目录等作为它的参数一样,在shell编程时同样可以使用参数。Shell有位置参数和内部参数。
  1、 位置参数
  由系统提供的参数称为位置参数。位置参数的值可以用$N得到,N是一个数字,如果为1,即$1.类似C语言中的数组,Linux会把输入的命令字符串分段并给每段进行标号,标号从0开始。第0号为程序名字,从1开始就表示传递给程序的参数。如$0表示程序的名字,$1表示传递给程序的第一个参数,以此类推。
  2、 内部参数
  上述过程中的$0是一个内部变量,它是必须的,而$1则可有可无。和$0一样的内部变量还有以下几个。
  $# ----传递给程序的总的参数数目
  $? ----上一个代码或者shell程序在shell中退出的情况,如果正常退出则返回0,反之为非0值。
  $* ----传递给程序的所有参数组成的字符串。
      $n ----表示第几个参数,$1 表示第一个参数,$2 表示第二个参数 ... 
      $0 ----当前程序的名称
      $@----以"参数1" "参数2" ... 形式保存所有参数
      $$ ----本程序的(进程ID号)PID
      $!  ----上一个命令的PID