In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces to you what the basic commands of Linux process and memory are, the content is very detailed, interested friends can refer to it, I hope it can be helpful to you.
Computers exist to run all kinds of programs. Most of the commands we have introduced so far are programs written in programming languages to complete certain calculations, which are stored in the operating system in the form of files (such as commands under / bin). However, static programs cannot produce results "spontaneously". Only by assigning input data to it in the operating system and running it can we get the output results. The most important form of program running in the operating system is the process.
Static programs can exist for a long time, and dynamic processes have a limited life cycle. At the beginning of each program run (such as typing a command and pressing enter), the operating system prepares a variety of resources for the program to run, most of which are in memory. In order to limit the permissions of multi-user processes, linux also defines two process run tenses: kernel mode and user mode. When a process wants to request a system service (such as operating a physical device), it must be achieved through a system call (an interface function provided by the operating system to the user space). At this time, the system switches to the kernel state and executes the system call on behalf of the program. after execution, the system switches back to the user state and continues to execute the program code.
The editor introduces the management commands about processes and memory in linux (more about viewing commands).
1. Running time of uptime system
Uptime [options]
When executing this command alone, the output information indicates: the current time, the length of time the system has been running, the number of logged in users, and the average load of the system in the past 1, 5, 15 minutes.
[root@centos7] # uptime 10:46:38 up 58 days, 19:20, 3 users, load average: 0.00,0.01,0.05
2. Ps displays system process information
Ps [options]
The information displayed when running the ps command separately is: process ID number (PID), terminal (TTY), cumulative CPU running time (TIME), command name (CMD)
[root@centos7 ~] # ps PID TTY TIME CMD 9503 pts/1 00:00:00 bash 9570 pts/1 00:00:00 ps
Here is a brief description of the relationship between processes, process groups, sessions, and terminals. In order to facilitate the management of processes in linux operating system, processes with similar functions or father-son or sibling relationships are grouped into a group. Each process must belong to one process group and can only belong to one process group. In addition to the process ID, a process has a process group ID (PGID); each process group has a process group leader whose PID is the same as the process group ID. Just as a series of related processes can be merged into process groups, a series of process groups can be merged into a session session. The session is established by the process within it, which is called the session leader of the session. The PID of the session header process is the SID (session ID) of this session. Each session starts when the user logs in and ends when the user exits. Each process group in a session is called a job. A session can have one process consisting of foreground work (foreground) for the session, while other process groups are background work (background). Each session is associated with a control terminal control terminal. When the session terminates (the user exits the terminal), the system sends a termination signal (SIGHUP) to all process groups in the session. The default way for the process to handle this signal is to terminate the process.
Ps accepts options in three formats: UNIX with a prefix symbol; BSD without a prefix; and GNU with two-long formats. The three types of options can be combined freely, but there may be conflicts.
Option a (BSD) displays all process information associated with the terminal, and when used with option x (BSD), all process information is displayed (the terminal-independent process TTY column is displayed as?).
The option-a (UNIX) indicates that process information other than the session header process associated with the terminal is displayed. The option-e represents all processes.
[root@centos7 ~] # ps a PID TTY STAT TIME COMMAND 2528 tty1 Ss+ 0:00-bash 9336 pts/0 Ss 0:00-bash 9503 pts/1 Ss 0:00-bash 9550 pts/2 Ss+ 0:00-bash 9571 pts/0 S + 0:00 man ps 9582 pts/0 S + 0:00 less-s 9643 pts/1 R + 0:00 ps a [root@centos7] # ps-a PID TTY TIME CMD 9571 pts/0 00:00:00 man 9582 pts/0 00:00:00 less 9644 pts/1 00:00:00 ps
As shown in the example, the BSD-style option also displays the status information of the process and the parameters of the command. The states that a process may be in while running include:
D uninterruptible sleep state (usually waiting for IO) R is running or can run (in the run queue) S interruptible sleep state (waiting for an event to complete) T pause state t tracking state W page status (kernel version later) X dead state (invisible) Z zombie state # BSD-style option STAT column may also include the following characters
< 高优先级进程 N 低优先级进程 L 锁定状态 s 会话首进程 l 多线程进程 + 进程处于前台进程组 选项u显示用户导向的进程信息(如进程的发起用户,用户态占用CPU和MEM百分比等) [root@centos7 ~]# ps au USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2528 0.0 0.0 115636 2384 tty1 Ss+ 9月30 0:00 -bash root 9336 0.0 0.0 115596 2240 pts/0 Ss 08:44 0:00 -bash root 9571 0.0 0.0 119196 1972 pts/0 S+ 10:59 0:00 man ps root 9582 0.0 0.0 110276 980 pts/0 S+ 10:59 0:00 less -s root 9835 0.0 0.0 115636 2172 pts/1 Ss 13:48 0:00 -bash root 9938 0.0 0.0 115512 2096 pts/2 Ss 14:49 0:00 -bash root 9960 0.0 0.0 154068 5632 pts/2 S+ 14:50 0:00 vim others.sh root 9967 0.0 0.0 139496 1640 pts/1 R+ 14:59 0:00 ps au VSZ表示占用的总的地址空间大小。它包括了没有映射到内存中的页面。 RSS表示实际驻留"在内存中"的内存大小,不包括交换出去的内存。和VSZ的单位均为KB 通常查看所有进程信息会使用命令ps -ef或ps aux 选项-o或o表示指定输出格式 如显示所有bash进程的pid,命令名,运行于哪颗逻辑cpu: [root@centos7 ~]# ps -eo pid,comm,psr|grep bash 2528 bash 1 9336 bash 4 9835 bash 3 9938 bash 6 配合选项--sort可指定按某一列排序输出 #表示按用户名排序 ps -eo pid,user,args --sort user 还可以用-o指定许多其他信息,请查询相关手册。 3、kill 终止进程 kill [options] pid... 命令kill会发送特定的信号给指定的进程或进程组,如果没有指定信号,则发送TERM信号 选项-l表示列出所有支持的信号: [root@centos7 ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX [root@centos7 ~]# 可以使用选项-s指定要发送的信号 如在一个终端启动进程sleep 300,在另一个终端查看并使用信号SIGKILL将其终止: [root@centos7 ~]# sleep 300 #此时会一直等待sleep执行完毕 #在另一个终端中 [root@centos7 temp]# ps -ef|grep [s]leep root 10359 9835 0 12:05 pts/1 00:00:00 sleep 300 #发送信号 [root@centos7 temp]# kill -s SIGKILL 10359 #原终端显示 [root@centos7 ~]# sleep 300 已杀死 [root@centos7 ~]# 或者执行命令kill -9 10359是同样的效果。关于其他信号的作用,请自行搜索。 4、pgrep和pkill 搜索或者发送信号给进程 pgrep [options] pattern pkill [options] pattern 这里的pattern是正则表达式,用来匹配进程名 如查看名称为gunicorn的所有进程 [root@centos7 ~]# pgrep gunicorn 17268 17286 17289 17290 17293 选项-l显示进程名和pid [root@centos7 ~]# pgrep -l gun 17268 gunicorn 17286 gunicorn 17289 gunicorn 17290 gunicorn 17293 gunicorn 如终止所有sleep进程 pkill sleep 如使syslogd重读它的配置文件 pkill -HUP syslogd 5、top 显示进程信息 top命令实时动态的显示系统汇总信息和进程状态信息,它每隔1s刷新一次,按键盘q键退出。 单独执行top命令时显示如下输出: top - 03:20:02 up 59 days, 17:30, 3 users, load average: 0.00, 0.01, 0.05 Tasks: 184 total, 1 running, 183 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.1 us, 0.0 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 8010720 total, 5100308 free, 420652 used, 2489760 buff/cache KiB Swap: 8257532 total, 8257532 free, 0 used. 6905944 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 193664 8708 2396 S 0.0 0.1 1:23.98 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.44 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.10 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root rt 0 0 0 0 S 0.0 0.0 0:00.34 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/0 10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcuob/1 下面分别对每行输出内容进行解释(注:top版本为3.3.10,其他版本的输出第四行和第五行可能不同) ***行显示信息和命令uptime的输出一致; 第二行显示任务汇总信息,状态即为进程可能状态中的四种; 第三行显示cpu负载信息,其中us表示用户态任务占用CPU时间百分比,sy表示内核态任务占用CPU时间百分比,ni表示改变过进程优先级的进程(通过nice或renice命令)占用CPU时间百分比,id表示CPU空闲时间百分比,wa表示等待输入输出的进程占用CPU时间百分比,hi表示硬件中断花费时间,si表示软件中断花费时间,st表示虚拟机等待真实物理机CPU资源的时间 第四行显示内存信息,total表示总内存,free表示未分配内存,used表示使用的内存(值为total-free-buff/cache的结果),buff/cache表示缓存内存; 第五行显示交换分区使用量,其中avail Mem表示启动一个新程序时可以分配给它的***内存,和第三行free列不同的地方在于,它会统计可以被回收的缓存分配器(slab)和页高速缓冲存储器(page cache)中的内存。(在一些较早的top实现中,并没有这一列的值) 接下来经过一个空行之后,显示的是进程相关信息,表头各列字段和ps命令的输出均有相对应的关系,其中PR表示优先级;NI表示nice值(后述);VIRT表示虚拟内存大小,对应ps命令中的VSZ;RES表示进程常驻内存大小,对应ps命令中的RSS;SHR表示共享内存大小;S表示进程状态,对应ps命令的STAT; linux系统的进程状态中有一个优先级(priority)的概念,其值是一个动态变化的整数,范围是0-139,此值越小,则优先级越高,那么它就越优先被CPU执行。如果top命令PR列显示为rt,表示此进程为实时进程,它的优先级范围是0-99,比其他的普通进程都要高。linux中还有静态优先级的概念,用户可以通过使用命令nice和renice对进程设置或改变静态优先级,它可以看成是动态优先级的修正值,能够影响动态优先级的值。 PR列显示的值为实际优先级减去实时进程***优先级之后的值,3.10内核非实时进程的默认值为20,即:DEFAULT_PRIO = MAX_RT_PRIO + 20 = 120 NI列不为0时,表示进程被设置过静态优先级值,范围是-20到19,它与当前优先级值的关系是:DEFAULT_PRIO = MAX_RT_PRIO + (nice) + 20 如使用nice启动一个sleep进程: #当不使用选项-n指定时,默认值为10 [root@centos7 ~]# nice -n -10 sleep 300 #对于已存在的进程可以使用renice命令调整其静态优先级 [root@centos7 ~]# [root@centos7 ~]# ps -eo pri,ni,comm|grep sleep 29 -10 sleep [root@centos7 ~]# [root@centos7 ~]# top -bn1 |egrep 'COMMAND$|sleep$' PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11967 root 10 -10 107892 616 528 S 0.0 0.0 0:00.00 sleep #注意这里ps和top优先级值显示的不同,ps命令pri列的值 29 = MAX_PRIO(139) - MAX_RT_PRIO(100) + nice(-10)。它们实际的优先级值是相等的。 上例中使用了选项-n表示top刷新次数,-b表示批处理模式运行top,此模式会去掉输出中的控制字符,方便将输出交给其他程序处理。 选项-o fieldname按指定列排序输出,选项-O可以列出-o能够指定的列名 #自行执行命令查看效果 top -O |tr '\n' ' ' top -bn1 -o PR 下面简要介绍一些top中可以使用的交互命令: q 退出top h 获得帮助信息 1 显示每个逻辑cpu的信息 k 终止一个进程(会提示用户输入需要终止的pid,以及需要发送什么样的信号) r 重新设置进程静态优先级(相当于执行renice) i 忽略闲置和僵死进程 H 显示线程信息 M 根据驻留内存大小排序 P 根据CPU使用百分比排序 W 将当前设置写入~/.toprc文件中 6、free 显示系统内存使用情况 free [options] free命令显示系统当前内存、swap(交换分区)的使用情况,默认单位是KB #版本3.3.10 [root@centos7 ~]# free total used free shared buff/cache available Mem: 8010720 423060 4540476 375580 3047184 6897052 Swap: 8257532 0 8257532 显示信息和top命令输出中的对应值一致,其中shared表示内存文件系统(tmpfs)中使用内存的大小。 前面讲述了available对应值所表示的含义,通常查看系统当前还有多少可用内存,看available的对应值就可以了。这里available = free + 缓存(可被回收部分)。 但在较老版本的free中并没有这个值,它的输出可能是这样的: total used free shared buffers cached Mem: 8174384 4120488 4053896 0 229320 1041712 -/+ buffers/cache: 2849456 5324928 Swap: 16779884 0 16779884 说明: buffer(缓冲) 是为了提高内存和硬盘(或其他I/O设备)之间的数据交换的速度而设计的 cache(缓存) 是为了提高cpu和内存之间的数据交换速度而设计的 所以输出中buffers可简单理解为准备写入硬盘的缓冲数据;cached可理解为从硬盘中读出的缓存数据(页高速缓冲存储器),缓存中可被回收部分来自cached和slab(缓存分配器) Mem行:used = total - free此时的空闲内存free列并不能体现系统当前可用内存大小 -/+ buffers/cache行:used = total - free(Mem) - (buffers + cached),这里的free列和前面所述的available关系为available = free + 缓存(可被回收部分) 所以当没有available列可查看时,并不能通过free命令查到或计算出真正可用内存,需要知道缓存部分的具体情况。 选项-b、-k、-m、-g分别表示指定各值的单位:bytes, KB, MB, 或者 GB 7、fuser 使用文件或套接字定位进程 fuser经常用来查看文件被哪些进程所使用 [root@centos7 ~]# fuser . /root: 2528c 11430c 11447c 例子表示显示有三个进程在使用当前目录,其中:2528c 前面数字表示进程PID,后面的字符c表示当前目录(即进程在此目录下工作),还可能出现的字符有: e 表示进程正在运行执行文件 f 打开文件,默认输出时省略 F 写方式打开文件,默认时输出省略 r 根目录 m mmap文件或共享库文件 选项-k表示发送信号SIGKILL给相关进程(谨慎使用) 选项-i表示交互,在kill一个进程之前询问用户 选项-l列出支持的信号 选项-SIGNAL指定信号 8、lsof 列出打开文件 在这一篇中我们简单描述了bash进程打开的前三个文件,并分别关联到文件描述符0,1,2。对于其他进程打开的文件也是同样,系统为每个进程维护一个文件描述符表,该表的值都是从0开始的数字。单独执行lsof命令时会显示系统中所有进程打开的文件 #命令版本为4.87 [root@centos7 temp]# lsof |head COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME systemd 1 root cwd DIR 253,0 4096 128 / systemd 1 root rtd DIR 253,0 4096 128 / systemd 1 root txt REG 253,0 1489960 6044 /usr/lib/systemd/systemd systemd 1 root mem REG 253,0 20032 201329002 /usr/lib64/libuuid.so.1.3.0 systemd 1 root mem REG 253,0 252704 201330338 /usr/lib64/libblkid.so.1.1.0 systemd 1 root mem REG 253,0 90632 201328968 /usr/lib64/libz.so.1.2.7 systemd 1 root mem REG 253,0 19888 201329137 /usr/lib64/libattr.so.1.1.0 systemd 1 root mem REG 253,0 19520 201328509 /usr/lib64/libdl-2.17.so systemd 1 root mem REG 253,0 153192 201328867 /usr/lib64/liblzma.so.5.0.99 每行一个打开的文件,表头各列意为: COMMAND 进程命令名前9个字符 PID 进程ID TID 任务ID FD 1)文件描述符号或者下面字符: cwd 当前工作目录 err FD错误信息 ltx 共享库代码 mem 内存映射文件 mmap 内存映射设备 pd 父目录 rtd 根目录 txt 程序代码 2)当是FD(数字)时,后面可能跟下面权限字符: r 读 w 写 u 读写 空格 权限未知且无锁定字符 - 权限未知但有锁定字符 3)权限字符后可能有如下锁定字符: r 文件部分读锁 R 整个文件读锁 w 文件部分写锁 W 整个文件写锁 u 任意长度读写锁 U 未知类型锁 空格 无锁 TYPE 类型,可能值为: DIR 目录 REG 普通文件 CHR 字符设备文件 BLK 块设备文件 FIFO 管道文件 unix UNIX套接字文件 IPv4 IPv4套接字文件 .... DEVICE 设备号 SIZE/OFF 文件大小或偏移量(bytes) NODE 文件inode号 选项-n表示不做ip到主机名的转换 选项-c string显示COMMAND列中包含指定字符的进程所有打开的文件 选项-u username显示所属user进程打开的文件 选项-d FD显示打开的文件描述符为FD的文件 [root@centos7 ~]# lsof -d 4 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME systemd 1 root 4u a_inode 0,9 0 5755 [eventpoll] systemd-j 539 root 4u unix 0xffff880230168f00 0t0 10467 /run/systemd/journal/socket systemd-u 549 root 4u unix 0xffff88003693d640 0t0 12826 /run/udev/control lvmetad 555 root 4wW REG 0,18 4 8539 /run/lvmetad.pid auditd 693 root 4w REG 253,0 701364 208737917 /var/log/audit/audit.log .... 选项+d DIR显示目录中被进程打开的文件 选项+D DIR递归显示目录中被进程打开的文件 [root@centos7 ~]# lsof +d /root|head -3 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME bash 2528 root cwd DIR 253,0 4096 201326721 /root bash 12902 root cwd DIR 253,0 4096 201326721 /root 选项-i表示显示符合条件的进程打开的文件,格式为[46][protocol][@hostname|hostaddr][:service|port] #查看22端口运行情况 [root@centos7 ~]# lsof -ni :22 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1358 root 3u IPv4 8979 0t0 TCP *:ssh (LISTEN) sshd 1358 root 4u IPv6 8981 0t0 TCP *:ssh (LISTEN) sshd 12900 root 3u IPv4 3509687 0t0 TCP 10.0.1.254:ssh->192.168.78.143 57325 (ESTABLISHED) # example Smtp is one of the services listed in the / etc/services file [root@centos7 ~] # lsof-ni 4TCP@0.0.0.0:22 Smtp COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1358 root 3U IPv4 8979 0t0 TCP *: ssh (LISTEN) master 2162 root 13u IPv4 16970 0t0 TCP 127.0.0.1:smtp (LISTEN) sshd 12900 root 3u IPv4 3509687 0t0 TCP 10.0.1.254 0t0 TCP SSH-> 192.168.78.143 Fren 57325 (ESTABLISHED)
Imagine if you delete a file that is being opened by another process. Experiment to see the phenomenon:
# use more command to view a file [root@centos7 ~] # more / root/.bash_history # use lsof to view [root@centos7 ~] # lsof on another terminal | grep ^ more more 14470 root cwd DIR 253 0 4096 201326721 / root more 14470 root rtd DIR 253 more 14470 root txt REG 253,0 41096 134321844 / usr/bin/more more 14470 root mem REG 253,0 106065056 134319094 / usr/lib/locale/locale-archive more 14470 root mem REG 253,0 2107816 201328503 / usr/lib64/libc-2.17.so more 14470 root mem REG 253,0 174520 201328905 / usr/lib64/libtinfo.so.5 . 9 more 14470 root mem REG 253,0 164440 225392061 / usr/lib64/ld-2.17.so more 14470 root mem REG 253,0 272001 67147302 / usr/share/locale/zh_CN/LC_MESSAGES/util-linux.mo more 14470 root mem REG 253,0 26254 201328839 / usr/lib64/gconv/gconv-modules.cache More 14470 root 0u CHR 136,1 0t0 4 / dev/pts/1 more 14470 root 1u CHR 136,1 0t0 4 / dev/pts/1 more 14470 root 2u CHR 136,1 0t0 4 / dev/pts/1 more 14470 root 3r REG 253root 0 17656 202386313 / root/.bash_history # Delete this file [root@centos7 ~] # rm-f / root/.bash_history # View [root@centos7 ~] # lsof-d 3 | grep ^ more more 14470 root 3r REG 253 authoring 0 17656 202386313 / root/.bash_history (deleted) [root@centos7 ~] # # you will find that the file column contains the word delete
The / proc directory in the linux system stores all the data related to the process of the system, and the name of the digital directory in it is PID. Let's take a closer look at the file descriptor of the more process just now
[root@centos7 ~] # cat / proc/14470/fd/3 > / root/.bash_history.bak # this operation saves the contents of file descriptor 3 to / root/.bash_history.bak # stop the more process and view [root@centos7 ~] # ls-l / root/.bash_history*-rw-r--r-- 1 root root 17656 November 30 07:47 / root/.bash_history.bak [root@centos7 ~] # cat / Root/.bash_history.bak # will find that the original file is gone The new file saves all the contents of the original file
The conclusion is that if a process is opening a file when it is deleted, the contents of the file can still be recovered through the process's corresponding file descriptor. At the same time, if you delete a file and find that the space has not been released, it means that a process is opening the file (command lsof | grep delete view). After restarting the process, the space will be released.
9. Iostat displays the statistical information of CPU and Iamp O
[root@centos7 ~] # iostat Linux 3.10.0-327.el7.x86_64 (centos7) 30 November 2016 _ x8634 _ (8 CPU) avg-cpu:% user% nice% system% iowait% steal% idle 0.12 0.00 0.03 0.00 99.85 Device: tps kB_read/s kB_wrtn/s kB_read KB_wrtn sda 0.23 0.79 3.05 4178309 16079082 dm-0 0.22 0.57 2.94 3002207 15480498 dm-1 0.00 0.00 0.00 1088 0 dm-2 0.03 0.22 0.11 1146430 596232 dm-3 0.06 0.01 1.91 28900 10079073 dm-4 0.03 0.01 1.91 28644 10079073
The cpu part of the display information is explained in the description of the command top. The tps O part is the information about the read and write rate and total amount of each device, where tps indicates the number of Imax O requests per second.
Option-c to display CPU information
Option-d displays device information
Option-x displays more detailed information
The command iostat m n number (m < n), m represents the interval, n represents the number of times; in this case, iostat will print once every m seconds, n times.
[root@centos7] # iostat-c 1 3 Linux 3.10.0-327.el7.x86_64 (centos7) November 30, 2016 _ x86 CPU 648 avg-cpu:% user% nice% system% iowait% steal% idle 0.12 0.00 0.03 0.00 99.85 avg-cpu:% user% nice% system% iowait% steal% idle 0.12 0.00 0.00 0.00 99.88 avg-cpu:% user% nice% system% iowait% steal% idle 0.12 0.00 0.00 0.00 99.75
You can also contact the device name to view the Icano information of the specified device.
[root@centos7 ~] # iostat sda Linux 3.10.0-327.el7.x86_64 (centos7) 30 November 2016 _ x8634 _ (8 CPU) avg-cpu:% user% nice% system% iowait% steal% idle 0.12 0.00 0.03 0.00 99.85 Device: tps kB_read/s kB_wrtn/s kB_ Read kB_wrtn sda 0.23 0.79 3.05 4178309 16084862
10. Vmstat displays virtual memory statistics
Vmstat [options] [delay [count]]
It will also display some information about CPU and iCompo.
Option-w formatted output
[root@centos7] # vmstat-w procs-memory-- swap---io-----system---cpu- r b swpd free buff cache Si so bi bo in cs us sy id wa st 100 4517628 3184 3067904 00 0 1 100 0 100 00
Among them
Procs r represents the number of runnable processes b represents the number of uninterruptible sleep processes memory swpd virtual memory usage free free memory buff buffer buffer memory usage cache memory usage swap si hard disk swap to memory so memory swap to hard disk io bi number of blocks (blocks) received from the block device Number of blocks sent by bo to block devices system in interrupts per second Including locks. Cs the number of process context switches per second. Cpu (same as command top) percentage of CPU time occupied by us user mode tasks percentage of CPU time occupied by sy kernel state tasks percentage of id CPU idle time percentage of CPU time occupied by processes waiting for input and output st virtual machine time spent waiting for real physical machine CPU resources
Option-m displays slab information
Option-s displays various memory counters and their information
The option-d displays the disk Ibank O information
Option-p device displays device partition details iPot O information
Like iostat, it also supports printing times by frequency.
11. Mpstat displays CPU-related information
Mpstat [options] [interval [count]]
Display information is similar to the top command
[root@centos7] # mpstat 12 Linux 3.10.0-327.el7.x86_64 (centos7) November 30, 2016 _ x8616648 CPU 09:18:19 CPU% usr% sys% iowait% irq% soft% steal% guest% gnice% idle 09:18:20 all 0.12 0.00 0.00 0.00. 00 0.00 0.00 0.00 99.88 09:18:21 all 0.12 0.00 0.00 0.00 99.75 average time: all 0.12 0.00 0.06 0.00 0.00 0.00 99.81
Option-A displaying all CPU and interrupt information is equivalent to executing mpstat-I ALL-P ALL
Option-I {SUM | CPU | SCPU | ALL} displays interrupt information
Option-P {cpu [,...] | ON | ALL} displays CPU information
[root@centos7] # mpstat-P 3Power5 Linux 3.10.0-327.el7.x86_64 (centos7) 30 November 2016 _ x86q648 CPU 09:29:03 CPU% usr% sys% iowait% irq% soft% steal% guest% gnice% idle 09:29:03 3 0.15 0.00 0.04 0.00 0.00 0.00 0.00 0.00 99.81 09:29:03 5 0.11 0.00 0.03 0.00 0.00 0.00 99.86 basic commands about Linux process and memory are shared here I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.