Cent OS viewing Server Information

Source: Internet
Author: User

How to view server information in centos Linux
Some customers often ask Cloud Zhi interconnection to view some hardware configuration methods of the server. The following uses centos as an example to share various information viewing methods with users. This tutorial is applicable to centos, Debian, and other Linux distributions.
1. view the server CPU Model
More/proc/cpuinfo | grep "model name"
Grep "model name"/proc/cpuinfo
Grep "model name"/proc/cpuinfo | cut-F2-D:
2. View server memory capacity
Grep memtotal/proc/meminfo
Grep memtotal/proc/meminfo | cut-F2-D:
Free-M | grep "mem" | awk '{print $2 }'
3. Check whether the server's CPU is 32-bit or 64-bit.
Getconf long_bit
4. view the current Linux version
More/etc/RedHat-release CAT/etc/RedHat-release
5. view the Linux kernel version
Uname-R
Uname-
6. view the current server time
Date
7. View server hard disks and partitions
DF-H
Fdisk-l
8. view the directory size
DU/etc-SH
9. view the software packages initially installed on the server
Cat-N/root/install. Log
More/root/install. log | WC-l
10 view installed software packages
Rpm-Qa
Rpm-Qa | WC-l
Yum List Installed | WC-l
11 view the server keyboard layout
CAT/etc/sysconfig/keyboard
CAT/etc/sysconfig/keyboard | grep keytable | cut-F2-D =
View SELinux status
Sestatus
Sestatus | cut-F2-D:
CAT/etc/sysconfig/SELinux
12. view the IP address and MAC address of the server Nic.
In the ifcfg-eth0 file you can see Mac, Gateway and other information.
Ifconfig
CAT/etc/sysconfig/network-scripts/ifcfg-eth0 | grep ipaddr
CAT/etc/sysconfig/network-scripts/ifcfg-eth0 | grep ipaddr | cut-F2-D =
Ifconfig eth0 | grep "Inet ADDR:" | awk '{print $2}' | cut-C 6-
Ifconfig | grep 'inet ADDR: '| grep-V' 127. 0.0.1' | cut-D:-F2 | awk '{print $1 }'
13. view the Default Server Gateway
CAT/etc/sysconfig/Network
14. view the default DNS of the server
CAT/etc/resolv. conf
15. view the default server Language
Echo $ Lang $ Language
CAT/etc/sysconfig/i18n
16. view the time zone and UTC time of the server.
CAT/etc/sysconfig/clock
17. view the server host name
Hostname
CAT/etc/sysconfig/Network

View CPU, memory, network traffic, and disk I/O in centos [Details]
Install Yum install-y sysstat
Sar-D 1 1
Rrqm/s: the number of merge read operations per second. That is, Delta (rmerge)/s
Wrqm/S: Number of write operations performed on merge per second. That is, Delta (wmerge)/s
R/S: The number of read I/O devices per second. That is, Delta (Rio)/s
W/s: the number of write I/O devices completed per second. That is, Delta (WIO)/s
Rsec/S: Number of read sectors per second. That is, Delta (rsect)/s
Wsec/S: Number of write sectors per second. That is, Delta (wsect)/s
RKb/s: the number of bytes read per second. It is half of rsect/s because the size of each slice is 512 bytes. (Computing required)
WKB/s: the number of K bytes written per second. Half of wsect/s. (Computing required)
Avgrq-SZ: average data size (slice) of each device I/O operation ). Delta (rsect + wsect)/DELTA (Rio + WIO)
Avgqu-SZ: Average I/O queue length. That is, Delta (aveq)/S/1000 (because aveq is measured in milliseconds ).
Await: average wait time (in milliseconds) for each device I/O operation ). That is, Delta (ruse + wuse)/DELTA (Rio + WIO)
Svctm: Average service time (in milliseconds) for each device I/O operation ). That is, Delta (use)/DELTA (Rio + WIO)
% Util: the percentage of time in one second is used for I/O operations, or the number of I/O queues in one second is not empty. That is, Delta (use)/S/1000 (because the Unit of use is milliseconds)
If % util is close to 100%, it indicates that too many I/O requests are generated and the I/O system is fully loaded.
There may be bottlenecks.
When the idle is less than 70% I/O, the load is high. Generally, the read speed is wait.
You can also view the parameters B (number of processes waiting for resources) and Wa in combination with vmstat (percentage of CPU time occupied by I/O wait, higher than 30% when I/O pressure is high)
For more information, see
Generally, svctm is smaller than await (because the wait time for simultaneously waiting requests is calculated repeatedly). The size of svctm is generally related to disk performance, and the CPU/memory load will also affect it, too many requests may indirectly increase the svctm. The size of await generally depends on the service time (svctm), the length of the I/O queue, and the mode in which I/O requests are sent. If svctm is close to await, it means that I/O has almost no waiting time. If await is much larger than svctm, it means that the I/O queue is too long and the response time of the application is slow, if the response time exceeds the allowable range, you can consider replacing a faster disk, adjusting the kernel elevator algorithm, optimizing the application, or upgrading the CPU.
The queue length (avgqu-sz) can also be used as an indicator to measure the system I/O load. However, because avgqu-SZ is based on the average per unit time, therefore, it cannot reflect the instantaneous I/O flood.
In the command line mode, how do I view CPU, memory usage, network traffic, and disk I/O?
Q: How can I view CPU, memory usage, network traffic, and disk I/O in the command line mode?

