色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
电子发烧友
开通电子发烧友VIP会员 尊享10大特权
海量资料免费下载
精品直播免费看
优质内容免费畅学
课程9折专享价
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Linux查看資源使用情況和性能調(diào)優(yōu)常用的命令

Q4MP_gh_c472c21 ? 來源:嵌入式ARM ? 作者:嵌入式ARM ? 2020-11-12 17:54 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

目錄

前言

top命令

htop命令

ps命令

free命令

vmstat命令

iosat命令

netstat命令

df命令

du命令

前言

一般來說,Linux性能調(diào)優(yōu)涉及CPU、內(nèi)存和 IO,包括進程、線程、程序堆棧、內(nèi)存、Swap、CPU調(diào)度、內(nèi)存調(diào)度、網(wǎng)絡(luò)連接和IO讀寫等。

本文介紹了Linux查看資源使用情況和性能調(diào)優(yōu)常用的命令,包括top、htop、ps、free、vmstat、iostat、netstat、df和du命令。

top命令

top命令用來監(jiān)控系統(tǒng)的資源使用情況,包括CPU、內(nèi)存、Swap、進程和線程等。

命令:

#運行top top #顯示進程的完整命令 top-c

推薦使用下面的htop命令來代替top命令。

htop命令

htop命令用來監(jiān)控系統(tǒng)的資源使用情況,包括CPU、內(nèi)存、Swap、進程和線程等。相比top命令,htop命令更能更強大,顯示也更加直觀。

命令:

#運行htop htop

概要信息說明:

CPU使用率:數(shù)字1、2、...表示CPU有幾個核,后面的進度條用不同顏色來表示不同維度的CPU使用率,最后是CPU使用率;

內(nèi)存使用率:Mem后面的進度條用不同顏色來表示不同維度的內(nèi)存使用率(綠色:used,藍色:buffers,橙色:cache),最后是內(nèi)存使用率(used / total);

Swap使用率:Swap后面的進度條顯示已用的Swap,最后是Swap使用率(used / total),如果系統(tǒng)關(guān)閉了Swap,則進度條為空,Swap使用率為0K/0K;

進程和線程統(tǒng)計:Tasks:進程數(shù),thr:線程數(shù),running:正在運行的進程數(shù);

系統(tǒng)平均負載統(tǒng)計:Load average:前1分鐘平均負載、前5分鐘平均負載和前15分鐘平均負載;負載越低說明CPU越空閑,負載越高說明CPU越忙:

負載低于0.7 * CPU核數(shù):CPU使用率正常;(道路通暢)

負載高于0.7 * CPU核數(shù):CPU使用率較高,需要關(guān)注;(道路堵車,需要交警到場疏導(dǎo)交通)

負載高于1 * CPU核數(shù):CPU使用率過高,需要關(guān)注;(道路嚴重堵車,可能發(fā)生了交通事故,需要交警馬上到現(xiàn)場處理)

負載高于5 * CPU核數(shù):系統(tǒng)超負荷運轉(zhuǎn),無法正常響應(yīng);(交通癱瘓,可能道路已經(jīng)被水淹無法通行,需要投入搶險力量恢復(fù)交通)

系統(tǒng)已連續(xù)運行時間:Uptime后面為系統(tǒng)從上次啟動后,已連續(xù)運行時間,可以倒推系統(tǒng)上次啟動時間;

詳細信息說明:

PID:進程ID;

USER:進程所有者;

PRI:進程優(yōu)先級;

NI:nice值,負值表示高優(yōu)先級,正值表示低優(yōu)先級;

VIRT:進程使用的虛擬內(nèi)存(virtual memory);

RES:進程使用的物理內(nèi)存(physical memory);

SHR:進程使用的共享內(nèi)存(shared memory);

S:進程狀態(tài),R(Running)正在運行的進程、S(Sleeping)休眠的進程、T/S(Traced/Stopped) 已停止或中止的進程 或 Z(Zommbie)僵尸進程;

CPU%:進程使用的CPU時間百分比;

MEM%:進程使用的內(nèi)存百分比;

TIME+:進程已連續(xù)運行時間;

Command:進程的執(zhí)行命令;

常用快捷鍵:

上下箭頭:上下滾動查看進程;

u:顯示指定用戶的進程;

P:按照進程使用的CPU時間百分比排序;

M:按照進程使用的內(nèi)存百分比排序;

T:按照進程已連續(xù)運行時間排序;

參考:

https://linuxtogether.org/htop-command-explanation/

https://www.softprayog.in/tutorials/htop-command-in-linux

https://scoutapm.com/blog/understanding-load-averages

htop官網(wǎng)

ps命令

#查看java進程 #e(every)所有進程 #f(fullformat)完整輸出格式 ps-ef|grepnginx #不顯示grep本身 ps-ef|grepnginx|grep-vgrep #獲取指定進程的PID ps-ef|grepjava|grepjenkins|grep-vgrep|awk'{print$2}' #根據(jù)進程的PID中止進程 ps-ef|grepjava|grepjenkins|grep-vgrep|awk'{print$2}'|xargskill-9 #查看進程堆棧 #p(path)顯示完整路徑 pmap-p #查看9091端口是哪個容器進程 dockerps|grep9091

ps -ef格式:

UID:進程的UID(用戶)

PID:進程ID

PPID:父進程ID

C:CPU使用時間百分比

STIME

TTY

TIME

CMD:啟動進程的命令

free命令

free命令用來查看內(nèi)存和Swap的使用情況。

命令:

#以適合閱讀的形式輸出(h:human) free-h #以MB格式輸出(m:MB) free-m #合計Mem和Swap(t:total) free-h-t #統(tǒng)計3次,每秒1次(c:count) free-h-c3 #統(tǒng)計5次,每2秒統(tǒng)計1次(s:second) free-h-t-c5-s2

說明:

Total: The amount of RAM installed in your system.

Used: Equal toTotal-(Free+Buffers+Cache).

Free: The amount of memory completely unused by anything.

Shared: Memory taken by thetmpfsfile systems.

Buffer: The data structures that are maintained to provide an index for everything stored inCache.

Cache: Data read from the hard drive, modified data waiting to be written back to the hard drive, and other computed values.

Available: What’s really free. An estimate of the memory inFree,Buffer, andCachethat could be used to satisfy a memory request.

簡單來說,total是系統(tǒng)總內(nèi)存,used就是系統(tǒng)已用內(nèi)存,total - used 就是系統(tǒng)可用內(nèi)存。

參考:

https://www.howtogeek.com/456943/how-to-use-the-free-command-on-linux/

vmstat命令

vmstat命令用來統(tǒng)計進程、內(nèi)存、Swap、IO和CPU等信息。

命令:

#運行vmstat vmstat #每5秒統(tǒng)計1次 vmstat5 #每5秒統(tǒng)計1次,共統(tǒng)計4次 vmstat54 #以MB格式輸出內(nèi)存使用情況 vmstat54-SM #顯示統(tǒng)計概要信息 vmstat-s

說明:

Proc

r: The number of runnable processes. These are processes that have been launched and are either running or are waiting for their next time-sliced burst of CPU cycles.

b: The number of processes in uninterruptible sleep. The process isn’t sleeping, it is performing a blocking system call, and it cannot be interrupted until it has completed its current action. Typically the process is a device driver waiting for some resource to come free. Any queued interrupts for that process are handled when the process resumes its usual activity.

Memory

swpd: the amount of virtual memory used. In other words, how much memory has been swapped out.,

free: the amount of idle (currently unused) memory.

buff: the amount of memory used as buffers.

cache: the amount of memory used as cache.

Swap

si: Amount of virtual memory swappedinfrom swap space.

so: Amount of virtual memory swappedoutto swap space.

IO

bi: Blocks received from a block device. The number of data blocks used to swap virtual memory back into RAM.

bo: Blocks sent to a block device. The number of data blocks used to swap virtual memory out of RAM and into swap space.

System

in: The number of interrupts per second, including the clock.

cs: The number of context switches per second. A context switch is when the kernel swaps from system mode processing into user mode processing.

