Chinaunix首页 | 论坛 | 博客
  • 博客访问: 195836
  • 博文数量: 71
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 450
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-29 21:28
个人简介

思考人生、专注技术

文章分类

全部博文(71)

文章存档

2015年(1)

2009年(2)

2008年(11)

2007年(57)

我的朋友

分类: LINUX

2007-12-02 09:45:06

proc 文件系统
Linux 内核有二个主要功能: 当程序与硬件交互的时候(when and how processes interact with these devices),控制它们对计算机上硬件的访问。 /proc/ 目录包含表明内核当前状态层次的特殊文件------允许应用程序和使用者知道内核的状态(allowing applications and users to peer into the kernel's view of the system)。
在 /proc/目录里面,你能发现有价值的很多资讯------系统硬件和现在正在运行的任何程序。 除此之外,在 / proc/ 目录树里面的一些文件能让使用者和应用程序改变内核的配置。
虚拟的文件系统
在 Linux 下,所有的数据都被当成文件。 绝大多数的使用者熟悉二种主要的文件:文本文件和二进制文件。 但是 /proc/ 目录包含另外类型的文件,它们叫做虚拟的文件。 就因为这个理由, /proc/ 时常被称为虚拟文件系统。
这些虚拟的文件有独特的性质。他们大部份在大小方面被列成如零的位元组(Most of them are listed as zero bytes in size)然而当被察看的时候,它能包含很多的信息。 比如,大部份时间和日期设置后会立即反映出目前的时间和日期, 表明他们在不停的变动。
有些虚拟文件,例如 中断,,/proc/meminfo,/proc/mounts, 和 /proc/ 分区提供随时更新的对系统硬件的信息描述。另外, 像 / proc/ filesystems 和 /proc/sys/ 目录提供系统的配置信息和介面(interfaces)。
为了达到这个目的,包含一个相似主题的资讯的文件被放在虚拟目录和子目录之内。 举例来说, , /proc/ide/ 包含所有ide硬件的信息。 同样地,程序目录包含每一个系统上正在运行的程序的资讯。
察看虚拟的文件
在 /proc/目录里面使用 cat ,,more, 和less命令,你能立刻访问一些关於系统的大量的资讯。 举例来说,如果你想看你的计算机的CPU是什么型号的,输入 cat /proc/cpuinfo ,你将会看见与下列各项相似的东西:
processor : 0
vendor_id : AuthenticAMD
cpu family : 5
model : 9
model name : AMD-K6™ 3D+ Processor
stepping : 1
cpu MHz : 400.919
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr
bogomips : 799.53

当在 /proc/中看不同的虚拟文件的时候, 你将会注意到一些信息是可以理解的但有一些则是天书一般的。 这是那些能从虚拟文件得到数据并将其显示的程序存在的原因。 这样的应用程序例如: lspci , apm, free, 和top。

注意
一些在 / proc/ 目录中的虚拟文件只能由 root 来读。

变更虚拟文件
如同惯例,/ proc/ 目录里面的大部分虚拟文件是只读的。 然而, 一些能用来在内核中调整设置。尤其对/proc/sys/子目录中的文件。
为了要改变虚拟的文件数值,使用 echo 命令和 > 重定向文件的新数值(To change the value of a virtual file, use the echo command and a > symbol to redirect the new value to the file)。 举例来说, 要立即改变你的主机名称,你可以输入:
echo bob.subgenius.com > /proc/sys/kernel/hostname

其他的文件被当作二进制文件或 boolean 开关(Other files act as binary or boolean switches)。 举例来说,如果你键入cat /proc/sys/net/ipv4/ip_forward, 你也将会看见0 或1. 0 表示内核不再转寄网络包。使用 echo 指令改变 ip_forward 的数值为 1,你能立刻把包转寄打开(you can immediately turn packet forwarding on。)

提示
过去一直用来改变设置的/ proc/sys/ 子目录中的命令现在在/sbin/sysctl中。要得到更多的资讯关於这个指令, 参见使用 sysctl这一部分(see the Section called Using sysctl)

要得到 /proc/sys/中的可用的一些内核配置文件的清单, 请参见/proc/sys/(.see the Section called /proc/sys/.)
在 proc 文件系统中最高层次的文件
下面是 /proc/目录中最高层次的一些比较有用的虚拟文件的列表。

注意
在大部份的情形下,在这个部分中列出的文件的内容在你机器上将不会总是相同的。 这是因为很多信息取决于你正在运行红帽子 Linux 的硬件。

/proc/apm
这个文件提供关於高级电源管理 (APM) 的系统状态的资讯并且被 apm 指令使用。 如果没有电池组被连接到 AC 动力源(If the system with no battery is connected to an AC power source), 虚拟的文件看起来类似这个:
1.16 1.2 0x07 0x01 0xff 0x80-1%-1?

在这样的系统上运行 apm- v指令,会有下面的显示:
APM BIOS 1.2 (kernel driver 1.16)
AC on-line, no system battery

对于没有使用电池组的系统, apm只能让计算机处于待机状态。 apm 指令在笔记本电脑上更有用。举例来说,在正在运行红帽子 Linux的笔记本电脑上,运行cat/proc/apm指令,会有下列各项输出:
1.16 1.2 0x03 0x01 0x03 0x09 100%-1?

当这个笔记本电脑拔开它的能源长达几分钟后 ,apm 文件的内容会换成下列相似的东西:
1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min

用apm- v 指令将得到更有用的数据,例如 下列各项:
APM BIOS 1.2 (kernel driver 1.16)
AC off-line, battery status high: 99% (1 day, 5:52)

/proc/cmdline
当它启动的时候 , 这个文件将展现传给内核的叁数。 一个样本 /proc/ cmdline 文件看起来像这样:
ro root=/dev/hda2

这告诉我们内核以只读挂载------(ro)表明------在第一 IDE 设备上的第二分区(/dev/hda2)。
/proc/cpuinfo
这个虚拟的文件识别你的系统用的处理机的类型。 下列各项是输出的一个例子,你会在 /proc/cpuinfo看见:
processor : 0
vendor_id : AuthenticAMD
cpu family : 5
model : 9
model name : AMD-K6™ 3D+ Processor
stepping : 1
cpu MHz : 400.919
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr
bogomips : 799.53

processor------提供每个处理器一个识别数字。 如果你只有一个处理器, 你将只会看见 0.
cpu family—简明地告诉你你系统中有的处理器的类型。如果你的计算机是Intel系列的,在"86"之前的数值加以区分。如果你想了解老机子的信息,例如 586,486, 或 386 ,这将非常有用。因为一些 rpm 软件包是为这些特别的结构编译的,这个数值能够让你决定安装哪些软件包。
model name------告诉你处理器的通常名字, 包括它的设计(project name)名字。
CPU MHz —告诉你CPU精确的速度------以MHz为单位,精确到小数点后3位。
cache size—告诉你处理器可用的二级缓存。
Flags------定义有关处理器的许多不同的性质, 例如 浮点运算 (FPU) 和处理 MMX 指令能力(the ability to process MMX instructions)。
/proc/devices
这个文件显示正在为内核配置使用的各种不同的字符(the various character)和区块设备。 它不包括模组未被载入内核的设备。 下面是这个虚拟文件一个样本的输出:
Character devices:
1 mem
2 pty
3 ttyp
4 ttyS
5 cua
7 vcs
10 misc
14 sound
29 fb
36 netlink
128 ptm
129 ptm
136 pts
137 pts
162 raw
254 iscsictl
Block devices:
1 ramdisk
2 fd
3 ide0
9 md
22 ide1
/proc/devices的信息包括设备的主要数目和名字,并且被分为二个主要的部分: 字符设备和区块设备(Character devices and Block devices)。
字符设备与区块设备,除了二种基本不同以外,是相似的。
块状设备有一个可用的缓冲区,在处理他们之前允许他们对命令提出请求(allowing them to order requests before dealing with them) 。这对用来存储信息的设备是非常重要的-------比如硬盘------因为在写入设备之前就能够得到信息,这就比单纯的命令更有效(This is important for devices designed to store information — such as hard drives — because the ability to order the information before writing it to the device allows it to be placed in more efficient order)。字符设备不需要缓冲。
另一个不同是区块设备能在每一设备被配置的区块同样大小中送并且接受信息。 字符设备没用送数据 preconfigured 大小(The other difference is that block devices can send and receive information in blocks of a size configured per device. Character devices send data with no preconfigured size。)
要得到关於设备的更多资讯,请参看 /usr/src/linux-2.4/Documentation/devices.txt 。
/proc/dma
这个文件包含已注册的正在使用中的ISA 直接内存读取 (DMA) 通道的列表。 一个 /proc/ dma 文件看起来像这样:
4: cascade

/proc/execdomains
这个文件列出被 Linux 内核支持的运行网域(execution domains),连同他们支持的其他性质。
0-0 Linux [kernel]
想象一下,一个特别的操作系统把运行网域当做 "个性" 。 因为其他的二进制格式,例如 Solaris , UnixWare 和 FreeBSD,都能被 Linux 使用,程序设计者能改变操作方式,通过变更任务的特性来适合这些二进制的特别系统的需要。 除了 PER_LINUX 运行网域以外,不同的性质也能被实现,如被动态地载入模块。(Think of execution domains as the "personality" for a particular operating system. Because other binary formats, such as Solaris, UnixWare, and FreeBSD, can be used with Linux, programmers can change the way the operating system treats particular system calls from these binaries by changing the personality of the task. Except for the PER_LINUX execution domain, different personalities can be implemented as dynamically loadable modules)
风絮飘凌2006-5-12, 22:05 PM
[/proc/fb
这个文件包含架框缓冲区设备的列表,有架框缓冲区设备号码和控制它的驱动器。 包含架框缓冲区设备系统的/ proc/ fb,标准的输出类似这:(This file contains a list of frame buffer devices, with the frame buffer device number and the driver that controls it. Typical output of /proc/fb for systems which contain frame buffer devices looks similar to this: )
0 VESA VGA

/proc/filesystems
这个文件显示现在被内核支持的文件系统类型的列表。来自一般内核的(未被编译的)/proc/ filesystems 文件的输出类似以下:
nodev rootfs
nodev bdev
nodev proc
nodev sockfs
nodev tmpfs
nodev shm
nodev pipefs
ext2
nodev ramfs
iso9660
nodev devpts
ext3
nodev autofs
nodev binfmt_misc
第一栏表明是否文件系统被安装在一个区块设备上。 以nodev开头 的那些不被安装在一个设备上。 第二栏列出被支持的文件系统的名字。
当一个文件系统不被识别,mount命令将会在这些文件系统中循环寻找适合的方式。(The mount command cycles through these file systems when one is not specified as an argument. )
/proc/interrupts
这个文件记录了 x86 结构上的每个 IRQ( 中断请求)中断的数字。 一个标准 /proc/interrupts类似以下:
CPU0
0: 80448940 XT-PIC timer
1: 174412 XT-PIC keyboard
2: 0 XT-PIC cascade
8: 1 XT-PIC rtc
10: 410964 XT-PIC eth0
12: 60330 XT-PIC PS/2 Mouse
14: 1314121 XT-PIC ide0
15: 5195422 XT-PIC ide1
NMI: 0
ERR: 0


对於一个有多处理器的机器,这个文件可能看起来有些稍微地不同:
CPU0 CPU1
0: 1366814704 0 XT-PIC timer
1: 128 340 IO-APIC-edge keyboard
2: 0 0 XT-PIC cascade
8: 0 1 IO-APIC-edge rtc
12: 5323 5793 IO-APIC-edge PS/2 Mouse
13: 1 0 XT-PIC fpu
16: 11184294 15940594 IO-APIC-level Intel EtherExpress Pro 10/100 Ethernet
20: 8450043 11120093 IO-APIC-level megaraid
30: 10432 10722 IO-APIC-level aic7xxx
31: 23 22 IO-APIC-level aic7xxx
NMI: 0
ERR: 0

第一栏表示 IRQ 数字。 每个处理器在系统中有它的自己的栏和它的 IRQ 中断号(Each CPU in the system has its own column and its own number of interrupts per IRQ)。下个栏报告中断的类型,而且最後一栏包含使用每个 IRQ 的设备名字(The next column reports the type of interrupt, and the last column contains the name of the device that is located at that IRQ)。
在这个文件中被看到的每个中断类型, 都是特殊的, 意即有不同之处(which are architecture-specific, mean something a little different)。 对x86 的机器, 下面的数值是通用的:

XT-PIC 这是老式AT计算机的中断。
IO -APIC-edge—电压讯号从最低值到高度打断过渡,创造edge, 断续发生和只是向曾经发送讯号。 这种断续 , 和 IO-APIC- level断续, 只在 586 系列产品的处理器和更高的系统上被看到(The voltage signal on this interrupt transitions from low to high, creating an edge, where the interrupt occurs and is only signaled once. This kind of interrupt, as well as the IO-APIC-level interrupt, are only seen on systems with processors from the 586 family and higher)。
IO-APIC-level当电压讯号高到讯号再一次低下地去的时候 , 产生中断(Generates interrupts when its voltage signal goes high until the signal goes low again。)
/proc/iomem
这个文件告诉你,目前每个物理设备在系统內存的映像:
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
(00000000-0009 fbff: 系统随机存取储存器
0009fc00-0009ffff: 保留
000a0000-000bffff: 录像带随机存取储存器区域
000c0000-000c7fff: 录像带只读存储器
000f0000-000fffff: 系统只读存储器
00100000-07 ffffff: 系统随机存取储存器
00100000-00291 ba8: 内核码
00291ba9-002e09cb: 内核数据
e0000000- e3ffffff: 经由技术,公司 VT82C597
e4000000- e7ffffff: PCI 总线 #01
e4000000- e4003fff: Matrox 图形,公司 MGA G200 AGP
e5000000- e57fffff: Matrox 图形,公司 MGA G200 AGP
e8000000- e8ffffff: PCI 总线 #01
e8000000- e8ffffff: Matrox 图形,公司 MGA G200 AGP
ea000000- ea00007f: 数传设备公司 DECchip 21140[ FasterNet]
ea000000- ea00007f: tulip
ffff0000- ffffffff: 保留)

第一栏显示內存被分配成每个不同类型的內存。 第二栏告诉那些内存里面被位于的类型內存(The first column displays the memory registers used by each of the different types of memory. The second column tells the kind of memory located within those registers)。特别地,这个栏将会告诉你哪一记忆记录器被内核RAM使用或 , 如果你有多个以太网卡在你的 NIC (网络接口)上 , 內存记录器分配作为每个端口(In particular, this column will tell you which memory registers are used by the kernel within the system RAM or, if you have multiple Ethernet ports on your NIC, the memory registers assigned for each port.)。
/proc/ioports
/proc/ ioports的输出提供用与一个设备通信的输入或输出的被注册的端口区域的列表。 这个文件可能相当长, 它的开始与这相似:
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0070-007f : rtc
0080-008f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : fpu
0170-0177 : ide1
01f0-01f7 : ide0
02f8-02ff : serial(auto)
0376-0376 : ide1
03c0-03df : vga+
03f6-03f6 : ide0
03f8-03ff : serial(auto)
0cf8-0cff : PCI conf1
d000-dfff : PCI Bus #01
e000-e00f : VIA Technologies, Inc. Bus Master IDE
e000-e007 : ide0
e008-e00f : ide1
e800-e87f : Digital Equipment Corporation DECchip 21140 [FasterNet]
e800-e87f : tulip
第一栏给出了为设备保留的 IO 端口地址范围,这些设备在第二栏中列出。
/proc/isapnp
这个文件列出了在系统上的 ISA 槽中的即插即用 (PnP) 卡。 这最可能是声卡,但是也可能包括设备的任何数目(This is most often seen with sound cards but may include any number of devices)。 若有 Soundblaster ,它的 proc/ isapnp 文件类似这个:
Card 1 'CTL0070:Creative ViBRA16C PnP' PnP version 1.0 Product version 1.0
Logical device 0 'CTL0001:Audio'
Device is not active
Active port 0x220,0x330,0x388
Active IRQ 5 [0x2]
Active DMA 1,5
Resources 0
Priority preferred
Port 0x220-0x220, align 0x0, size 0x10, 16-bit address decoding
Port 0x330-0x330, align 0x0, size 0x2, 16-bit address decoding
Port 0x388-0x3f8, align 0x0, size 0x4, 16-bit address decoding
IRQ 5 High-Edge
DMA 1 8-bit byte-count compatible
DMA 5 16-bit word-count compatible
Alternate resources 0:1
Priority acceptable
Port 0x220-0x280, align 0x1f, size 0x10, 16-bit address decoding
Port 0x300-0x330, align 0x2f, size 0x2, 16-bit address decoding
Port 0x388-0x3f8, align 0x0, size 0x4, 16-bit address decoding
IRQ 5,7,2/9,10 High-Edge
DMA 1,3 8-bit byte-count compatible
DMA 5,7 16-bit word-count compatible
这个文件可能相当长,取决于显示的设备数目和他们的资源需求。
每个卡列出它的名字, PnP 版号和产品版号。 如果设备是活动的和配置过的,这个文件也将会为设备显示端口和 IRQ 数字。 除此之外, 保证更好的兼容性,卡将会指定给不同叁数首选的和可接受的数值(the card will specify preferred and acceptable values for a number of different parameters)。 这里的目标是要允许 PnP 卡在彼此的周围工作并且避免 IRQ 和端口冲突(The goal here is to allow the PnP cards to work around one another and avoid IRQ and port conflicts)。
/proc/kcore
这个文件表现系统的物理內存并被储存成核心文件格式。 不像大部分的/proc/文件,kcore 显示大小。 这个数值用位元组给出并且和实际的內存 (RAM) 的大小加上 4KB相等。
这个文件的内容被设计成由调试器调试, 例如 gdb ,它就不是人类的可读(如同天书)。

警告
不要访问 /proc/ kcore 虚拟文件。 文件的内容将会由终端文本输出。如果你偶然地看这个文件,按ctrl+c停止程序,然后输入reset,返回指令行提示。

/proc/kmsg
这个文件用来保持被内核产生的信息。 这些信息然后由其他的程序使用, 例如 /sbin/klogd。
风絮飘凌2006-5-12, 22:06 PM
/proc/ksyms
这个文件支撑动态地被输出被模组工具用的符号定义到的内核联接并且绑载入模组(This file holds the kernel exported symbol definitions used by the module tools to dynamically link and bind loadable modules)。
e003def4 speedo_debug[eepro100]
e003b04c eepro100_init[eepro100]
e00390c0 st_template[st]
e002104c RDINDOOR[megaraid]
e00210a4 callDone[megaraid]
e00226cc megaraid_detect[megaraid]

第一栏列出了用于内核运行的内存位址,第二个栏表示运行功能的名字,而且最後一个栏显示载入模块的名字。
/proc/loadavg
这个文件提供一个显示,处理器在时间上的平均负荷和被 uptime 和其他的指令用的附加数据。 一个/proc/ loadavg 文件类似这:
0.20 0.18 0.12 1/80 11206

前三个栏表明在最後 1,5, 和 10 分钟时间段内对处理器的使用。 第四栏表明正在运行的程序数和程序的总数目。 最後一个栏显示最後一个进程使用的ID号。
/proc/lock
这个文件显示正被内核用的块文件。 这个文件的内容包含内核的调试数据和能够做巨大的改变,取决于对系统的使用。 一个轻负荷系统的 /proc/locks文件类似这:
1: FLOCK ADVISORY WRITE 807 03:05:308731 0 EOF c2a260c0 c025aa48 c2a26120
2: POSIX ADVISORY WRITE 708 03:05:308720 0 EOF c2a2611c c2a260c4 c025aa48

每个块都有一个由独特数字为开头的行。第二栏表明块的类, FLOCK表明来自一个flock系统呼叫的老式UNIX文件块, POSIX 表明来自一个 lockf 系统呼叫的较新的 POSIX块锁(with FLOCK signifying the older-style UNIX file locks from a flock system call and POSIX representing the newer POSIX locks from the lockf system call。)
第三栏有二个数值。 ADVISORY意谓着该块允许其他的人访问数据;它只避免其他的人来尝试锁定它。 MANDATORY意谓着当块在的时候,他人访问数据不被允许。第四个栏显示块所有者在访问文件的时候,是否可读或可写 , 第五栏说明拥有块的进程的ID(身份证)。第六栏表明正被锁的文件的ID,格式如MAJOR-DEVICE:MINOR-DEVICE:INODE-NUMBER.。第七栏展现文件的块区域的开始和结束。 剩余的栏指出被特殊调试的内核数据结构,它们可以忽略。
/proc/mdstat
这个文件表明多重-磁盘(multiple-disk)目前的信息,RAID配置。 如果你的系统不包含这样的配置, 那麽你的 /proc/ mdstat 文件将会看起来相似以下:
Personalities :
read_ahead not set
unused devices:
在上面的状态中,这个文件将保留,直到你创建软件RAID或 md 设备。 在那种情况下,你能看到 / proc/ mdstat 给你现在正在用的 mdX RAID设备发生的东西拍快照。
下面的 proc/ mdstat 文件显示一个md0 被配置成RAID1设备的一个系统。 它现在与磁盘同步:
Personalities : [linear] [raid1]
read_ahead 1024 sectors
md0: active raid1 sda2[1] sdb2[0] 9940 blocks [2/2] [UU] resync=1% finish=12.3min
algorithm 2 [3/3] [UUU]
unused devices:

/proc/meminfo
这在/proc/目录中是更普遍使用的文件之一,例如它报告给系统许多关於目前的RAM(随机存取储存器)用法的有价值的资讯。 有256MB内存和 384MB 交换空间的一个系统的 / proc/ meminfo 文件类似这:
total: used: free: shared: buffers: cached:
Mem: 261709824 253407232 8302592 0 120745984 48689152
Swap: 402997248 8192 402989056
MemTotal: 255576 kB
MemFree: 8108 kB
MemShared: 0 kB
Buffers: 117916 kB
Cached: 47548 kB
Active: 135300 kB
Inact_dirty: 29276 kB
Inact_clean: 888 kB
Inact_target: 0 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 255576 kB
LowFree: 8108 kB
SwapTotal: 393552 kB
SwapFree: 393544 kB

这里的很多信息被free, top和 ps 指令引用。 事实上,指令free的输出在内容和结构上都与/proc/meminfo相似。 但是直接地察看 /proc/meminfo,更多的细节被显示:

Mem —显示在系统中内存的目前状态, 包括总共的,使用的,自由的,共享的,缓冲的, 和高速缓冲存储器(cache),它们均以byte表示。
Swap—以byte显示交换空间总共的,使用的,自由的。
MemTotal —物理内存的总数量,以kb为单位。
MemFree —被系统留着未用的物理内存,以kb为单位。
MemShared —不被2.4和更高版本的内核使用的,为与比较早的内核版本保持兼容性而保留。
Buffers—被缓冲文件使用的内存的总数, 以kb为单位。
Cached—被高速缓冲存储器(cache memory)用的内存的总数量, 以kb为单位。
Active—在活跃使用中的缓冲或高速缓冲存储器页面文件的总数量, 以kb为单位。
Inact_dirty —缓冲或高速缓冲存储器页面的总数量, 以kb为单位, 可能是自由的(未使用的)和可利用的。
Inact_clean —缓冲或高速缓冲存储器页面的总数量,以kb为单位,肯定是自由的和可利用的。
Inact_target —平均过一分钟每秒净余量的分配(The net amount of allocations per second),以kb为单位。(Inact_target — The net amount of allocations per second, in kilobytes, averaged over one minute.)
HighTotal 和 HighFree —內存的全体的和自由的量, 分别地,那是间接的在内核空间之内的映射。 HighTotal 数值能改变,基於使用的内核的类型。
LowTotal 和 LowFree —內存的全体的和自由的量,分别地,那是直接的在内核空间之内的映射。 LowTotal 数值能改变,基於使用的内核的类型。
SwapTotal —可用的交换空间的总数量, 以kb为单位。
SwapFree —自由的交换空间的总数量, 以kb为单位
风絮飘凌2006-5-12, 22:08 PM
/proc/misc
这个文件列出各种的主要设备上被注册的各种驱动,这些设备号码 为10: (This file lists miscellaneous drivers registered on the miscellaneous major device, which is device number 10:)
135 rtc
1 psaux
134 apm_bios

第一栏在是每个设备的较小数目 ,第二栏表明正在使用的驱动器(The first column is the minor number of each device, and the second column shows the driver in use)。
/proc/modules
这个文件显示所有被载入内核的模块的列表。 它的内容可能会改变,取决于你的系统的配置和使用,但是它应该以相似的方式被组织成以下这个样本 /proc/modules文件的输出:
ide-cd 27008 0 (autoclean)
cdrom 28960 0 (autoclean) [ide-cd]
soundcore 4100 0 (autoclean)
agpgart 31072 0 (unused)
binfmt_misc 5956 1
iscsi 32672 0 (unused)
scsi_mod 94424 1 [iscsi]
autofs 10628 0 (autoclean) (unused)
tulip 48608 1
ext3 60352 2
jbd 39192 2 [ext3]

第一栏包含模块的名字。 第二个栏表明模块占用內存的大小,以b作单位。 第三栏告诉你是否模块现在被载入 (1) 或未被载入 (0)。最后一栏表明模块是否能在没有使用一段时期之後自动地卸货它本身(autoclean),是否它不被利用(unused).所在行列有名字在括号中(象[ or ]) 任何模块告诉你这个模块依赖另外的模块(Any module with a line containing a name listed in brackets ([ or ]) tells you that this module depends upon another module to be present in order to function)。
/proc/mounts
这个文件简明列出正被系统使用中的所有的挂载点(mounts):
rootfs / rootfs rw 0 0
/dev/hda2 / ext3 rw 0 0
/proc /proc proc rw 0 0
/dev/hda1 /boot ext3 rw 0 0
none /dev/pts devpts rw 0 0
none /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0

在这里的输出与/ etc/mtab的内容类似, 除了 /proc/mount可能是才更新的。
第一栏指明被挂载的设备,第二个栏显示挂载点( mountpoint)。第三个栏告诉文件系统类型,第四个栏告诉你是否它被挂载成只读 (ro) 或可读可写(rw)。 第五栏和第六栏是虚拟数值,它们被设计成与/etc/mtab的格式匹配。
/proc/mtrr
这个文件表明在使用中的系统目前內存范围记录器 (MTRRs) 。 如果你系统的结构支持 MTRRs,你的 mtrr 可能看起来相似以下(This file refers to the current Memory Type Range Registers (MTRRs) in use with the system. If your system's architecture supports MTRRs, your mtrr might look something like this:):
reg00: base=0x00000000 ( 0MB), size= 64MB: write-back, count=1

MTRRs 与intel P6系列处理器 (Pentium 2 和更高的)一同使用,而且他们被用来控制处理器访问內存的范围。 当使用 PCI 或 AGP 插槽上的显卡的时候, 适当地配置 / proc/ mtrr 文件能获得超过 150% 的性能.
大部份时间,这个数值会为你适当地配置。要得到更多有关MTRRs的资讯和手动配置这个文件,请看 。
/proc/ partitions
除了下列各项以外,这里的大部份信息对使用者来说不太重要:

major —设备的主要数目。 主要的数目在我们的例子 (3) 中用 区块设备 ide0 符合在 /proc/ devices(major — The major number of the device with this partition. The major number in our example (3) corresponds with the block device ide0 in /proc/devices。)
minor —设备的较小数目。 这服侍在~结束的时候分割的名字分开分割进不同的实际设备之内并且与~有关数目。(minor — The minor number of the device with this partition. This serves to separate the partitions into different physical devices and relates to the number at the end of the name of the partition )
# blocks—列表被包含在特别的分割实际的磁盘区块的数目(#blocks — Lists the number of physical disk blocks contained in a particular partition。)
name—分割的名字(name — The name of the partition)。
/proc/pci
这个文件包含你系统上的每个 PCI 设备的一个完整的列表。取决于你有的 PCI 设备的数目,/proc/ pci 能相当长。 来自一个基本系统上的这个文件的一个例子看起来相似这:
Bus 0, device 0, function 0:
Host bridge: Intel Corporation 440BX/ZX - 82443BX/ZX Host bridge (rev 3).
Master Capable. Latency=64.
Prefetchable 32 bit memory at 0xe4000000 [0xe7ffffff].
Bus 0, device 1, function 0:
PCI bridge: Intel Corporation 440BX/ZX - 82443BX/ZX AGP bridge (rev 3).
Master Capable. Latency=64. Min Gnt=128.
Bus 0, device 4, function 0:
ISA bridge: Intel Corporation 82371AB PIIX4 ISA (rev 2).
Bus 0, device 4, function 1:
IDE interface: Intel Corporation 82371AB PIIX4 IDE (rev 1).
Master Capable. Latency=32.
I/O at 0xd800 [0xd80f].
Bus 0, device 4, function 2:
USB Controller: Intel Corporation 82371AB PIIX4 USB (rev 1).
IRQ 5.
Master Capable. Latency=32.
I/O at 0xd400 [0xd41f].
Bus 0, device 4, function 3:
Bridge: Intel Corporation 82371AB PIIX4 ACPI (rev 2).
IRQ 9.
Bus 0, device 9, function 0:
Ethernet controller: Lite-On Communications Inc LNE100TX (rev 33).
IRQ 5.
Master Capable. Latency=32.
I/O at 0xd000 [0xd0ff].
Non-prefetchable 32 bit memory at 0xe3000000 [0xe30000ff].
Bus 0, device 12, function 0:
VGA compatible controller: S3 Inc. ViRGE/DX or /GX (rev 1).
IRQ 11.
Master Capable. Latency=32. Min Gnt=4.Max Lat=255.
Non-prefetchable 32 bit memory at 0xdc000000 [0xdfffffff].

这个输出展现所有 PCI 设备的列表,以总线,设备,功能来分类(sorted in the order of bus, device, and function)。 不仅仅提供设备的名字和版本 , 这个列表也给你IRQ的详细说明信息,你能很快地找出冲突。

提示
要得到这个信息的一个更可读的版本,输入:
lspci -vb

/proc/slabinfo
这个文件给片层次上的关於~的资讯內存用法(This file gives information about memory usage on the slab level)。Linux2.2及更高的内核都用slab pools在页层次上面来管理內存。普遍用物件有他们的自己片池(Commonly used objects have their own slab pools.)。下列各项是典型的 /proc/ slabinfo 虚拟文件的部分:
slabinfo - version: 1.1
kmem_cache 64 68 112 2 2 1
nfs_write_data 0 0 384 0 0 1
nfs_read_data 0 160 384 0 16 1
nfs_page 0 200 96 0 5 1
ip_fib_hash 10 113 32 1 1 1
journal_head 51 7020 48 2 90 1
revoke_table 2 253 12 1 1 1
revoke_record 0 0 32 0 0 1
clip_arp_cache 0 0 128 0 0 1
ip_mrt_cache 0 0 96 0 0 1

这个文件中的数值以下列顺序出现: cache名字,活跃的链接(objects)数目,总链接的数目,链接的大小数目,链接的活跃片 (区块) 的数目,链接的片总数和每片页数(The values in this file occur in the following order: cache name, number of active objects, number of total objects, size of the object, number of active slabs (blocks) of the objects, total number of slabs of the objects, and the number of pages per slab)。
注意活跃在这种情况下意谓着一个链接是在使用中。 因此一个活跃的链接是在使用中的,而一个活跃的片是包含一个或更多活跃的链接。
/proc/stat
它记录着自最近开机之後,有关系统的各种不同的数据。 /proc/stat的内容 /proc/stat, 可能相当长,其开始部分与以下相似:
cpu 1139111 3689 234449 84378914
cpu0 1139111 3689 234449 84378914
page 2675248 8567956
swap 10022 19226
intr 93326523 85756163 174412 0 3 3 0 6 0 1 0 428620 0 60330 0 1368304 5538681
disk_io: (3,0)1408049,445601,5349480,962448,17135856)
ctxt 27269477
btime 886490134
processes 206458

一些比较常见的统计数据包括:

CPU—以 jiffies(一秒的 1/100)为单位衡量------在以下各种模式下------用户模式,低优先级用户模式(nice), 系统模式 , 和空闲任务。 在顶端给出了所有的CPU的总数,每个CPU在下面又有它自己的数据列表。
page—內存页的数目系统的页数有写在和在外到磁盘(page — The number of memory pages the system has written in and out to disk)。
swap—swap页的数目系统有引进 和在外(swap — The number of swap pages the system has brought in and out)。
intr —系统有经历的中断数目(intr — The number of interrupts the system has experienced)。
btime —启动时间,从 1970 年1月 1 日起以秒计算, 以公元纪年。
/proc/swaps
这个文件测量交换空间和它的利用。 对一个系统来说,只有唯一的一个swap分区, /proc/swap的输出可能看起来类似以下:
Filename Type Size Used Priority
/dev/hda6 partition 136512 20024 -1

虽然一些信息能在/proc/目录中的其他文件看到,/proc/swap提供一个快照-------每个交换文件名,交换空间的类型,总大小和正在使用中的空间数量(以kb作单位)。 当很多交换文件在使用中的时候 , 前面几栏是有用的。优先级越低,交换文件越可能将要被使用(The lower the priority, the more likely the swap file is to be used)。
/proc/uptime
这个文件表明自开机以来共运行了多长时间。 / proc/ uptime的输出 相当短:
350735.47 234388.90

第一个数字告诉你计算机运行的总秒数。 第二个数字告诉你有多少秒机器是空闲的。
/proc/version
这个文件告诉你 Linux 内核和 gcc 的版本, 和红帽子 Linux 的版本:
Linux version 2.4.18-0.40 (user@foo.redhat.com)(gcc version 2.96 20000731
(Red Hat Linux 7.2 2.96-102)) #1 Tue May 28 04:28:05 EDT 2002
风絮飘凌2006-5-12, 22:09 PM
通常有关内核的大量的信息被放置在/proc/的目录和子目录中。
进程目录(Process Directories)
每个/proc/ 目录包含许多目录名。 一个列表可能类似这个:
dr-xr-xr-x 3 root root 0 Feb 13 01:28 1
dr-xr-xr-x 3 root root 0 Feb 13 01:28 1010
dr-xr-xr-x 3 xfs xfs 0 Feb 13 01:28 1087
dr-xr-xr-x 3 daemon daemon 0 Feb 13 01:28 1123
dr-xr-xr-x 3 root root 0 Feb 13 01:28 11307
dr-xr-xr-x 3 apache apache 0 Feb 13 01:28 13660
dr-xr-xr-x 3 rpc rpc 0 Feb 13 01:28 637
dr-xr-xr-x 3 rpcuser rpcuser 0 Feb 13 01:28 666
这些目录叫做进程目录,因为他们以进程的ID命名且包含进程的详细信息。当使用者运行程序时,在进程目录中对所有者和组的设定都会起作用。 当进程被结束的时候, 它的 /proc/进程目录将消失。
每个进程目录包含以下文件:

cmdline —这个文件包含启动进程发出的命令。
CPU—提供对系统的每个处理器的利用的详细资讯。 在一个双处理器系统上运行某程序会有类似以下的输出:
cpu 11 3
cpu0 0 0
cpu1 11 3

cwd —一 链接到程序当前工作目录(A symlink to the current working directory for the process.)。
environ —为程序给出环境变量的列表。环境变数被屈服所有的大写字符,而且数值是在小写(铅字) 字符中(The environment variable is given in all upper-case characters, and the value is in lower-case characters)。



exe —一链接到可运行的程序。
fd —一该目录包含进程的所有描述文件。 他们象以下:
total 0
lrwx------ 1 root root 64 May 8 11:31 0 -> /dev/null
lrwx------ 1 root root 64 May 8 11:31 1 -> /dev/null
lrwx------ 1 root root 64 May 8 11:31 2 -> /dev/null
lrwx------ 1 root root 64 May 8 11:31 3 -> /dev/ptmx
lrwx------ 1 root root 64 May 8 11:31 4 -> socket:[7774817]
lrwx------ 1 root root 64 May 8 11:31 5 -> /dev/ptmx
lrwx------ 1 root root 64 May 8 11:31 6 -> socket:[7774829]
lrwx------ 1 root root 64 May 8 11:31 7 -> /dev/ptmx
maps—包含与进程有关的各种的可执行文件和库文件的內存映像。 这个文件可能相当长, 取决于程序是否复杂, sshd 进程的输出的开始像这一样:
08048000-08086000 r-xp 00000000 03:03 391479 /usr/sbin/sshd
08086000-08088000 rw-p 0003e000 03:03 391479 /usr/sbin/sshd
08088000-08095000 rwxp 00000000 00:00 0
40000000-40013000 r-xp 00000000 03:03 293205 /lib/ld-2.2.5.so
40013000-40014000 rw-p 00013000 03:03 293205 /lib/ld-2.2.5.so
40031000-40038000 r-xp 00000000 03:03 293282 /lib/libpam.so.0.75
40038000-40039000 rw-p 00006000 03:03 293282 /lib/libpam.so.0.75
40039000-4003a000 rw-p 00000000 00:00 0
4003a000-4003c000 r-xp 00000000 03:03 293218 /lib/libdl-2.2.5.so
4003c000-4003d000 rw-p 00001000 03:03 293218 /lib/libdl-2.2.5.so
mem —被程序占用的內存。 这个文件不能被使用者读取。
Root-----进程到root目录的链接。
Stat—程序的状态。
statm —被进程使用的內存的状态。下面是/proc/ statm 文件的一个样本:
263 210 210 5 0 205 0
七栏针对不同的方面对程序占用內存做出统计。 从左到右,他们依次是下列各个方面:

size 程序大小 KB
resident 常驻内存空间大小 KB
shared 共享内存页数
trs 代码段占用内存页数
drs 数据/堆栈段占用内存页数
lrs 引用库占用内存页数
dt 脏页数量
阅读(841) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~