A: In command line mode,
1. Command for viewing CPU usage
$ Vmstat 5
Refresh Every 5 seconds, with CPU usage data at the rightmost.
$ Top
Top, then sort by SHIFT + P, by process processor usage
2. Command to view memory usage
$ Free
Top and then sort by SHIFT + M, by process memory usage
$ Top
3. View network traffic
You can use the iptraf tool.
$ Iptraf-G
"" Can be obtained by comparing the RX and TX data of two time network interfaces for the network traffic of an interface.
$ Date; ifconfig eth1
$ Date; ifconfig eth1
4. view disk I/O
$ Iostat-D-x/dev/sdc3 2
Use iostat to view disk I/O of Disk/dev/sdc3, and refresh every two seconds.
$ Vmstat 2
Use vmstat to view Io Information
Procs:
R->; number of processes waiting in the running queue
B->; number of processes waiting for Io
W->; processes that can enter the running queue but are replaced
Memoy
Swap->; available swap memory (k)
Free->; idle memory (k)
Pages
Re -- recycling page
Mf -- non-serious error page
Pi -- number of incoming pages (k)
Po -- number of outgoing pages (k)
Fr -- number of free pages (k)
De -- number of missed pages read in advance
Sr-page scanned by clock algorithm
Disk Displays disk operations per second. S indicates the SCSI disk, and 0 indicates the disk number.
Fault displays the number of interrupts per second
In -- device interruption
Sy -- System interruption
Cy -- CPU Switching
CPU indicates the CPU usage status
CS -- time used by the user process
Sy -- time used by the system process
Id -- CPU idle time
Where:
If R is often greater than 4 and the ID is often less than 40, the CPU load is heavy.
If PI and Po are not equal to 0 for a long time, the memory is insufficient.
If the disk is often not equal to 0 and the queue in B is greater than 3, the IO performance is poor.

Disk I/O performance monitoring command
1) iostat command
The iostat command monitors the load of the system input/output device by observing the activity time of the physical disk and their average transmission speed. According to the report generated by the iostat command, you can determine whether a system configuration is balanced and balance the input/output load between the physical disk and the adapter accordingly. The iostat tool is designed to monitor disk utilization and detect system I/O bottlenecks. The output formats of different operating system command formats are slightly different. The administrator can check the user manual to determine its usage.
Install iostat
Iostat command. If no command is used, install it.
Installation command
Apt-Get install sysstat
Deb package (Ubuntu server 9.10)
Http://tw.archive.ubuntu.com/ubuntu/pool/main/s/sysstat/sysstat_9.0.3-2ubuntu1_amd64.deb
Targz package
Http://pagesperso-orange.fr/sebastien.godard/sysstat-9.1.1.tar.gz
2) SAR commands
The SAR Command reports CPU usage, I/O, and other system behaviors. SAR commands can collect, report, and save system behavior information. The data collected in this way is useful for determining the time cycle characteristics of the system and determining the peak usage time. However, when running the sar command, a considerable number of reads and writes are generated. Therefore, it is best to run the SAR statistics without any workload, measure the test taker's knowledge about the impact of SAR on the overall statistics.

2. Disk I/O performance indicators
Before introducing the disk I/O monitoring command, we need to understand the disk I/O performance monitoring metrics, as well as the disk performance of each indicator. Disk I/O performance metrics include:
1) I/O per second (iops or TPS)
For a disk, the continuous read or write operation of a disk is called a disk I/O. The iops of the disk is the sum of the number of consecutive read operations and write operations of the disk per second. This indicator is of important reference significance when small pieces of discontinuous data are transmitted.
2) Throughput)
It refers to the speed at which data streams are transmitted by hard disks. The transmitted data is the sum of read and write data. The Unit is generally kbps, MB/s, etc. This indicator provides an important reference for transmitting large pieces of discontinuous data.
3) average I/O data size
The average I/O data size is the throughput divided by the I/O quantity. This indicator is important for revealing the disk usage mode. Generally, if the average I/O data size is smaller than 32 KB, the disk usage mode is primarily random access. If the average I/O data size is greater than 32 KB, it can be considered that the disk usage mode focuses on sequential access.
4) Percentage of disk activity time (utilization) % util
The percentage of the time when the disk is active, that is, the disk usage. The disk is active in data transmission and processing commands (such as seeking. The disk utilization is proportional to the resource contention degree and is inversely proportional to the performance. That is to say, the higher the disk utilization, the more serious the resource contention, the worse the performance, and the longer the response time. In general, if the disk usage exceeds 70%, the application process will spend a long time waiting for I/O to complete, because most processes will be blocked or sleep while waiting.
5) servicetime svctm
The execution time of disk read or write operations, including seek, rotation delay, and data transmission time. The size is generally related to disk performance, and the CPU/memory load will also affect it. Too many requests will indirectly lead to an increase in service time. If the value lasts for more than 20 ms, it may affect upper-layer applications.
6) I/O wait queue length (queue length)
The number of I/O requests to be processed. This value increases if the I/O Request pressure continuously exceeds the disk processing capability. If the queue length of a single disk exceeds 2, it is generally considered that the disk has an I/O performance problem. Note that if the disk is a virtual logical drive of the disk array, You need to divide the value by the actual number of physical disks that constitute the logical drive, to obtain the length of the I/O wait queue for an average single hard disk.
7) wait time (wait time)
It refers to the time when the disk read or write operations are waiting for execution, that is, the waiting time in the queue. If I/O requests continue to exceed the disk processing capacity, it means that I/O requests that cannot be processed have to wait for a long time in the queue. By monitoring the preceding metrics, and comparing these metrics with historical data, empirical data, and disk nominal values, if necessary, the CPU, memory, and swap partition usage are combined, it is not difficult to find potential or problems with disk I/O. But what if we want to avoid and solve these problems? This requires the use of knowledge and technology in disk I/O performance optimization. Limited by the subject and length of this article, we only list some common Optimization Methods for your reference:
(1) Adjust the Data Layout and allocate I/O requests to all physical disks as much as possible;
(2) For raid disk arrays, try to make the application I/O equal to the Strip size or a multiple of the Strip size. Select appropriate raid methods, such as raid 10 and RAID 5;
(3) increase the queue depth of the disk driver, but do not exceed the disk processing capacity. Otherwise, some I/O requests will be resent due to loss, which will reduce the performance;
(4) The application Cache Technology reduces the number of times an application accesses a disk. The cache technology can be applied at the file system level or application level;
(5) because most databases already include optimized cache technology, database I/O should directly access the original disk partition (rawpartition) or use the dio Technology (direct Io) that bypasses the file system cache );
(6) storing frequently accessed files or data in the memory, taking advantage of the memory read/write bandwidth, which is far superior to direct disk I/O operations.

