小记

Linux 桌面显示系统资源信息,先看下效果图。主要是使用Conky,加上自定义的配置,可以让我们定义自己喜欢的资源显示方案

信息显示

我这里显示了,IP信息、主机信息、内存和交换内存、占用CPU的资源消耗前几位、磁盘、显示网卡的流量信息等(无边框阴影)

Linux桌面系统监控工具Conky1

安装配置

我们使用命令安装conky

楼主使用的是kaillinux系统配置的

配置代码部分

#### 安装软件
> 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

Linux桌面系统监控工具Conky2

Linux桌面系统监控工具Conky3

配置文件

安装之后的路径是------/etc/conky/conky.conf

显示效果

Linux桌面系统监控工具Conky4

-- 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