ESXi 主機上最重要的調試工具esxtop輸出滿屏亂碼

VMware vSphere 6.7中,容許登陸 SSH登陸ESXi主機後,我試着運行了一下esxtop,沒有看到相似Linux top類似的結果,卻看到滿屏幕的亂碼。以下:linux

no termcap entry for a `xterm-256color' terminal"(PDH-CSV 4.0) (UTC)(0)",
"\\172.localdomain\Memory\Memory Overcommit (1 Minute Avg)",
"\\172.localdomain\Memory\Memory Overcommit (5 Minute Avg)",
"\\172.localdomain\Memory\Memory Overcommit (15 Minute Avg)",
"\\172.localdomain\Physical Cpu Load\Cpu Load (1 Minute Avg)",
"\\172.localdomain\Physical Cpu Load\Cpu Load (5 Minute Avg)",
"\\172.localdomain\Physical Cpu Load\Cpu Load (15 Minute Avg)",
"\\172.localdomain\Physical Cpu(0)\% Processor Time",
"\\172.localdomain\Physical Cpu(1)\% Processor Time",
"\\172.localdomain\Physical Cpu(_Total)\% Processor Time",
"\\172.localdomain\Physical Cpu(0)\% Util Time",
"\\172.localdomain\Physical Cpu(1)\% Util Time",
"\\172.localdomain\Physical Cpu(_Total)\% Util Time",
"\\172.localdomain\Memory\Machine MBytes","
\\172.localdomain\Memory\Kernel MBytes",
"\\172.localdomain\Memory\NonKernel MBytes",
"\\172.localdomain\Memory\Free MBytes",
"\\172.localdomain\Memory\Kernel Managed MBytes",
"\\172.localdomain\Memory\Kernel MinFree MBytes",
"\\172.localdomain\Memory\Kernel Reserved MBytes",
"\\172.localdomain\Memory\Kernel Unreserved MBytes",
"\\172.localdomain\Memory\Kernel State",
"\\172.localdomain\Memory\PShare Shared MBytes",
"\\172.localdomain\Memory\PShare Common MBytes",
"\\172.localdomain\Memory\PShare Savings MBytes",
"\\172.localdomain\Memory\Swap Used MBytes",
"\\172.localdomain\Memory\Swap Target MBytes",
"\\172.localdomain\Memory\Swap MBytes Read/sec",
"\\172.localdomain\Memory\Swap MBytes Write/sec",
"\\172.localdomain\Memory\Total Compressed MBytes",
"\\172.localdomain\Memory\Total Saved By Compression MBytes",
"\\172.localdomain\Memory\Memctl Current MBytes",
"\\172.localdomain\Memory\Memctl Target MBytes",
"\\172.localdomain\Memory\Memctl Max MBytes",
"\\172.localdomain\Power\Power Usage Now Watts",
"\\172.localdomain\Power\Power Usage Cap Watts",
"\\172.localdomain\VSAN\Enabled?",
"\\172.localdomain\Group Cpu(1:system)\Members",
"\\172.localdomain\Group Cpu(1:system)\% Used",
"\\172.localdomain\Group Cpu(1:system)\% Run",
"\\172.localdomain\Group Cpu(1:system)\% System",
"\\172.localdomain\Group Cpu(1:system)\% Wait",
"\\172.localdomain\Group Cpu(1:system)\% Ready",
"\\172.localdomain\Group Cpu(1:system)\% Idle",
"\\172.localdomain\Group Cpu(1:system)\% Overlap",
"\\172.localdomain\Group Cpu(1:system)\% CoStop",
"\\172.localdomain\Group Cpu(1:system)\% Max Limited",
"\\172.localdomain\Group Cpu(1:system)\% Swap Wait",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% Used",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% Run",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% System",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% Wait",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% VmWait",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% Ready",
"\\172.localdomain\Vcpu(1:system:2097153:idle1)\% Idle",

原本vSphere還得依靠它來查看系統信息呢,esxtop卻亂成一團,這可如何是好?去網上搜一搜,竟然也有人經歷過相同的遭遇,VMware官網上有解決方法,以下:數據庫

第1步 查看終端變量的設置

[root@172:~] echo $TERM
xterm-256color

第1行中的no termcap entry for a `xterm-256color' terminal就是告訴咱們:對於xterm-256color這種控制終端,在本機的數據庫裏沒有找到,因此就顯示不出來正確的格式。既然不支持,就找一個能支持的終端吧。安全

第2步 查找ESXi主機支持的格式

[root@172:~] find /usr/share/terminfo/ -type f
/usr/share/terminfo/v/vt102
/usr/share/terminfo/x/xterm
/usr/share/terminfo/s/screen
/usr/share/terminfo/l/linux
/usr/share/terminfo/a/ansi

看吧,terminfo數據裏能被ESXi主機支持的控制終端有5個,隨便選一個來試試。bash

第3步 設置終端格式

# TERM=XTERM esxtop

設爲第2種xterm。立刻就行了!另外幾種,也均可以。問題暫時解決了。要是下一次登陸,又不能顯示,怎麼辦?dom

那就在/etc/bashrc裏添加這個TERM變量。不行,沒有這個文件。/etc/profile卻是有,不過是隻讀的,root也沒有權限修改。卻是有個/etc/profile.local的權限是1644,root是用戶,能夠修改。打開來看,裏面有一句說:測試

This file is not used when UEFI secure boot is enabled.

意思是說,要是使用UEFI安全啓動,這個文件就廢了。無論那麼多了,修改一下,在裏面添加這麼兩句:spa

TERM=xtermcode

export $TERMterminal

而後,再引用一下這個文件。get

# source /etc/profile.local

測試一下。先把TERM設爲別的變量。

# TERM=test
# source /etc/profile.local
# echo $TERM

顯示的是xterm。下次vSphere從新啓動的時候,會讀這個文件嗎?我尚未試過。

 

參考資料:https://kb.vmware.com/s/article/2001448

相關文章
相關標籤/搜索