Obtain the system runtime data from the PROC file system and SYSFS System

Source: Internet
Author: User

==============================
-PROC file system Introduction
==============================

; Display memory information, corresponding command: vmstat/free
$ Cat/proc/meminfo
$ Cat/proc/vmstat
$ Cat/proc/vmmemctl

; Display device information
$ Cat/proc/devices

Displays disk information. The second command displays the partition name, the primary device number and the secondary device number. The corresponding command is fdisk-l.
$ Cat/proc/diskstats
$ Cat/proc/partitions

; Display start time
$ Cat/proc/uptime
$ Cat/proc/version

Displays System interruption and related information, used to view the IRQ interrupt requested by the device, where 'i8042' is the keyboard
The second command displays the address range occupied by system IO.
The third command is used to view the address space read and write by the system device.
$ Cat/proc/interrupts
$ Cat/proc/ioports
$ Cat/proc/iomem

View CPU information and CPU support for Instruction Sets
$ Cat/proc/cpuinfo | awk '/flags /'
$ Cat/proc/cpuinfo | awk '/vendor /'
$ Cat/proc/cpuinfo | awk '/MHz /'

View the file system compiled by the kernel, that is, view the file system supported by the kernel
$ Cat/proc/filesystems

View the modules loaded by the system. Command: lsmod
$ Cat/proc/modules

; View average system load
$ Cat/proc/loadavg
View the command line parameters sent to the kernel through the system startup command line
$ Cat/proc/cmdline

; System call list
$ Cat/proc/kallsyms


+ Network
The system ARP table is displayed. "HWADDR" 0 indicates that the IP address is not occupied.
$ Cat/proc/net/arp
Displays SNMP information. The preceding line indicates each field, and the following line indicates the value.
$ Cat/proc/net/snmp
; Display total interface traffic
$ Cat/proc/net/dev
The route table is displayed. Note that it is not displayed in hexadecimal notation, but in hexadecimal notation.
$ Cat/proc/net/route
Displays wireless information, including received AP and signal quality.
$ Cat/proc/net/wireless

+ Process <CPU/IO/Fd>
; Reference Directory <vw>:/proc/# Pid/
View the memory ing table, including its reference to the Dynamic Linked Library and stack location, which can be used for troubleshooting
$ Cat $ vw/maps
$ Cat $ vw/smaps
View the running status of the process. For example, the SLEEP parameter table shows the degree of busy process.
$ Cat $ vw/status
View the IO status of the process. You can also check whether the process is an IO-intensive process.
$ Cat $ vw/io
View the files opened by the process and run the following command: lsof
$ Ls $ vw/fd
; View the working directory of the process
$ Ls-l $ vw/cwd
; View process executable files
$ Ls-l $ vw/exe
; View the environment variables of the input process
$ Cat $ vw/environ
; View the command line of the input process
$ Cat $ vw/cmdline | tr "\ 000" "\ n"
View the process restrictions, such as the number of opened files and the number of Running jobs.
$ Cat $ vw/limits
; View the elements locked by the Process
$ Cat $ vw/locks

+ Device
View information about the optical drive. Pay attention to DRIVENAME, which is required for mounting.
$ Cat/proc/sys/dev/cdrom/info

+ Bus
View the PCI bus. Command: lspci/setpci
$ Cat/proc/bus/pci/devices
View the USB bus. Command: lsusb
$ Cat/proc/bus/usb/devices
; View the keyboard, mouse, and speaker
$ Cat/proc/bus/input/devices
$ Cat/proc/bus/input/handler
; View the SCSI bus
$ Cat/proc/scsi
; View SCSI devices
$ Cat/proc/scsi/device_info
==================================
* SYS File System
==================================

; View the original MAC of the NIC
$ Cat/sys/class/net/ethX/address
; View Nic statistics
$ Cat/sys/class/net/ethX/statistics /*
; View interface status
$ Cat/sys/class/net/ethX/operstate
 
For example
This Code calculates the network traffic received by the ETH0 interface within 10 seconds. The unit is BPS.
#! /Bin/bash
Cd/sys/class/net/eth0/statistics
StartRX = 'cat rx_bytes'
Sleep 10
EndRX = 'cat rx_bytes'
BytesTotal = 'expr $ endRX-$ startrx'
Bps = 'expr $ bytesTotal '/'10'
Echo "The average traffic is RX: $ {bps} Bytes/sec"
Note: we can see from the above that all LINUX performance data collection tools read performance data from the/PROC file system. In addition, since we already know the source of system performance data, if these tools are not installed in the system, you can also write scripts to collect data. In addition, if you do not know about the PROC file system, you cannot write any files in the PROC file system, especially online systems. Otherwise, you are not liable for this.
 
Author "nothing is serious !"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.