[root@rhel5 ~]# ll /proc total 0 dr-xr-xr-x 5 root root 0 Feb 8 17:08 1 dr-xr-xr-x 5 root root 0 Feb 8 17:08 10 dr-xr-xr-x 5 root root 0 Feb 8 17:08 11 dr-xr-xr-x 5 root root 0 Feb 8 17:08 1156 dr-xr-xr-x 5 root root 0 Feb 8 17:08 139 dr-xr-xr-x 5 root root 0 Feb 8 17:08 140 dr-xr-xr-x 5 root root 0 Feb 8 17:08 141 dr-xr-xr-x 5 root root 0 Feb 8 17:09 1417 dr-xr-xr-x 5 root root 0 Feb 8 17:09 1418 |
[root@rhel5 ~]# ll /proc/2674 total 0 dr-xr-xr-x 2 root root 0 Feb 8 17:15 attr -r-------- 1 root root 0 Feb 8 17:14 auxv -r--r--r-- 1 root root 0 Feb 8 17:09 cmdline -rw-r--r-- 1 root root 0 Feb 8 17:14 coredump_filter -r--r--r-- 1 root root 0 Feb 8 17:14 cpuset lrwxrwxrwx 1 root root 0 Feb 8 17:14 cwd -> /var/run/saslauthd -r-------- 1 root root 0 Feb 8 17:14 environ lrwxrwxrwx 1 root root 0 Feb 8 17:09 exe -> /usr/sbin/saslauthd dr-x------ 2 root root 0 Feb 8 17:15 fd -r-------- 1 root root 0 Feb 8 17:14 limits -rw-r--r-- 1 root root 0 Feb 8 17:14 loginuid -r--r--r-- 1 root root 0 Feb 8 17:14 maps -rw------- 1 root root 0 Feb 8 17:14 mem -r--r--r-- 1 root root 0 Feb 8 17:14 mounts -r-------- 1 root root 0 Feb 8 17:14 mountstats -rw-r--r-- 1 root root 0 Feb 8 17:14 oom_adj -r--r--r-- 1 root root 0 Feb 8 17:14 oom_score lrwxrwxrwx 1 root root 0 Feb 8 17:14 root -> / -r--r--r-- 1 root root 0 Feb 8 17:14 schedstat -r-------- 1 root root 0 Feb 8 17:14 smaps -r--r--r-- 1 root root 0 Feb 8 17:09 stat -r--r--r-- 1 root root 0 Feb 8 17:14 statm -r--r--r-- 1 root root 0 Feb 8 17:10 status dr-xr-xr-x 3 root root 0 Feb 8 17:15 task -r--r--r-- 1 root root 0 Feb 8 17:14 wchan |
[root@rhel5 ~]# more /proc/2674/cmdline /usr/sbin/saslauthd |
[root@rhel5 ~]# more /proc/2674/environ TERM=linuxauthd |
[root@rhel5 ~]# ll /proc/2674/fd total 0 lrwx------ 1 root root 64 Feb 8 17:17 0 -> /dev/null lrwx------ 1 root root 64 Feb 8 17:17 1 -> /dev/null lrwx------ 1 root root 64 Feb 8 17:17 2 -> /dev/null lrwx------ 1 root root 64 Feb 8 17:17 3 -> socket:[7990] lrwx------ 1 root root 64 Feb 8 17:17 4 -> /var/run/saslauthd/saslauthd.pid lrwx------ 1 root root 64 Feb 8 17:17 5 -> socket:[7991] lrwx------ 1 root root 64 Feb 8 17:17 6 -> /var/run/saslauthd/mux.accept |
[root@rhel5 ~]# cat /proc/2674/maps 00110000-00239000 r-xp 00000000 08:02 130647 /lib/libcrypto.so.0.9.8e 00239000-0024c000 rwxp 00129000 08:02 130647 /lib/libcrypto.so.0.9.8e 0024c000-00250000 rwxp 0024c000 00:00 0 00250000-00252000 r-xp 00000000 08:02 130462 /lib/libdl-2.5.so 00252000-00253000 r-xp 00001000 08:02 130462 /lib/libdl-2.5.so |
[root@rhel5 ~]# more /proc/2674/status Name: saslauthd State: S (sleeping) SleepAVG: 0% Tgid: 2674 Pid: 2674 PPid: 1 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 32 Groups: VmPeak: 5576 kB VmSize: 5572 kB VmLck: 0 kB VmHWM: 696 kB VmRSS: 696 kB ………… |
[root@rhel5 ~]# more /proc/cmdline ro root=/dev/VolGroup00/LogVol00 rhgb quiet |
[root@rhel5 ~]# more /proc/crypto name : crc32c driver : crc32c-generic module : kernel priority : 0 type : digest blocksize : 32 digestsize : 4 ………… |
[root@rhel5 ~]# more /proc/devices Character devices: 1 mem 4 /dev/vc/0 4 tty 4 ttyS ………… Block devices: 1 ramdisk 2 fd 8 sd ………… |
[root@rhel5 ~]# more /proc/dma 2: floppy 4: cascade |
[root@rhel5 ~]# more /proc/execdomains 0-0 Linux [kernel] |
[root@rhel5 ~]# more /proc/filesystems nodev sysfs nodev rootfs nodev proc iso9660 ext3 ………… ………… |
[root@rhel5 ~]# more /proc/interrupts CPU0 0: 1305421 IO-APIC-edge timer 1: 61 IO-APIC-edge i8042 185: 1068 IO-APIC-level eth0 ………… |
[root@rhel5 ~]# more /proc/iomem 00000000-0009f7ff : System RAM 0009f800-0009ffff : reserved 000a0000-000bffff : Video RAM area 000c0000-000c7fff : Video ROM ………… |
/proc/iomem
This file shows you the current map of the system's memory for each physical device:
00000000-0009fbff : System RAM 0009fc00-0009ffff : reserved 000a0000-000bffff : Video RAM area 000c0000-000c7fff : Video ROM 000f0000-000fffff : System ROM 00100000-07ffffff : System RAM 00100000-00291ba8 : Kernel code 00291ba9-002e09cb : Kernel data e0000000-e3ffffff : VIA Technologies, Inc. VT82C597 [Apollo VP3] e4000000-e7ffffff : PCI Bus #01 e4000000-e4003fff : Matrox Graphics, Inc. MGA G200 AGP e5000000-e57fffff : Matrox Graphics, Inc. MGA G200 AGP e8000000-e8ffffff : PCI Bus #01 e8000000-e8ffffff : Matrox Graphics, Inc. MGA G200 AGP ea000000-ea00007f : Digital Equipment Corporation DECchip 21140 [FasterNet] ea000000-ea00007f : tulip ffff0000-ffffffff : reserved
The first column displays the memory registers used by each of the different types of memory. The second column lists the kind of memory located within those registers and displays which memory registers are used by the kernel within the system RAM or, if the network interface card has multiple Ethernet ports, the memory registers assigned for each port.
/opt/qtmarvell/mvqt # cat /proc/iomem
00000000-0fffffff : System RAM
0002b000-00554fff : Kernel text
00556000-005a22f3 : Kernel data
10000000-1fffffff : System RAM
e0000000-e7ffffff : PEX0 Memory
e0000000-e0003fff : 0000:00:01.0
e0004000-e0004fff : 0000:00:01.0
e8000000-efffffff : PEX1 Memory
f1012100-f10121ff : serial8250.0
f1012100-f101211f : serial
f1090000-f10903ff : mvsdio
f1090000-f10903ff : mvsdio
f10a0000-f10a3fff : mv88fx_snd.0
f10a0000-f10a3fff : mv88fx_snd
f10c0000-f10d0000 : dovefb.0 寄存器地址映射到这个
f10c0000-f10d0000 : dovefb_ovly.0
/opt/qtmarvell/mvqt # ./framebuffer
The framebuffer device was opened successfully.
Fixed screen info:
id: GFX Layer 0
smem_start: 0x12000000
smem_len: 33554432
type: 0
type_aux: 0
visual: 2
xpanstep: 1
ypanstep: 1
ywrapstep: 0
line_length: 2560
mmio_start: 0xf10c0000
mmio_len: 65537
[root@rhel5 ~]# less /proc/ioports 0000-001f : dma1 0020-0021 : pic1 0040-0043 : timer0 0050-0053 : timer1 0060-006f : keyboard ………… |
[root@rhel5 ~]# more /proc/kallsyms c04011f0 T _stext c04011f0 t run_init_process c04011f0 T stext ………… |
[root@rhel5 ~]# more /proc/loadavg 0.45 0.12 0.04 4/125 5549 [root@rhel5 ~]# uptime 06:00:54 up 1:06, 3 users, load average: 0.45, 0.12, 0.04 |
[root@rhel5 ~]# more /proc/locks 1: POSIX ADVISORY WRITE 4904 fd:00:4325393 0 EOF 2: POSIX ADVISORY WRITE 4550 fd:00:2066539 0 EOF 3: FLOCK ADVISORY WRITE 4497 fd:00:2066533 0 EOF |
[root@rhel5 ~]# less /proc/mdstat Personalities : unused devices: <none> |
[root@rhel5 ~]# less /proc/meminfo MemTotal: 515492 kB MemFree: 8452 kB Buffers: 19724 kB Cached: 376400 kB SwapCached: 4 kB ………… |
[root@rhel5 ~]# ll /proc |grep mounts lrwxrwxrwx 1 root root 11 Feb 8 06:43 mounts -> self/mounts |
[root@rhel5 ~]# more /proc/mounts rootfs / rootfs rw 0 0 /dev/root / ext3 rw,data=ordered 0 0 /dev /dev tmpfs rw 0 0 /proc /proc proc rw 0 0 /sys /sys sysfs rw 0 0 /proc/bus/usb /proc/bus/usb usbfs rw 0 0 ………… |
[root@rhel5 ~]# more /proc/modules autofs4 24517 2 - Live 0xe09f7000 hidp 23105 2 - Live 0xe0a06000 rfcomm 42457 0 - Live 0xe0ab3000 l2cap 29505 10 hidp,rfcomm, Live 0xe0aaa000 ………… |
[root@rhel5 ~]# more /proc/partitions major minor #blocks name 8 0 20971520 sda 8 1 104391 sda1 8 2 6907950 sda2 8 3 5630782 sda3 8 4 1 sda4 8 5 3582463 sda5 |
[root@rhel5 ~]# more /proc/slabinfo slabinfo - version: 2.1 # name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <ac tive_slabs> <num_slabs> <sharedavail> rpc_buffers 8 8 2048 2 1 : tunables 24 12 8 : slabdata 4 4 0 rpc_tasks 8 20 192 20 1 : tunables 120 60 8 : slabdata 1 1 0 rpc_inode_cache 6 9 448 9 1 : tunables 54 27 8 : slabdata 1 1 0 ………… ………… ………… |
[root@rhel5 ~]# more /proc/stat cpu 2751 26 5771 266413 2555 99 411 0 cpu0 2751 26 5771 266413 2555 99 411 0 intr 2810179 2780489 67 0 3 3 0 5 0 1 0 0 0 1707 0 0 9620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5504 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12781 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ctxt 427300 btime 1234084100 processes 3491 procs_running 1 procs_blocked 0 |
[root@rhel5 ~]# more /proc/swaps Filename Type Size Used Priority /dev/sda8 partition 642560 0 -1 |
[root@rhel5 ~]# more /proc/uptime 3809.86 3714.13 |
[root@rhel5 ~]# more /proc/version Linux version 2.6.18-128.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) #1 SMP Wed Dec 17 11:42:39 EST 2008 |
[root@rhel5 ~]# more /proc/vmstat nr_anon_pages 22270 nr_mapped 8542 nr_file_pages 47706 nr_slab 4720 nr_page_table_pages 897 nr_dirty 21 nr_writeback 0 ………… |
[root@rhel5 ~]# more /proc/zoneinfo Node 0, zone DMA pages free 1208 min 28 low 35 high 42 active 439 inactive 1139 scanned 0 (a: 7 i: 30) spanned 4096 present 4096 nr_anon_pages 192 nr_mapped 141 nr_file_pages 1385 nr_slab 253 nr_page_table_pages 2 nr_dirty 523 nr_writeback 0 nr_unstable 0 nr_bounce 0 protection: (0, 0, 296, 296) pagesets all_unreclaimable: 0 prev_priority: 12 start_pfn: 0 ………… |
1、从/proc文件系统获取相关的性能参数
cpu使用率:/proc/stat
内存使用情况: /proc/meminfo
网络负载信息:/proc/net/dev
相应的计算方法:(摘自:什么是proc文件系统)
(1) 处理器使用率
(2) 内存使用率
(3) 流入流出数据包
(4) 整体网络负载
这些数据分别要从/proc/stat、/proc/net/dev、/proc/meminfo三个文件中提取。如里有问题或对要提取的数据不太清楚,可以使用man proc来查看proc文件系统的联机手册。
(1) 处理器使用率
这里要从/proc/stat中提取四个数据:用户模式(user)、低优先级的用户模式(nice)、内核模式(system)以及空闲的处理器时间(idle)。它们均位于/proc/stat文件的第一行。CPU的利用率使用如下公式来计算。
CPU利用率 = 100 *(user + nice + system)/(user + nice + system + idle)
(2) 内存使用率
这里需要从/proc/meminfo文件中提取两个数据,当前内存的使用量(cmem)以及内存总量(amem)。
内存使用百分比 = 100 * (cmem / umem)
(3)网络利用率
为了得到网络利用率的相关数据,需要从/proc/net/dev文件中获得两个数据:从本机输出的数据包数,流入本机的数据包数。它们都位于这个文件的第四行。
性能收集程序开始记录下这两个数据的初始值,以后每次获得这个值后均减去这个初始值即为从集群启动开始从本节点通过的数据包。
利用上述数据计算出网络的平均负载,方法如下:
平均网络负载 = (输出的数据包+流入的数据包) / 2
2. 通过/proc文件系统调整相关的内核配置
允许ip转发 /proc/sys/net/ipv4/ip_forward
禁止ping/proc/sys/net/ipv4/icmp_echo_ignore_all
可以在命令行下直接往上述两个“文件”里头写入"1"来实现相关配置,如果写入"0"将取消相关配置。不过在系统重启以后,这些配置将恢复默认设置,所以,如果想让这些修改生效,可以把下面的配置直接写入/etc/profile文件,或者其他随系统启动而执行的程序文件中。
- echo 1 > /proc/sys/net/ipv4/ip_forward
- echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
如果需要获取其他的性能参数,或者需要对内核进行更多的配置,可以参考proc文件系统介绍,也可以直接通过man proc查看相关的信息。