Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2395832
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类:

2011-03-15 16:06:16



关键字:df mount uname ifconfig netstat dmesg free top

  df -ah  看磁盘利用率
[root@nm socket]# df -ah
Filesystem 
           Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      1.6G  1.1G  410M  74% /
usbfs                           /proc/bus/usb
/dev/hda1              99M  9.0M   85M  10% /boot

  mount  看当前mount状态
[root@nm socket]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/hda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)


   cat /proc/diskstats     看当前磁盘的状态
[root@vm macg]# cat /proc/diskstats
     0 ram0 0 0 0 0 0 0 0 0 0 0 0
     1 ram1 0 0 0 0 0 0 0 0 0 0 0
     2 ram2 0 0 0 0 0 0 0 0 0 0 0
。。。
     0 hda 12812 4809 186746 126266 2528 6413 71382 235278 0 125170 361551
             
     1 hda1 692 1392 27 54                                            
     2 hda2 16792 184258 8916 71328                               
         

  22    0 hdc 11 61 576 155 0 0 0 0 0 146 155                      
 253    0 dm-0 16527 0 183370 166325 8916 0 71328 663415 0 124665 829737
 253    1 dm-1 45 0 360 160 0 0 0 0 0 37 160
     0 fd0 0 0 0 0 0 0 0 0 0 0 0

     0 md0 0 0 0 0 0 0 0 0 0 0 0   


  cat /proc/filesystems              当前所支持的文件系统
 [root@vm macg]# cat /proc/filesystems

nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   sockfs
nodev   binfmt_misc
nodev   usbfs
nodev   usbdevfs
nodev   futexfs
nodev   tmpfs
nodev   pipefs
nodev   eventpollfs
nodev   devpts
        ext2
nodev   ramfs
nodev   hugetlbfs
        iso9660
nodev   relayfs
nodev   mqueue
        ext3
nodev   rpc_pipefs
nodev   autofs
         

    solaris 下,format 看硬盘
  ·   format/partition/print  看slice
  ·   format/fdisk   如果是x86系统,看dos/win分区


   solaris   的  iostat –nE  看光驱CDROM
-E  : 错误
因为无盘的光驱,系统认为是错误的。所以系统会将光驱当错误设备显示出来
-n :  按cxtxdx形式显示
[macg@machome]:/export/home/macg>$iostat -nE
c0t1d0           Soft Errors: 1 Hard Errors: 0 Transport Errors: 0
Vendor: BENQ     Product: DVD DD DW1640    Revision: BSLB Serial No: 
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 1 Predictive Failure Analysis:



    cat /proc/cpuinfo
注意/proc/cpuinfo是按“核”显示,双核双CPU,显示为4个CPU
[root@localhost ~]# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 6
model name      : Intel(R) Xeon(TM) CPU 2.66GHz
stepping        : 4
cpu MHz         : 1992.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2


processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 6
model name      : Intel(R) Xeon(TM) CPU 2.66GHz
stepping        : 4
cpu MHz         : 1992.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2


processor       : 2
vendor_id       : GenuineIntel
cpu family      : 15
model           : 6
model name      : Intel(R) Xeon(TM) CPU 2.66GHz
stepping        : 4
cpu MHz         : 1992.000
cache size      : 2048 KB
physical id     : 1
siblings        : 2
core id         : 0
cpu cores       : 2


processor       : 3
vendor_id       : GenuineIntel
cpu family      : 15
model           : 6
model name      : Intel(R) Xeon(TM) CPU 2.66GHz
stepping        : 4
cpu MHz         : 1992.000
cache size      : 2048 KB
physical id     : 1
siblings        : 2
core id         : 1
cpu cores       : 2



   top, 动态监测系统CPU,内存,SWAP利用率和进程
