惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Vercel News
Vercel News
月光博客
月光博客
S
SegmentFault 最新的问题
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
小众软件
小众软件
WordPress大学
WordPress大学
G
Google Developers Blog
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 【当耐特】
I
InfoQ

xnum’s blog

2025/03 初春日本四國遊記 2024/8 菲律賓遊學記 使用DNS紀錄來自動更新IP白名單 lvremove 遇到 contains a filesystem in use 多媒體檔案管理和下載伺服器 - 軟體篇 淘寶退貨 順豐寄回大陸經驗 在dnsmasq加上自動生成PTR紀錄 ultrahuman ring air 台灣購買兼使用心得 AI Singing Voice Conversion (SVC) 的試玩心得
在Linux上面安裝glances並設定為系統服務
Jia Jun Yeh · 2024-05-23 · via xnum’s blog

由於在 Docker 中無法查看某些系統資訊,加上需要指定版本,因此需要進行一個繁瑣的 Python 程式安裝流程。

首先,我們需要建立一個虛擬環境來隔離即將安裝的依賴,以免影響系統的穩定性。

apt install python3 python3-venv

接下來,建立一個虛擬環境:

python3 -m venv /root/_glances
source /root/_glances/bin/activate

接著,安裝 Glances。如果需要使用 Web UI,則需要額外安裝 FastAPI。

pip3 install Glances
pip3 install FastAPI

以下是 systemd 的服務配置檔案,將其放置於 /etc/systemd/system/glances.service

[Unit]
Description=Glances
Documentation=man:glances(1)
Documentation=https://github.com/nicolargo/glances
After=network.target

[Service]
ExecStart=/root/_glances/bin/python3 -m glances -w
Restart=on-abort

[Install]
WantedBy=multi-user.target

完成上述步驟後,啟用並啟動 Glances 服務:

systemctl daemon-reload
systemctl enable glances
systemctl start glances

這樣就完成了在 Linux 上安裝並設定 Glances 為系統服務的步驟。現在,你可以透過 Web UI 來監控你的系統狀態了。