CPU

These values are all percentages of the total CPU time.

us: Time spent running non-kernel code. That is, how much time is spent in user time processing and in nice time processing.

sy: Time spent running kernel code.

id: Time spent idle.

wa: Time spent waiting for input or output.

st: Time stolen from a virtual machine. This is the time a virtual machine has to wait for the hypervisor to finish servicing other virtual machines before it can come back and attend to this virtual machine.

參考:

https://www.howtogeek.com/424334/how-to-use-the-vmstat-command-on-linux/

https://www.tecmint.com/linux-performance-monitoring-with-vmstat-and-iostat-commands/

iosat命令

iostat命令用來統(tǒng)計磁盤IO和CPU等信息。

命令:

#運行iostat iostat #以MB格式輸出 iostat-m #查看指定磁盤(分區(qū)) iostat-m-pvda #每2秒統(tǒng)計一次,共統(tǒng)計3次 iostat-m23

說明:

CPU信息:

%user :It shows the percentage of CPU being utilization that while executing at the user level.

%nice :It shows the percentage of CPU utilization that occurred while executing at the user level with a nice priority.

%system :It shows the percentage of CPU utilization that occurred while executing at the system (kernel) level.

%iowait :It shows the percentage of the time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.

%steal :It shows the percentage of time being spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing by another virtual processor.

%idle :It shows the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.

磁盤信息:

Device :The device/partition name is listed in/devdirectory.

tps :The number of transfers per second that were issued to the device. Higher tps means the processor is busier.

Blk_read/s :It shows the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second.

Blk_wrtn/s :The amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second.

Blk_read :It shows the total number of blocks read.

Blk_wrtn :It shows the total number of blocks written.

參考:

https://www.geeksforgeeks.org/iostat-command-in-linux-with-examples/

https://www.techrepublic.com/article/how-to-use-the-linux-iostat-command-to-check-on-your-storage-subsystem/

netstat命令

netstat命令用來統(tǒng)計網(wǎng)絡(luò)連接和端口等信息。

命令:

#顯示在偵聽的TCP/UDP網(wǎng)絡(luò)連接,包括程序和端口信息 #u(UDP) #t(TCP) #n(port) #l(listen) #p(program) netstat-utnlp #只顯示在偵聽的TCP網(wǎng)絡(luò)連接,包括程序和端口信息 netstat-tnlp #查看某個端口被哪個進程使用 #a(all) netstat-anp|grep6379 #查看某個進程在哪個端口 netstat-anp|grepredis #查看docker啟動的進程在哪個端口 dockerps|grepjenkins

df命令

df命令用來統(tǒng)計磁盤使用情況。

命令:

#查看全部文件系統(tǒng)的磁盤使用情況 df-h #查看指定目錄所在的文件系統(tǒng)的磁盤使用情況 df-h~ #不顯示docker文件系統(tǒng) df-h|grep-vdocker

du命令

du命令用來統(tǒng)計指定目錄的大小。

命令:

#統(tǒng)計某個目錄大小 du-sh~ #統(tǒng)計目錄下各個子目錄和文件的大小 du-h~ #統(tǒng)計目錄下各個子目錄和文件的大小,并顯示合計大小 du-ch~ #只統(tǒng)計下一級目錄大小 du-h--max-depth1 #只統(tǒng)計下一級目錄大小,單位為MB,從大到小排序 du-m--max-depth1|sort-rn #只統(tǒng)計下一級目錄大小,單位為MB,從大到小排序,返回最大的10個文件(目錄) du-m--max-depth1|sort-rn|head-11

責(zé)任編輯:xj

原文標題:9個必須掌握的Linux性能調(diào)優(yōu)命令和工具

文章出處:【微信公眾號:嵌入式ARM】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • Linux
    +關(guān)注

    關(guān)注

    87

    文章

    11497

    瀏覽量

    213269
  • 命令
    +關(guān)注

    關(guān)注

    5

    文章

    736

    瀏覽量

    22798
  • 性能
    +關(guān)注

    關(guān)注

    0

    文章

    276

    瀏覽量

    19346