[root@vm macg]# top
top - 11:11:01 up 25 min 1 user load average: 0.00, 0.01, 0.11
Tasks:  50 total,   1 running,  49 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0% us 2.6% sy,  0.0% ni, 97.4% id,  0.0% wa,  0.0% hi,  0.0% si
Mem:    158540k total,   130508k used,    28032k free   66672k buffers
Swap:   327672k total,        0k used,   327672k free,    32272k cached
以下是CPU利用率和MEME利用率从高到低排列的进程
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  
3769 root      16   3008  932  760 R  1.3  0.6   0:00.26 top
3712 root      16   1900  736  600 S  1.0  0.5   0:00.41 in.telnetd
 311 root      16          0 S  0.3  0.0   0:01.57 kjournald 
3769 root      16   3008  932  760 R  1.3  0.6   0:00.26 top  
3712 root      16   1900  736  600 S  1.0  0.5   0:00.41 in.telnetd 
 311 root      16          0 S  0.3  0.0   0:01.57
注意这个命令的输出是动态刷新的,大概5秒种刷新一次
 必须ctrl-c结束

    mpstat –P cpunum  看某一个CPU的运行状况、利用率
[root@ntracker test]# mpstat -P 0
Linux 2.6.9-42.ELsmp (ntracker)         07/13/2007

02:25:47 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
02:25:47 PM      0.81    0.08    0.37    1.38    0.00    0.00   97.35    513.23

[root@ntracker test]# mpstat -P 1
Linux 2.6.9-42.ELsmp (ntracker)         07/13/2007

02:25:49 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
02:25:49 PM      0.94    0.09    0.16    1.18    0.00    0.00   97.62    500.92

[root@ntracker test]# mpstat  不跟参数,是看所有CPU的状况
Linux 2.6.9-42.ELsmp (ntracker)         07/13/2007

02:26:13 PM  CPU   %user   %nice %system %iowait    %irq   %soft   %idle    intr/s
02:26:13 PM  all    0.87    0.08    0.26    1.28    0.00    0.00   97.50   1014.29

    sar –P  cpunum     同mpstat -P非常类似
[root@ test]# sar -P 0
Linux 2.6.9-42.ELsmp (ntracker)         07/13/2007

12:49:34 PM       LINUX RESTART

12:50:03 PM       CPU     %user     %nice   %system   %iowait     %idle
01:00:01 PM             1.60      0.00      0.26      0.69     97.45
01:10:01 PM             0.29      0.00      0.02      0.18     99.50
01:20:01 PM             0.02      0.00      0.01      0.00     99.97
01:30:01 PM             0.88      0.00      0.32      0.06     98.73
01:40:01 PM             1.55      0.00      0.67      0.11     97.67
01:50:02 PM             1.30      0.00      0.70      0.05     97.95
02:00:01 PM             0.73      0.79      0.53      0.65     97.31
02:10:01 PM             0.14      0.00      0.03      0.05     99.78
Average:                0.82      0.10      0.32      0.22     98.55
[root@ntracker test]# sar -P 1
Linux 2.6.9-42.ELsmp (ntracker)         07/13/2007

12:49:34 PM       LINUX RESTART

12:50:03 PM       CPU     %user     %nice   %system   %iowait     %idle
01:00:01 PM             1.58      0.00      0.24      0.99     97.18
01:10:01 PM             0.30      0.00      0.04      0.29     99.37
01:20:01 PM             0.09      0.00      0.01      0.05     99.85
01:30:01 PM             0.64      0.00      0.10      0.06     99.19
01:40:01 PM             2.50      0.00      0.10      0.08     97.33
01:50:02 PM             1.91      0.00      0.05      0.02     98.03
02:00:01 PM             1.06      0.86      0.20      0.57     97.31
02:10:01 PM             0.09      0.00      0.05      0.03     99.84
Average:                1.02      0.11      0.10      0.26     98.51


    ps -eo pid,pcpu,args 精简显示进程的cpu(pcpu)使用      
[root@mm guan]# ps -eo pid,pcpu,args |sort +1n
 3152  0.0 /sbin/mingetty tty5
 3153  0.0 /sbin/mingetty tty6
 3427  0.0 /usr/local/sbin/bgpd --daemon -f /etc/bgpd.conf
    0.0 [khelper]
   41  0.0 [pdflush]
   44  0.0 [aio/0]
 5003  0.0 cupsd
    0.0 [kacpid]



   solaris 下 ,   isainfo 查看系统的32位或64位内核
