树莓派安装conky监控运行状态


时间

2022.7(请注意时效性)

环境及物料

环境及物料
Raspberry Pi 4B(8G)
OS: Raspberry Pi OS(64-bit)
Win11 PC(用于远程桌面连接)

Conky简介

Conky 是一个用于X窗口系统的系统监视软件。它可以运行在 GNU/Linux 和 FreeBSD 上,是一个基于GPL协议的免费软件。Conky 可以监控许多系统变量,包括 CPU,内存,交换分区,磁盘空间,温度,top,上传,下载,系统消息,以及更多。它具有很高的可配置性,但配置有一些难于理解。Conky是torsmo的一个分支。

Conky安装

1
sudo apt-get install conky

Conky配置

  • 创建配置文件
1
sudo nano /home/username/.conkyrc #将username替换成用户名,默认用户名pi
  • 把下面的内容复制到新建的文件中(从conky 1.10以来,配置文件都是用新的lua语法编写的)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
conky.config = {

background = true,
use_xft = true,
font = '123:size=12',
xftalpha = 0.1,
update_interval = 0.5,
total_run_times = 0,
own_window = true,
own_window_type = 'normal',
own_window_transparent = true,
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
double_buffer = true,
minimum_width = 250,
minimum_height = 5,
maximum_width = 400,
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
default_color = 'gray',
default_shade_color = 'red',
default_outline_color = 'green',
alignment = 'top_right',
gap_x = 10,
gap_y = 10,
no_buffers = true,
uppercase = false,
cpu_avg_samples = 2,
net_avg_samples = 1,
override_utf8_locale = false,
use_spacer = 'right'

}

conky.text = [[

${font Arial:size=20}${color Tan1}RPI${color Ivory}LINUX

${voffset -90}
${color DimGray}
${font}
${font Arial:bold:size=10}${color Tan1}SYSTEM ${color DarkSlateGray} ${hr 2}
$font${color DimGray}$sysname $kernel $alignr $machine
Frequency $alignr${freq_g cpu0}Ghz
Uptime $alignr${uptime}
File System $alignr${fs_type}

${font Arial:bold:size=10}${color Tan1}CPU ${color DarkSlateGray}${hr 2}
$font${color DimGray}Temp: $alignr ${exec sudo vcgencmd measure_temp | cut -c6-9} C
$font${color DimGray}CPU1 ${cpu cpu1}% ${cpubar cpu1}
CPU2 ${cpu cpu2}% ${cpubar cpu2}
CPU3 ${cpu cpu3}% ${cpubar cpu3}
CPU4 ${cpu cpu4}% ${cpubar cpu4}

${cpugraph DimGray DarkSlateGray} $color

${font Arial:bold:size=10}${color Tan1}MEMORY ${color DarkSlateGray}${hr 2}
$font${color DimGray}MEM $alignc $mem / $memmax $alignr $memperc%
$membar
$font${color DimGray}SWAP $alignc $swap / $swapmax $alignr $swapperc%
$swapbar

${font Arial:bold:size=10}${color Tan1}HDD ${color DarkSlateGray}${hr 2}
$font${color DimGray}/home $alignc ${fs_used /home} / ${fs_size /home} $alignr ${fs_free_perc /home}%
${fs_bar /home}

${font Arial:bold:size=10}${color Tan1}TOP PROCESSES ${color DarkSlateGray}${hr 2}
${color DimGray}$font${top_mem name 2}${alignr}${top mem 2} %
$font${top_mem name 3}${alignr}${top mem 3} %
$font${top_mem name 4}${alignr}${top mem 4} %
$font${top_mem name 5}${alignr}${top mem 5} %

${font Arial:bold:size=10}${color Tan2}NETWORK ${color DarkSlateGray}${hr 2}
$font${color DimGray}IP on eth0 $alignr ${addr eth0}

Down $alignr ${downspeed eth0} kb/s
Up $alignr ${upspeed eth0} kb/s

Downloaded: $alignr ${totaldown eth0}
Uploaded: $alignr ${totalup eth0}

]]
  • Ctrl+O写入,回车确定,Ctrl+X退出

Conky使用

1
conky

Conky效果

  • 截图软件scrot