3. Use iostat
[Command:] iostat [-c |-D] [-K] [-T] [interval description] [detection times]
Parameters:
-C: Only displays the CPU status.
-D: Only displays the status of the storage device. It cannot be used with-C.
-K: The read block information is displayed by default. You can use-K to change the size of KB to display the block information.
-T: Display date
-P device | all: device is a device or a partition. If all is used, information about all partitions and devices is displayed.
1) Basic use
$ Iostat-D-K 1 10
Note: The-D parameter indicates that the device (Disk) usage status is displayed.-K indicates that kilobytes is used as the unit of block usage. 1 10 indicates that, the data display is refreshed every 1 second, and a total of 10 times are displayed. Each statistics is the statistical data between the previous statistical time and the current statistical time.
2)-x Parameters
Use the-x parameter to obtain more statistics.
$ Iostat-D-X-K 1 10
3)-C Parameters
Obtain the status value of the CPU.
$ Iostat-C 1 10
4) common usage
$ Iostat-D-K 1 10
# Viewing TPS and throughput Information
$ Iostat-D-X-K 1 10
# View device usage (% util) and response time (await)
$ Iostat-C 1 10
# View CPU status
5) mpstat command
Mpstat is short for Multiprocessor statistics and is a real-time system monitoring tool. Its report and CPU statistics are stored in the/proc/STAT file. In a multi-CPUs system, it can not only view the average status information of all CPUs, but also view information about specific CPUs. The following describes only the CPU-related parameters of mpstat. The mpstat syntax is as follows:
Mpstat [-P {| all}] [internal [count]
Parameter description
-P {| all} indicates the CPU to be monitored. The CPU value ranges from 0 to 1.
Interval between two adjacent internal sampling
Count: the number of samples. Count can only be used with delay.
If no parameter exists, mpstat displays the average value of all information after the system is started. The average information of the first line since the system was started when interval exists.
(1) $ mpstat
When mpstat does not contain parameters, the output value is the average value since the system was started.
(2) $ mpstat-P all 2 3
Generate statistical reports of all processors in 2 seconds, and collect statistics three times. By default, statistical data of all processors is output;
(3) $ mpstat-P 0 2 3
Generate the statistical report of the No. 0 processor in 2 seconds, and make three counts;
4. iostat Parameters
Parameter description
Rrqm/s Read Request the number of merge read operations per second. That is, Delta (rmerge)/s
Wrqm/s write request the number of write operations performed by merge per second. That is, Delta (wmerge)/s
The number of read I/O devices completed by R/S read per second. That is, Delta (Rio)/s
The number of write I/O devices completed by W/s write per second. That is, Delta (WIO)/s
The number of read sectors per second in the rsec/s read section. That is, Delta (rsect)/s
Number of write sectors per second in the wsec/s write section. That is, Delta (wsect)/s
RKb/s read kilo bytes read K bytes per second. It is half of rsect/s because the size of each slice is 512 bytes. (Computing required)
WKB/s write kilo byte write K bytes per second. Half of wsect/s. (Computing required)
Avgrq-SZ average request size average data size (slice) of each device I/O operation ). Delta (rsect + wsect)/DELTA (Rio + WIO)
Avgqu-SZ average queue size average I/O queue length. That is, Delta (aveq)/S/1000 (because aveq is measured in milliseconds)
Await average wait time (milliseconds) for each device I/O operation ). That is, Delta (ruse + wuse)/DELTA (Rio + WIO)
Svctm service time indicates the average service time (in milliseconds) for each device I/O operation ). That is, Delta (use)/DELTA (Rio + WIO)
% Util utilty The amount of time in one second is used for I/O operations, or the number of I/O queues in one second is not empty. That is, Delta (use)/S/1000 (because the Unit of use is milliseconds)

If % util is close to 100%, it indicates that too many I/O requests are generated and the I/O system is fully loaded. This disk may have a bottleneck and the idle is under a high I/O pressure if it is less than 70%, generally, the read speed is wait. At the same time, you can use vmstat (virtual memory status) to view the number of processes waiting for resources (number of processes waiting for resources) and the Wa parameter (percentage of CPU time occupied by Io wait, higher than 30% when the IO pressure is high)
In addition, you can also refer to svctm. Because it is generally smaller than await (because the wait time of the simultaneously waiting request is calculated repeatedly), the size of svctm is generally related to disk performance, the CPU/memory load will also affect it, and too many requests will indirectly lead to the increase of svctm. The size of await generally depends on the service time (svctm), the length of the I/O queue, and the mode in which I/O requests are sent. If svctm is close to await, it means that I/O has almost no waiting time. If await is much larger than svctm, it means that the I/O queue is too long and the response time of the application is slow, if the response time exceeds the allowable range, you can consider replacing a faster disk, adjusting the kernel elevator algorithm, optimizing the application, or upgrading the CPU. The queue length (avgqu-sz) can also be used as an indicator to measure the system I/O load. However, because avgqu-SZ is based on the average per unit time, therefore, it cannot reflect the instantaneous I/O flood.
5. Example (I/O system vs. Supermarket queuing)
For example, how can we decide which payment platform to pay when queuing for checkout at the supermarket? First, let's look at the number of people in the queue. is the total number of five people faster than 20? In addition to the number of people, we often look at the number of items purchased by the previous person. If there is a big mom who has purchased food for a week, we can consider changing the team. There is also the cashier's speed. If you have a newbie who doesn't even know about the money, you will have to wait. In addition, the timing is also very important. It may be 5 minutes ago, but the money was crowded, and now people go to the building, but it is refreshing to pay the money. Of course, the premise is that what has been done in the past five minutes is more meaningful than queuing (but I have not found anything boring than queuing ).
I/O systems have many similarities with supermarket Queues:
Ø R/S + w/s is similar to the total number of payers
The average queue length (avgqu-sz) is similar to the number of average queues per unit time.
The average service time (svctm) is similar to the cashier's collection speed
The average wait time (await) is similar to the average wait time of each person
Ø average I/O data (avgrq-sz) is similar to the average number of items bought by each person
The I/O operation rate (% util) is similar to the time ratio of someone waiting in queue before the cashier.
Parameter Output Analysis
# Iostat-X 1
AVG-CPU: % USER % nice % sys % idle
16.24 0.00 4.31 79.44
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s RKb/s WKB/s avgrq-SZ avgqu-SZ await svctm % util
SDA 0.00 44.90 1.02 27.55 8.16 579.59 4.08 289.80 20.57 22.35 78.21 5.00 14.29

