conky 上的负 ram

conky 上的负 ram

我在 arch linux 上安装了 conky,桌面是 xfce。内存使用不正常。内存使用量显示为负数。

截屏

以下是我的配置

conky.config = {
    use_xft = true,
    xftalpha = 0.8,
    update_interval = 1.0,
    total_run_times = 0,
    own_window = true,
    own_window_transparent = no,
    own_window_argb_visual = true,
    own_window_argb_value = 180,
    own_window_colour = '2F343F',
    own_window_type = 'normal',
    own_window_class = 'conky-semi',
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
    background = true,
    double_buffer = true,
    imlib_cache_size = 0,
    no_buffers = true,
    uppercase = false,
    cpu_avg_samples = 2,
    override_utf8_locale = true,

    -- placement
    alignment = 'top_right',
    gap_x = 25,
    gap_y = 45,

    -- default drawing
    draw_shades = false,
    draw_outline = false,
    draw_borders = false,
    draw_graph_borders = true,
    default_bar_width = 150, default_bar_height = 5,
    default_graph_width = 150, default_graph_height = 12,
    default_gauge_width = 20, default_gauge_height = 20,

    -- colors
    font = 'Noto Sans:size=9',
    default_color = 'E9FFE9',
    color1 = '77BCFF', 
    color2 = '90EE90',
    color3 = '4E6E4E',

    -- layouting
    template0 = [[${font Liberation Sans:bold:size=11}${color2}\1 ${color3}${hr 2}${font}]],
    template1 = [[${color1}\1]],
    template2 = [[${goto 70}${color}]],
    template3 = [[${goto 120}${color}${alignr}]],
};

conky.text = [[
${template0 Info}
${template1 Date}                                                           ${color3}${template3}${time %a,}${color}${time %e %B %G}
${template1 Time}                                                           ${template3}${time %T}

${template0 System}
${template1 Hostname}                                                       ${template3}${nodename}
${template1 ${sysname}}                                                     ${template3}${kernel}-${machine}
${template1 Uptime}                                                         ${template3}${uptime_short}
${template1 CPU}                                                            ${template3}${freq_g}GHz

${template0 Processors}
${template1 Load}               ${template2}${loadavg 1}                    ${template3}${loadgraph}
${template1 Core\ 1}            ${template2}${cpu cpu1}%                    ${template3}${cpubar cpu1}
${template1 Core\ 2}            ${template2}${cpu cpu2}%                    ${template3}${cpubar cpu2}
${template1 Core\ 3}            ${template2}${cpu cpu3}%                    ${template3}${cpubar cpu3}
${template1 Core\ 4}            ${template2}${cpu cpu4}%                    ${template3}${cpubar cpu4}
${template1 Top}                ${template2}${top name 1}                   ${template3}${top cpu 1}

${template0 Memory}
${template1 Memory}             ${template2}${memperc}% used                ${template3}${mem} / ${memmax}
                                                                            ${template3}${membar}
${template1 Top}                ${template2}${top_mem name 1}               ${template3}${top_mem mem_vsize 1}

${template0 Filesystem}
${template1 /}                  ${template2}${fs_free /} free               ${template3}${fs_used /} / ${fs_size /}
                                                                            ${template3}${fs_bar /}
${template1 IO\ Read}           ${template2}${diskio_read}                  ${template3}${diskiograph_read}
${template1 IO\ Write}          ${template2}$diskio_write                   ${template3}$diskiograph_write
${template1 Top}                ${template2}${top_io name 1}                ${template3}${top_io io_perc 1}

]];

答案1

这似乎是最近才出现的一个错误:github 问题 877

最近更新到版本 v1.11.5。在此更新之后,我注意到使用 $mem 变量和其他与内存相关的函数(如下图所示的使用情况图)时,RAM 使用率将为负数,这在以前的版本中没有出现过。

他们建议通过撤消最近的补丁来修复,但您可能需要跟踪问题,因为后果存在一些不确定性。

conky 通过从 读取值来计算内存/proc/meminfo。如果你愿意,可以暂时用 awk 进行以下计算(单位为 kiB):

awk </proc/meminfo -F': *' '
{ v[$1] = $2+0 }
END{ print v["MemTotal"]-v["MemFree"]-(v["Cached"]-v["Shmem"]+v["Buffers"]+v["SReclaimable"])
}'

相关内容