|< Day Day Up >|
Recipe 5.4. Getting Live Hardware Snapshots with /proc
Read the /proc virtual filesystem. Use only cat to read /proc, or utilities designed expressly for it, such as sysctl, lspci, ps, and top. The syntax is the same as for reading any file:
$ cat /proc/filename
You can explore /proc just like any filesystem and easily find the information you want. Look to the named folders for hardware information:
$ ls /proc bus cmdline cpuinfo devices dma driver filesystems ide kcore kmsg ksyms loadavg meminfo misc modules mounts mtrr partitions pci scsi swaps sys tty
$ cat /proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 6 model : 3 model name : AMD Duron(tm) Processor stepping : 1 cpu MHz : 801.442 ...
$ cat /proc/meminfo total: used: free: shared: buffers: cached: Mem: 262746112 237740032 25006080 0 11575296 150138880 Swap: 534601728 81661952 452939776 MemTotal: 256588 kB MemFree: 24420 kB ...
$ cat /proc/ide/via -------VIA BusMastering IDE Configuration--------- Driver Version: 3.37 South Bridge: VIA vt82c686a Revision: ISA 0x22 IDE 0x10 Highest DMA rate: UDMA66 BM-DMA base: 0xd400 PCI clock: 33.3MHz ...
$ cat /proc/ide/ide0/hda/geometry physical 39870/16/63 logical 2501/255/63
$ cat /proc/ide/ide0/hda/model IBM-DTLA-305020
$ cat /proc/ide/drivers de-scsi version 0.93 ide-cdrom version 4.59-ac1 ide-floppy version 0.99.newide ide-disk version 1.17 ide-default version 0.9.newide
$ cat /proc/sys/dev/cdrom/info CD-ROM information, Id: cdrom.c 3.12 2000/10/18 drive name: sr1 sr0 drive speed: 40 32 ... Can read multisession: 1 1 Can read MCN: 1 1 Reports media changed: 1 1 Can play audio: 1 1 Can write CD-R: 1 0 Can write CD-RW: 1 0 Can read DVD: 0 1 Can write DVD-R: 0 0 Can write DVD-RAM: 0 0
To show SCSI devices, using the following command. Note that it does not differentiate between devices attached to the SCSI bus and IDE devices using the SCSI-emulation subsystem. These are IDE CD drives:
$ cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: TOSHIBA Model: DVD-ROM SD-M1202 Rev: 1020 Type: CD-ROM ANSI SCSI revision: 02 Host: scsi0 Channel: 00 Id: 01 Lun: 00 Vendor: LITE-ON Model: LTR-24102B Rev: 5S54 Type: CD-ROM ANSI SCSI revision: 02
This following command is just plain fun and has absolutely no practical value. It requires a functioning sound system. Warning: it's noisy—this is the sound of your CPU in action. Ctrl-C stops it:
# cat /proc/kcore > /dev/dsp
Disk geometry, as expressed by /proc or any other utility, is largely a fiction. Modern drives are far more complex than the old "heads sectors cylinders" model.
As mentioned earlier, to read /proc use only cat or utilities designed expressly for it, such as sysctl, lspci, ps, and top. Pagers like less and more give a different picture, because they re-read /proc with each page. And you don't want to use a text editor, or any utility with write powers, because you can mess up your system in a heartbeat.
5.4.4 See Also
|< Day Day Up >|