# isainfo –b
64

# isainfo –v
64-bit sparcv9 applications
32-bit sparc applications

# isainfo -v
32-bit i386 applications
        mmx cmov sep cx8 tsc fpu


    solaris 下, psrinfo -v看CPU和虚处理器(内核)
# /usr/sbin/psrinfo -v
Status of virtual processor 0 as of: 04/11/2007 13:37:42
  on-line since 04/11/2007 11:44:13.
  The i386 processor operates at 466 MHz
        and has an i387 compatible floating point processor.


    cat /proc/meminfo        看系统内存状况
[root@vm macg]# cat /proc/meminfo
MemTotal:       158540 kB             
MemFree:         28176 kB             
Buffers:         66672 kB
Cached:          32272 kB
SwapCached:          0 kB
Active:          50628 kB
Inactive:        58032 kB
HighTotal:           0 kB
LowFree:         28176 kB
SwapTotal:      327672 kB
SwapFree:       327672 kB


      solaris 下,prtconf看内存
# /usr/sbin/prtconf
System Configuration:  Sun Microsystems  i86pc
Memory size: 191 Megabytes
System Peripherals (Software Nodes):

prtconf –v


  ps -eo pid,vsz,args精简显示进程的内存(vsz)使用
[root@mm guan]# ps -eo pid,vsz,args | sort +1n
  190     0 [kseriod]
 1904     0 [kauditd]
 1951     0 [kjournald]
   44     0 [aio/0]
       0 [kacpid]
  PID   VSZ COMMAND
 3153  1916 /sbin/mingetty tty6
 1393  2000 udevd
 2799  2112 klogd -x
 2986  2160 /usr/sbin/acpid
 2977  3200 /usr/sbin/smartd
 3031  3244 xinetd -stayalive -pidfi
   

    free 看当前内存和SWAP的利用情况,free不看CPU
[root@nm mac]# free
           total        used       free     shared    buffers     cached
Mem:        158540      34392     124148               3328      15468
-/+ buffers/cache:      15596     142944
Swap:       262136             262136


    ifconfig –a  看当前接口配置

    netstat -i看接口状态
[root@ntracker proc]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500      1412                  681              0 BMU
eth1       1500     13786                 6001              0 BMRU
lo        16436    291861               291861              0 LRU

   cat /proc/net/dev 和netstat –i差不多
[root@ntracker ~]# cat /proc/net/dev
Inter-|   Receive                               Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
   lo:35145529  291803      0 35145529  291803              0
  eth0:  189041    1412       93825     681           0     0
  eth1: 6483284   13251     1752138    5814           0     0
  sit0:                                     

  netstat –nr   看路由表

  netstat –an  看当前TCP,UDP listen端口的状况

  lsof -i  ——类似 netstat -an 只看当前的listen和establisht
[root@nm mac]# /usr/sbin/lsof -i
COMMAND    PID USER   FD   TYPE DEVICE SIZE NODE NAME
sshd      2662 root    3u  IPv6   5848       TCP *:ssh (LISTEN)
xinetd    2672 root    5u  IPv4   5912       TCP *:ftp (LISTEN)
xinetd    2672 root    6u  IPv4   5913       TCP *:telnet (LISTEN)
xinetd    2672 root    8u  IPv4   5914       UDP *:tftp
in.telnet 3204 root    0u  IPv4   7054       TCP 10.4.3.117:telnet->huitong-nko3iq0:4836 (ESTABLISHED)
in.telnet 3204 root    1u  IPv4   7054       TCP 10.4.3.117:telnet->huitong-nko3iq0:4836 (ESTABLISHED)
in.telnet 3204 root    2u  IPv4   7054       TCP 10.4.3.117:telnet->huitong-nko3iq0:4836 (ESTABLISHED)
 
    cat  /proc/net/sockstat     看当前socket
