Linux performance monitoring and Common commands

Source: Internet
Author: User

Linux performance monitoring and Common commands

As a DBA, it is also necessary to have certain Linux server performance monitoring knowledge. Sometimes Oracle database performance problems are caused by server performance bottlenecks. That is to say, from the Oracle perspective, there is almost no waiting or Error Tracking in alert log, however, the system is still slow or the user feedback system response time is significantly different from the normal status at ordinary times. At this time, we will not try the following methods to observe the operating system problems.

Linux server performance monitoring is a very important task for administrators. server running should provide optimal network performance. When the performance suddenly falls below the average, the problem may come from the processes being executed, memory usage, disk performance, network traffic, and CPU load. Therefore, it is important to understand and optimize system performance. The process is to first check the status of the entire system, and then check the specific subsystem.

Linux Server overall performance monitoring:
CPU monitoring
Process Monitoring
Memory monitoring
Network Monitoring
I/o monitoring
 
Performance monitoring methods:
1./proc
The Linux system provides an excellent way for administrators to modify kernel parameters online during system running without re-booting. This is achieved through the/proc Virtual File System. The/proc Virtual File System is a mechanism used between the kernel and the kernel module to send messages to processes. The file system allows interaction with the kernel data structure to obtain interaction information about the kernel and process. Unlike other file systems,/proc exists in the memory rather than in the disk.
/Proc file system files and directories and definitions:
 
Directory Name directory content
Apm Advanced Power Management Information
Cmdline kernel command line
Cpuinfo Cpu Information
Devices available for Devices (Block Devices/character Devices)
Dma channels used by DMA
File systems supported by Filesystems
Interrupts interruption
Ioports I/O port usage
Core impressions of Kcore
Kmsg kernel message
Ksyms kernel symbol table
Loadavg Load Balancing
Locks kernel lock
Meminfo memory information
Misc Miscellaneous
List of Modules loaded by Modules
File System loaded by Mounts
Partition tables recognized by the Partitions System
Rtc real-time clock
Slabinfo Slab pool information
Stat comprehensive statistics Status table
Swaps space utilization
Version kernel Version
Uptime system normal running time
 
 
Not all of these directories are available in your system, depending on your Kernel configuration and loaded modules. In addition, there are three important directories in/proc: net, scsi, and sys. The Sys directory is writable and can be used to access or modify kernel parameters (see the following section). net and scsi depend on Kernel configurations. For example, if the system does not support scsi, the scsi directory does not exist.
 
In addition to the above descriptions, there are also some directories named by numbers, which are process directories. Each process currently running in the system has a corresponding directory under/proc, with the process PID as the directory name. They are interfaces for reading process information. The self directory is an interface for reading information about the process itself and a link. The name of the Proc file system starts from. The process directory structure is as follows:
Cmdline command line parameters
Environ environment variable value
Fd A directory containing all file descriptors
Memory utilization of Mem Process
Stat Process status
The current Status of the Status process, which is displayed as readable.
Cwd current working directory Link
Exe points to the execution command file of the process
Maps memory image
Statm process memory status information
Root link to the root directory of the process
 
To view system information, run the cat command. For example:
# Cat/proc/interrupts
 
To change the kernel parameters, you only need to use the echo parameter to redirect to the file. However, you must be careful because it may cause system crashes. It is best to first find an irrelevant machine and apply it to your system after successful debugging. The following is an example:
# Cat/proc/sys/fs/file-max
4096
# Echo 8192>/proc/sys/fs/file-max
# Cat/proc/sys/fs/file-max
8192
If you have optimized the parameters, you can add them to the rc. local file so that they are automatically modified when the system starts.
 
 
Proc Virtual File System functions:
1. Process Information: any process in the system has a process ID of the same name in the corresponding sub-directory. You can find zooline, mem, root, stat, statm, status.
2. System Information: If you need to know the complete bear information, you can obtain it from the/proc/stat file. This includes cpu usage, disk space, Memory Page, memory redemption, interruption, switch, and auto-lifting time.
3. CPU information: The/proc/cpuinfo file can be used to obtain the current accurate cpu information.
4. Load information:/proc/loadavg contains the system load information.
5. Memory information: meminfo contains detailed information about the system memory. The number of physical memory, available swap space, and idle memory are displayed.
 
Monitoring System Load
 
1. Use the uptime command
You can use the uptime command to view the system load. The average system load is defined as the average number of processes in the queue during a specific interval. If a process does not wait for the results of the I/o operation and actively enters the waiting status, it is located in the running queue.
[Root @ kt-db2 proc] # uptime
00:51:59 up 49 days, 3 users, load average: 7.04, 7.83, 9.44
The above shows that the average system load in the last minute is 7.04, the average load in the last five minutes is 7.83, and the average load in the last 15 minutes is 9.44.
 
2. ps command
Linux provides ps and top tools to view system process information. With these system calls, you can clearly understand the running status of processes and take measures to ensure the performance of the linux system. They are currently the most common tool for viewing Process status. They are installed and used together with the linux release. The following is an example of ps command output.

PID: process ID
% CPU: CPU load
% MEM: memory usage percentage
VSZ (Virtual Memory Size): Memory address space occupied by a process
RSS (Resident Set Size): The actual memory address space occupied by the Process
 
Note: RSS includes the memory occupied by the shared library, such as libc. We can use the pmap command to see the memory occupied by various libraries called by the process:
Pmap-d pid

 
The r-x part belongs to the code segment and is shared among processes. Rw --- belongs to the data segment. This is the memory actually used by this process.
TTY: Secondary terminal number
STAT: Process status
START: START process time
TIME: cpu time consumed by processes
COMMAND: process name
 
3. Monitor memory usage
Use the free command to monitor memory usage:

 

The unit of the preceding numbers is KB, with 32 GB total memory and 30 GB swap space. The physical memory is displayed in the third row. The Free column displays unused memory, shared memory, and buffers displays cache. By default, the unit is k. You can specify the-m parameter and use the unit of M for statistics. The watch command and the free command are combined to monitor memory usage in Real Time:
# Watch-n 1-d free

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.