The iostat output above indicates that there are 28.57 device I/O operations in seconds:
Total io (IO)/S = R/S (read) + w/s (write) = 1.02 + 27.55 = 28.57 (times/second) the write operation accounts for the subject (W: r = 27)
On average, only 5 ms is required for each device I/O operation, but 78 MS is required for each I/O request. Why? Because too many I/O requests are sent (about 29 requests per second), assuming these requests are sent at the same time, the average wait time can be calculated as follows:
Average wait time = single I/O service time * (1 + 2 +... + Requests-1)/Total requests
Application to the above example: average wait time = 5 ms * (1 + 2 +... + 28)/29 = 70 ms, which is very close to the average waiting time of 78 MS given by iostat. This in turn indicates that I/O is initiated at the same time.
There are many I/O requests per second (about 29), but the average queue is not long (only about 2). This indicates that the arrival of these 29 requests is uneven, i/O is idle most of the time.
In one second, 14.29% of the time I/O queues have requests. That is to say, the I/O system has nothing to do in 85.71% of the time, all 29 I/O requests are processed within 142 milliseconds.
Delta (ruse + wuse)/DELTA (IO) = await = 78.21 => delta (ruse + wuse)/S = 78.21 * delta (IO) /S = 78.21*28.57 = 2232.8, indicating that I/O requests per second need to wait for a total of 2232.8 Ms. Therefore, the average queue length should be 2232.8 ms/1000 ms = 2.23, while the average queue length (avgqu-sz) provided by iostat is 22.35. Why ?! Because there is a bug in iostat, The avgqu-SZ value should be 2.23 instead of 22.35.
We can analyze the I/O Request mode and the I/O speed and response time based on the data.

View system hardware information in centos
Uname-A # Linux system information command for viewing kernel/operating system/CPU Information
Head-N 1/etc/issue # view the operating system version, which is a number 1, not a letter L
CAT/proc/cpuinfo # Linux system information command for viewing CPU Information
Hostname # Linux system information command for viewing computer names
Lspci-TV # list all PCI devices
Lsusb-TV # Linux system information commands for listing all USB devices
Lsmod # list loaded Kernel Modules
Env # view environment variable resources
Free-M # view memory usage and swap zone usage
DF-h # view the usage of each partition
Du-SH # view the size of the specified directory
Grep memtotal/proc/meminfo # view total memory
Grep memfree/proc/meminfo # view the Amount of idle memory
Uptime # view system running time, number of users, and load
CAT/proc/loadavg # view system load disks and partitions
Mount | column-T # view the status of the mounted Partition
Fdisk-L # view all partitions
Swapon-s # view all swap partitions
Hdparm-I/dev/hda # view disk parameters (only applicable to ide devices)
Dmesg | grep ide # view the network of IDE Device Detection Status at startup
Ifconfig # view the attributes of all network interfaces
Iptables-L # view firewall settings
Route-N # view the route table
Netstat-lntp # view all listening ports
Netstat-antp # view all established connections
Netstat-s # view network statistics process
PS-Ef # view all processes
Top # real-time display of Process status users
W # view active users
ID # view specified user information
Last # view User Logon logs
Cut-D:-F1/etc/passwd # view all users in the system
Cut-D:-F1/etc/group # view all groups in the system
Crontab-L # view the scheduled Task Service of the current user
Chkconfig-list # list all system services
Chkconfig-list | grep on # list all started system service programs
Rpm-Qa # view all installed software packages
CAT/proc/cpuinfo # Linux system command for viewing CPU-related parameters
CAT/proc/Partitions # command for viewing Linux hard disk and partition information
CAT/proc/meminfo # Linux system command for viewing Linux system memory information
CAT/proc/version # view the version, similar to uname-R
CAT/proc/ioports # view the device's IO port
CAT/proc/interrupts # view interrupt
CAT/proc/PCI # view PCI device information
CAT/proc/SWAPs # view information about all swap partitions
If the preceding command does not exist, you can use a similar command like yum provides "*/lspci" on rhel6, and then install the corresponding software package.

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.