[root@ntracker ~]# cat /proc/net/sockstat
sockets: used 65
TCP: inuse 5 orphan 0 tw 0 alloc 13 mem 2
UDP: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0


    看dmesg启动信息是了解系统最直接的途径
但内容很多,要粘帖下来慢慢看
[root@localhost dev]# dmesg
Linux version 2.6.11-1.1369_FC4 (bhcompile@decompose.build.redhat.com) (gcc version 4.0.0 20050525 (Red Hat 4.0.0-9)) #1 Thu Jun 2 22:55:56 EDT 2005
0MB HIGHMEM available.
190MB LOWMEM available.

Kernel command line: ro root=LABEL=/ rhgb quiet
Initializing CPU#0
Detected 467.859 MHz processor.

Console: colour VGA+ 80x25
Memory: 188460k/195520k available (2518k kernel code, 6508k reserved, 690k data, 180k init, 0k highmem)

Security Framework v1.0.0 initialized
SELinux:  Initializing.
SELinux:  Starting in permissive mode

CPU: Intel Celeron (Mendocino) stepping 05

Linux Plug and Play Support v0.97 (c) Adam Belay
pnp: PnP ACPI: disabled
usbcore: registered new driver usbfs
usbcore: registered new driver hub


Probing IDE interface ide0...
hda: ST3802110A, ATA DISK drive
hdb: BENQ DVD DD DW1640, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Probing IDE interface ide1...
Probing IDE interface ide1...
hda: max request size: 1024KiB
hda: 156301488 sectors (80026 MB) w/2048KiB Cache, CHS=16383/255/63, UDMA(66)
hda: cache flushes supported
 hda: hda1 hda2 hda3 < hda5 hda6 > hda4
 hda4:
hdb: ATAPI 48X DVD-ROM DVD-R CD-R/RW drive, 2048kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.20

input: AT Translated Set 2 keyboard on isa0060/serio0
input: PS/2 Generic Mouse on isa0060/serio1

security:  3 users, 6 roles, 764 types, 87 bools
security:  55 classes, 180131 rules
SELinux:  Completing initialization.

e100: Intel(R) PRO/100 Network Driver, 3.3.6-k2-NAPI
e100: Copyright(c) 1999-2004 Intel Corporation
e100: eth0: e100_probe: addr 0xe6000000, irq 5, MAC addr 00:90:27:10:D7:50


    看系统log
/var/adm/messages


   查当前登陆user            w 比who更详细些
# who  当前登陆的
macg       pts/1        12月  7日 15:00 (192.168.1.11)
kkk        pts/2        12月  7日 15:53 (192.168.1.11)

$ w
 01:06:13 up 13:27,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
macg     pts/2    192.168.1.11     00:57    0.00s  0.12s  0.02s w

last最管用,但列得也过多,所有登陆过的都列出
# last
kkk       pts/2       192.168.1.11     Thu Dec  7 15:53 仍在登录状态
macg      pts/2       192.168.1.11     Thu Dec  7 15:52 - 15:53  (00:01)
macg      pts/1       192.168.1.11     Thu Dec  7 15:00 仍在登录状态
macg      console                      Thu Dec  7 12:59 - 13:00  (00:01)
root      console                      Thu Dec  7 12:59 - 12:59  (00:00)
root      console                      Thu Dec  7 12:55 - 12:58  (00:02)
reboot    system boot                  Thu Dec  7 12:18
reboot    system down                  Thu Dec  7 03:58
root      console                      Thu Dec  7 03:53 - 03:53  (00:00)
reboot    system boot                  Thu Dec  7 03:52
reboot    system down                  Thu Dec  7 03:51
看到solaris系统开关机的用户


   uname –a        收集OS信息
$ uname -a
SunOS sxuno        5.8 Generic_108528-24 sun4u sparc SUNW,Ultra-Enterprise


   SPARC:prtdiag -v 显示系统诊断信息


 
转载自:http://blog.sina.com.cn/s/blog_6151984a0100eipy.html


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