原文標題:9個必須掌握的Linux性能調(diào)優(yōu)命令和工具

文章出處:【微信號:gh_c472c2199c88,微信公眾號:嵌入式微處理器】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 0人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    飛凌嵌入式ElfBoard ELF 1板卡-文件系統(tǒng)常用命令之系統(tǒng)管理與設(shè)置常用命令

    使用情況可使用free查看內(nèi)存使用情況:root@ELF1:~# freetotalusedfreesharedbuff/cacheavailableMem
    發(fā)表于 06-23 16:12

    手把手教你如何調(diào)優(yōu)Linux網(wǎng)絡(luò)參數(shù)

    在高并發(fā)網(wǎng)絡(luò)服務(wù)場景中,Linux內(nèi)核的默認網(wǎng)絡(luò)參數(shù)往往無法滿足需求,導(dǎo)致性能瓶頸、連接超時甚至服務(wù)崩潰。本文基于真實案例分析,從參數(shù)解讀、問題診斷到優(yōu)化實踐,手把手教你如何調(diào)優(yōu)
    的頭像 發(fā)表于 05-29 09:21 ?163次閱讀

    Linux常用命令大全

    Linux常用命令是指在Linux操作系統(tǒng)中廣泛使用的命令工具,這些命令工具可以完成各種不同的任務(wù),如管理文件和目錄、操作進程、網(wǎng)絡(luò)通信、軟
    的頭像 發(fā)表于 05-03 18:08 ?1030次閱讀

    S32G3有沒有辦法從.map文件確定SRAM使用情況

    我有 NXP S32G3 板。我有 .map 文件。有沒有辦法從 .map 文件確定 SRAM 使用情況。 非常感謝幫助。
    發(fā)表于 04-08 06:00

    HarmonyOS NEXT 原生應(yīng)用/元服務(wù)-DevEco Profiler性能問題定界實時監(jiān)控

    ,該泳道會展示所有您所選擇應(yīng)用的功耗總和。右側(cè)區(qū)域柱狀圖則展示了時間窗內(nèi)各部件資源的實時使用情況,柱狀圖的顏色代表每種部件的功耗占比。 說明 FPS、GPU顯示的是所使用設(shè)備的實時信息,而非當前調(diào)
    發(fā)表于 02-21 14:35

    HarmonyOS NEXT 原生應(yīng)用/元服務(wù)-DevEco Profiler性能問題定界實時監(jiān)控

    步驟來查看應(yīng)用的實時資源使用情況。 您可以通過如下三種方式打開DevEco Profiler: 在DevEco Studio頂部菜單欄中選擇“View -> Tool Windows
    發(fā)表于 02-20 10:14

    Linux ip命令常用操作

    Linux?ip命令常用操作 在Linux系統(tǒng)中,ip命令是用于管理網(wǎng)絡(luò)接口和路由的強大工具。相比于舊的?ifconfig
    的頭像 發(fā)表于 02-19 10:23 ?631次閱讀

    Linux實時查看日志的四種命令詳解

    如何在Linux中實時查看日志文件的內(nèi)容?那么有很多實用程序可以幫助用戶在文件更改或不斷更新時輸出文件的內(nèi)容。在Linux中實時顯示文件內(nèi)容的常用命令是tail
    的頭像 發(fā)表于 01-13 10:45 ?2891次閱讀
    <b class='flag-5'>Linux</b>實時<b class='flag-5'>查看</b>日志的四種<b class='flag-5'>命令</b>詳解

    嵌入式開發(fā)必備-RK3562演示Linux常用系統(tǒng)查詢命令

    本文介紹Linux系統(tǒng)查看硬件配置及常用調(diào)試命令,方便開發(fā)者快速了解開發(fā)板硬件信息及進行相關(guān)調(diào)試
    的頭像 發(fā)表于 01-06 14:13 ?458次閱讀
    嵌入式開發(fā)必備-RK3562演示<b class='flag-5'>Linux</b><b class='flag-5'>常用</b>系統(tǒng)查詢<b class='flag-5'>命令</b>

    Linux下如何管理虛擬內(nèi)存 使用虛擬內(nèi)存時的常見問題

    查看虛擬內(nèi)存使用情況 : 使用 free 命令可以查看當前的虛擬內(nèi)存使用情況,包括物理內(nèi)存、交換空間等的
    的頭像 發(fā)表于 12-04 09:19 ?1292次閱讀

    LMX2592正常使用情況下溫度大概有多少?

    你好,LMX2592如果將 OUTA_PD = 1;OUTB_PD = 1;為什么芯片還是很燙,正常使用情況下溫度大概有多少,對于溫度的變化可以提供一下參考嗎
    發(fā)表于 11-08 08:32

    Linux常用命令

    實時監(jiān)控: tail -f xxx.log htop 監(jiān)控程序進程 htop nvidia-smi 顯示內(nèi)存使用情況 實時刷新(每隔1秒刷新一
    的頭像 發(fā)表于 11-06 16:04 ?358次閱讀
    <b class='flag-5'>Linux</b><b class='flag-5'>常用命令</b>

    TMS320C64x在高性能DSP應(yīng)用中的高速緩存使用情況

    電子發(fā)燒友網(wǎng)站提供《TMS320C64x在高性能DSP應(yīng)用中的高速緩存使用情況.pdf》資料免費下載
    發(fā)表于 10-21 09:43 ?0次下載
    TMS320C64x在高<b class='flag-5'>性能</b>DSP應(yīng)用中的高速緩存<b class='flag-5'>使用情況</b>

    Linux服務(wù)器性能查看方法

    Linux服務(wù)器性能查看是系統(tǒng)管理員和開發(fā)人員在日常工作中經(jīng)常需要進行的任務(wù),以確保系統(tǒng)穩(wěn)定運行并優(yōu)化資源使用。以下將詳細介紹多種Linux
    的頭像 發(fā)表于 09-02 11:15 ?1732次閱讀

    全志Linux磁盤操作基礎(chǔ)命令

    /sdc2 df命令 顯示Linux上文件系統(tǒng)磁盤使用的占用情況。 [ubuntu@book:~]$ df//顯示文件系統(tǒng)的磁盤使用情況。 [ubuntu@book:~]$ df
    發(fā)表于 09-02 10:47
    主站蜘蛛池模板: 国产97精品久久久天天A片 | 好紧好湿太硬了我太爽了小说 | 欧美成人免费一区二区三区不卡 | 511麻豆视传媒精品AV | 国产色精品久久人妻99蜜桃麻豆 | 国产一级特黄a大片99 | 特级aa 毛片免费观看 | 两性午夜色视频免费网站 | 久久操韩国自偷拍 | 国产精品亚洲精品爽爽 | 色综合伊人色综合网站 | 成人无码在线超碰视频 | 伊人亚洲综合青草青草久热 | 国产成人一区二区三区在线观看 | 三级中国免费的 | 99在线视频免费观看视频 | 国产亚洲视频在线播放香蕉 | 久久黄色大片 | 牲高潮99爽久久久久777 | 国产短视频精品区 | 亚洲欧美中文日韩视频 | 达达兔欧美午夜国产亚洲 | 午夜免费小视频 | 超碰在线97久久视频观看 | 美女xx00 | 99久久久国产精品免费调教 | 国产精品一区二区在线播放 | 干丝袜美女 | 亚洲三级黄色 | 蜜臀AV人妻久久无码精品麻豆 | 日韩人妻无码专区一本二本 | 日本 稀土矿| 亚洲裸舞 hd | 国产精品无码亚洲精品 | 99久久综合国产精品免费 | 中文字幕亚洲无线码一区 | 欧美日韩看看2015永久免费 | 国产精品一区二区制服丝袜 | 亚洲欧美国产综合在线一区 | 嫩草影院在线观看精品 | 抽插的日日液液H |

    電子發(fā)燒友

    中國電子工程師最喜歡的網(wǎng)站

    • 2931785位工程師會員交流學(xué)習(xí)
    • 獲取您個性化的科技前沿技術(shù)信息
    • 參加活動獲取豐厚的禮品