Chapter 5 study notes of Linux command line and shell script programming

Source: Internet
Author: User
Chapter 2: shell script programming advanced monitoring system Statistical Data System Snapshot Report 1 run time The uptime Command will provide the following basic information: the number of days, hours, average number of users logging on to the system in minutes: 1 minute, 5 minutes, and 15 minutes $ upti

Chapter 2: Advanced shell script programming

Monitoring system Statistics

System Snapshot report

1. run time

The uptime Command provides the following basic information:

Current time

Number of days, hours, and minutes when the system is running

Number of users currently logged on to the system

Average load in 1 minute, 5 minutes, and 15 minutes

$ uptime  16:20:51 up 2 days,  3:11,  9 users,  load average: 0.01, 0.02, 0.05

2. disk usage

$ df -hFilesystem            Size  Used Avail Use% Mounted on/dev/sda1              47G  5.8G   39G  13% /none                  2.9G  244K  2.9G   1% /devnone                  2.9G  5.3M  2.9G   1% /dev/shmnone                  2.9G  456K  2.9G   1% /var/runnone                  2.9G     0  2.9G   0% /var/lock/dev/sda7             197G  141G   47G  76% /home/dev/sdb              459G  338G   98G  78% /home/su1216/android/source/cn3

3. memory usage

The free command displays the total physical memory and the amount of idle memory. The above data of the swap memory, including the kernel buffer, is also displayed.

$ free             total       used       free     shared    buffers     cachedMem:       6025532    5966392      59140          0     967352    1849580-/+ buffers/cache:    3149460    2876072Swap:      2899696     174624    2725072

4. Zombie process

$ ps -alF S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD1 S  1000  2279     1  0  80   0 - 21912 poll_s pts/0    00:00:36 fcitx0 S  1000 27284     1  0  80   0 -  7330 poll_s pts/3    00:00:02 adb0 R  1000 29962  2252  0  80   0 -  2737 -      pts/0    00:00:00 ps

If the S column is in Z state, it is a zombie process, and there is no zombie process on it.

$ ps -al | tr -s ' ' ' ' | cut -d ' ' -f 2,4S PIDS 2279S 27284R 29959S 29960S 29961

Then grep-Z can find the Zombie process and the corresponding PID.

System Statistical Data Report

Vmstat allows you to view the virtual machine status

Output symbol of vmstat

Symbol Description
R Number of processes waiting for CPU time
B Number of processes in non-disruptive sleep
Swpd Total virtual memory used (unit: MB)
Free Total idle physical memory (unit: MB)
Buff Total memory used as a buffer (unit: MB)
Cache Total memory used for cache (unit: MB)
Si Total memory exchanged from the disk (unit: MB)
So Total memory exchanged to the disk (unit: MB)
Bi Number of blocks received from the block device
Bo Number of blocks sent to block devices
In Number of CPU interruptions per second
Cs Number of CPU context switches per second
Us Percentage of CPU time used to execute non-kernel code
Sy Percentage of CPU time used to execute kernel code
Id Percentage of CPU time in idle state
Wa Percentage of CPU time waiting for I/O

When you run vmstat for the first time, it displays the average load value since the last restart.

To obtain the current statistics, you must add the following parameters:

$ vmstat 1 3procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa 0  0 191364 158988 246504 2287404    0    0    64    82   48   17  3  1 96  1 0  0 191364 158888 246504 2287416    0    0     0     0  374  862  2  0 98  0 0  0 191364 158888 246504 2287416    0    0     0     0  360  970  1  0 99  0

Problem tracking database

By default, mysql ignores case sensitivity.

You can use regular expressions in mysql. For example:

Select * from tableA where name REGEXP 'regular expression'

(Note only contains the necessary scripts and there is no new knowledge. for all the scripts, see chapter 27th of the original book)

Repost the following link

My blog address

Http://su1216.iteye.com/

Http://blog.csdn.net/su1216/

Related Article

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.