Several Linux commands to work with

Source: Internet
Author: User
Tags disk usage

Recently, because of work needs, new learning a few Linux commands, record. Content Reference Related Blogs

Https://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html

Https://www.cnblogs.com/peida/archive/2012/12/28/2837345.html

http://blog.csdn.net/hguisu/article/details/7493661

Iostat: Activity for monitoring disks

Command format: iostat [parameter] [TIME] [times]

With Iostat, it is convenient to view the activity of CPU, network card, TTY device, disk, CD-ROM and so on, load information

    • -C Display of CPU usage
    • -D Display disk usage
    • -K displays in kilobytes
    • -m displays in units of M.
    • -N Display of disk array (LVM) information
    • -N Display of NFS usage
    • -p[disk] Displays disk and partition conditions
    • -t display terminal and CPU information
    • -X to display detailed information
    • -V Display version information

Iostat Show all load conditions

CPU Properties:

%user:cpu percentage of time in user mode

%nice:cpu percentage of time in user mode with nice value

%system:cpu percentage of time in System mode

%iowait:cpu the percentage of time to wait for the input output to finish

%steal: The percentage of the virtual CPU's unconscious wait time when the hypervisor maintains a second virtual processor

%IDLE:CPU Idle time percentage

if the value of%iowait is too high, indicating that the hard disk has an I/O bottleneck, if the%idle value is high but the system responds slowly, it is possible that the CPU waits for the allocated memory, which should increase the memory capacity. If the%idle value continues below 10, the system's CPU processing power is relatively low, indicating that the most resource to be addressed in the system is the CPU.

Disk Properties:

RRQM/S: The number of requests per second that need to be read

WRQM/S: Number of required write requests per second

R/S: Number of Read I/O devices completed per second. namely RIO/S

W/S: Number of write I/O devices completed per second. namely WIO/S

RSEC/S: Number of Read sectors per second. namely RSECT/S

WSEC/S: Number of Write sectors per second. namely WSECT/S

rkb/s: Reads K bytes per second. is half the rsect/s because the size of each sector is 512 bytes.

wkb/s: Writes K bytes per second. is half the wsect/s.

Avgrq-sz: The average data size (sector) per device I/O operation.

Avgqu-sz: Average I/O queue length.

Await: The average wait time (in milliseconds) for each device I/O operation.

SVCTM: The average service time (in milliseconds) per device I/O operation.

%util: How much time in a second is spent on I/O operations, which is the percentage of CPU consumed by IO

if%util is close to 100%, it indicates that there are too many I/O requests, the I/O system is full , and the disk may have bottlenecks. If the SVCTM is closer to await, it indicates that I/O has almost no wait time, and if the await is much larger than SVCTM, indicating that the I/O queue is too long and the IO response is too slow , the necessary optimizations are required. If the Avgqu-sz is larger, it also indicates that there is an equivalent IO waiting.

Common Iostat-x/dev/sda1 1 100 (refresh every 1s, refresh 100 times) to see the details of disk I/O

The SAR command is a Linux system profiling tool that analyzes file reads and writes , usage of system calls, disk I/O, CPU efficiency, memory usage, process activity, and IPC-related activities, among other things.

Command format

SAR [Options] [-A] [-o file] t [n]

which

T is the sampling interval, n is the number of samples, the default value is 1;

-o file means that the command result is stored in a binary format in a file, and file is a filename.

Options is a command-line option, and the SAR command is commonly used as follows:

-A: Sum of all reports

-P: Set CPU

-U: Output statistics about CPU usage

-V: Output statistics for inode, files, and other kernel tables

-D: Output activity information for each block device

-N: Reporting Network conditions
-Q: Report Queue length and payload information

-r: Output memory and swap space statistics

-B: Display statistics for I/O and transfer rates

-A: File read and write status

-C: Output process statistics, number of processes created per second

-r: Output memory page statistics

-Y: terminal equipment activity situation

-W: Output system Exchange activity information

Monitoring of the CPU

Sar-u-O cpuinfo 1 5 (interval 1s, sampled 5 times)

Monitoring of IO and transfer rates

Sar-b 1 5

TPS: Total I/O transfers per second of disk

Rtps: Total amount of data read from disk per second

Wtps: Total amount of data written to disk per second

BREAD/S: Amount of data read from disk per second in block/s

BWRTN/S: Amount of data written to disk per second in blocks/s

Suspected CPU bottlenecks, sar-u and sar-q can be used to view

Suspect memory bottlenecks and can be viewed with Sar-b, sar-r, sar-w, etc.

Suspected I/O bottlenecks and can be viewed with Sar-b, sar-u, sar-d, etc.

SED command: An online editor that operates on a single line of commands, primarily for editing one or more files.

sed [-NEFR] [action] options and Parameters:-N: Use Quiet (silent) mode. In the usage of general sed, all data from STDIN is generally listed on the terminal. However, if you add the-n parameter, only the line (or action) that is specially processed by SED is listed. -E: The action edit of SED directly in the command-line mode;-F: The action of SED is written in a file directly, and-f filename can run the SED action within filename; The-r:sed action supports the syntax of the extended formal notation. (The default is the basic formal notation of French)-I: Directly modifies the contents of the read file, not the output to the terminal.
Action Description: [N1[,n2]]functionn1, N2: Not necessarily exist, generally represents "select the number of lines of action", for example, if my action is required between 10 to 20 rows, then "10,20[Action Behavior" "FUNCTION:A: New, the back of a The strings can be connected, and the strings will appear on a new line (the current next line) ~c: Replace, C can be followed by a string, these strings can replace the line between N1,N2! D: Delete, because it is deleted, so d usually do not take any knock; I: Insert, I can be followed by a string, and these strings will appear on a new line (the current line); P: Print, that is, print out a selected data. Normally p will run with parameter sed-n ~s: Replace, can be directly replaced by work! Usually this s action can be paired with formal notation! For example 1,20s/old/new/g is!

The use of SED commands is often used in conjunction with regular expressions.
The main use of the SED command to modify a file in a row of content
Sed-i "s/^xxx.*$/yyyy/g" file name (modified to yyyy with XXX line included)

Several Linux commands to work with

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.