Linux 桌面系統監控工具Conky 顯示系統資源信息


Linux 桌面顯示系統資源信息,先看下效果圖。主要是使用Conky,加上自定義的配置,可以讓我們定義自己喜歡的資源顯示方案

我這里顯示了,IP信息、主機信息、內存和交換內存、占用CPU的資源消耗前幾位、磁盤、顯示網卡的流量信息等(無邊框陰影)

接下來說下安裝配置,我們使用命令安裝conky

樓主使用的是kaillinux系統配置的

安裝配置代碼部分

安裝conkey

#### 安裝軟件
> Centos系統
yum install conky

> Debian系統
apt-get install conky

#### 啟動軟件
>直接在命令行輸入conky就可以了

設置開機啟動
程序開機啟動的位置
>/etc/xdg/autostart

編寫一二個conky.desktop的文件,寫入程序路徑就可以實現程序自啟動
/usr/bin/conky 編寫桌面啟動文件的時候,是需要找到啟動的bin文件的

#新建配置文件
touch conky.conf
#編輯配置文件
vi conky.conf

[Desktop Entry]
Type=Application
Encoding=UTF-8
Exec=/usr/bin/conky

樓主的配置文件

安裝之后的路徑是------/etc/conky/conky.conf

加陰影之后的顯示效果

-- vim: ts=4 sw=4 noet ai cindent syntax=lua

# set to yes if you want Conky to be forked in the background
background yes
cpu_avg_samples 2
net_avg_samples 2
out_to_console yes
# X font when Xft is disabled, you can pick one with program xfontsel
#font 7x12
#font 6x10
#font 7x13
#font 8x13
#font 7x12
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*
#font -artwiz-snap-normal-r-normal-*-*-100-*-*-p-*-iso8859-1
# Use Xft?
use_xft yes
# Xft font when Xft is enabled
xftfont DejaVu Sans Mono:size=10  
own_window_argb_visual yes
#own_window_colour hotpink
# Text alpha when using Xft
xftalpha 0.8
# on_bottom yes
# mail spool
#mail_spool $MAIL
# 資源監視面板的更新時間間隔
update_interval 5
# 創建自己的窗口而不是使用桌面
own_window yes
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
#own_window_type override
own_window_type normal
# 使用雙重緩沖 減少閃爍
double_buffer yes
# 最小寬度
minimum_size 260 5
maximum_width 400
# 是否顯示陰影
draw_shades no
# 是否顯示外邊框
draw_outline no
# 是否繪制文字邊框
draw_borders no
# 是否使用邊界斑點
stippled_borders no
# 設置外邊距
border_margin 2
# border width 邊框的寬度
border_width 2
# Default colors and also border colors 默認顏色 陰影顏色 外邊框顏色
default_color green
default_shade_color red
default_outline_color red
# 文本對齊
#alignment top_left
#minimum_size 10 10
gap_x 15
gap_y 20
# 配置是顯示在屏幕左邊還屏幕是右邊 top_right top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
# Add spaces to keep things from moving about?  This only affects
# certain objects.
use_spacer none
# Subtract file system buffers from used memory?
no_buffers yes
# set to yes if you want all text to be in uppercase
uppercase no
# none, xmms, bmp, audacious, infopipe (default is none)
# xmms_player bmp
#===================================================================================
# 這個部分顯示的是主要部分的內容,語法還是需要簡單的學習一下的
# ${} 這個里面設置的是參數,主要是使用這個來設置
TEXT
${color yellow}SYSTEM ${hr 1}${color}
Time:$alignr${time %Y.%m.%d}$alignc   ${time %H:%M:%S}$alignr   Week:${time %w}
# 設置的是主機、用戶名、內核版本等
Hostname: $alignr$nodename
UserName: $alignr$USER
Kernel: $alignr$kernel
Machine:$alignr$machine
Uptime: $alignr$uptime
#Temp: ${alignr}${acpitemp} °C
#${color yellow}IP ${hr 1}${color}
#獲取本機的ip地址
IpLocal:$alignr${addr eth0}${addr wlan0}
# 這里是使用awk獲取外網信息
#Ext IP Addr:${alignr}${exec curl http://myip.com.tw/ | grep "我的 IP 是" | awk -F '>' '{print$3}'| awk -F '<' '{print$1}'}
#Ext Ip Addr:${alignr}${exec curl https://ip.cn | awk -F":" '{print $2}' | awk -F"," '{print substr($1,3,15)}'}
#Battery:$alignr${battery BAT0}
#Battery:$alignr${battery_percent BAT0}%  
${color yellow}CPU ${hr 1}${color}
# 設置CPU的顯示信息
CPU: ${alignr}${freq dyn} MHz
Processes: ${alignr}$processes ($running_processes running)
Load: ${alignr}$loadavg
#CPU1 ${alignr}${cpu cpu1}%
#${cpubar 4 cpu1}
#CPU2 ${alignr}${cpu cpu2}%
#${cpubar 4 cpu2}
#${cpugraph red yellow}
#內存和交換內存顯示部分
Ram ${alignr}$mem / $memmax ($memperc%)
${membar 4}
swap ${alignr}$swap / $swapmax ($swapperc%)
${swapbar 4}
${color yellow}CPU/MEM ${hr 1}${color}
${color pink}Highest CPU $alignr CPU% MEM%${color}
${top name 1}$alignr${top cpu 1} ${top mem 1}
${top name 2}$alignr${top cpu 2} ${top mem 2}
${top name 3}$alignr${top cpu 3} ${top mem 3}
#${color pink}Highest MEM $alignr CPU% MEM%${color}
#${top_mem name 1}$alignr${top_mem cpu 1} ${top_mem mem 1}
#${top_mem name 2}$alignr${top_mem cpu 2} ${top_mem mem 2}
#${top_mem name 3}$alignr${top_mem cpu 3} ${top_mem mem 3}
# 設置顯示文件存儲的信息
${color yellow}FILE SYSTEM ${hr 1}${color}
Root: ${alignr}${fs_free /} / ${fs_size /}
${fs_bar 4 /}
Home: ${alignr}${fs_free /home} / ${fs_size /home}
${fs_bar 4 /home}
${color yellow}NETWORK eth0${hr 1}${color}
#顯示的是配置網卡的信息
Down ${downspeed eth0}  ${alignr}Up ${upspeed eth0} 
${downspeedgraph eth0 25,107} ${alignr}${upspeedgraph eth0 25,107}
Total ${totaldown eth0} ${alignr}Total ${totalup eth0}
${color yellow}NETWORK wlan0${hr 1}${color}
Down ${downspeed wlan0}  ${alignr}Up ${upspeed wlan0} 
${downspeedgraph wlan0 25,107} ${alignr}${upspeedgraph wlan0 25,107}
Total ${totaldown wlan0} ${alignr}Total ${totalup wlan0}
#${color white}NEWS $color
#${rss http://www.linuxeden.com/plus/rss.php?tid=1 5 item_titles 2}

樓主較喜歡簡單的風格,所以沒做其他風格的配置教程,若是需要,可以留言交流

GitHub 站點 https://github.com/brndnmtthws/conky/

配置詳細文檔(全英 需要翻譯) http://conky.sourceforge.net/docs.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM