Skip to content

Support for weewx cmon

David Baetge edited this page Feb 19, 2024 · 5 revisions

The skin provides a pre-configured page to show data from the weewx-cmon extension.

I am using the fork available at https://github.com/bellrichm/weewx-cmon because it includes a fix for getting the CPU temperature on the Raspberry Pi.

For getting the correct units on the observations please add this to user/extensions.py (if you dont know where to find this file, see here: https://weewx.com/docs/usersguide.htm#Where_to_find_things, its in the User directory):

import weewx.units

weewx.units.obs_group_dict['pop'] = 'group_percent'
weewx.units.obs_group_dict['cloudcover'] = 'group_percent'
weewx.units.obs_group_dict['sunshineDur'] = 'group_deltatime'
weewx.units.obs_group_dict['rainDur'] = 'group_deltatime'
weewx.units.obs_group_dict['temp'] = 'group_temperature'

weewx.units.obs_group_dict['cpu_user'] = 'group_percent'
weewx.units.obs_group_dict['cpu_nice'] = 'group_percent'
weewx.units.obs_group_dict['cpu_system'] = 'group_percent'
weewx.units.obs_group_dict['cpu_idle'] = 'group_percent'
weewx.units.obs_group_dict['cpu_iowait'] = 'group_percent'
weewx.units.obs_group_dict['cpu_irq'] = 'group_percent'
weewx.units.obs_group_dict['cpu_softirq'] = 'group_percent'

weewx.units.obs_group_dict['mem_total'] = 'group_data'
weewx.units.obs_group_dict['mem_used'] = 'group_data'
weewx.units.obs_group_dict['mem_free'] = 'group_data'

weewx.units.obs_group_dict['swap_total'] = 'group_data'
weewx.units.obs_group_dict['swap_used'] = 'group_data'
weewx.units.obs_group_dict['swap_free'] = 'group_data'

weewx.units.obs_group_dict['load1'] = 'group_count'
weewx.units.obs_group_dict['load5'] = 'group_count'
weewx.units.obs_group_dict['load15'] = 'group_count'

weewx.units.obs_group_dict['proc_active'] = 'group_count'
weewx.units.obs_group_dict['proc_total'] = 'group_count'

weewx.units.obs_group_dict['cpu_temp'] = 'group_temperature'
weewx.units.obs_group_dict['cpu_temp1'] = 'group_temperature'
weewx.units.obs_group_dict['cpu_temp2'] = 'group_temperature'
weewx.units.obs_group_dict['cpu_temp3'] = 'group_temperature'
weewx.units.obs_group_dict['cpu_temp4'] = 'group_temperature'

weewx.units.obs_group_dict['net_eth0_rbytes'] = 'group_data'
weewx.units.obs_group_dict['net_eth0_rpackets'] = 'group_count'
weewx.units.obs_group_dict['net_eth0_rerrs'] = 'group_count'
weewx.units.obs_group_dict['net_eth0_rdrop'] = 'group_count'

weewx.units.obs_group_dict['net_eth0_tbytes'] = 'group_data'
weewx.units.obs_group_dict['net_eth0_tpackets'] = 'group_count'
weewx.units.obs_group_dict['net_eth0_terrs'] = 'group_count'
weewx.units.obs_group_dict['net_eth0_tdrop'] = 'group_count'

weewx.units.obs_group_dict['net_wlan0_rbytes'] = 'group_data'
weewx.units.obs_group_dict['net_wlan0_rpackets'] = 'group_count'
weewx.units.obs_group_dict['net_wlan0_rerrs'] = 'group_count'
weewx.units.obs_group_dict['net_wlan0_rdrop'] = 'group_count'

weewx.units.obs_group_dict['net_wlan0_tbytes'] = 'group_data'
weewx.units.obs_group_dict['net_wlan0_tpackets'] = 'group_count'
weewx.units.obs_group_dict['net_wlan0_terrs'] = 'group_count'
weewx.units.obs_group_dict['net_wlan0_tdrop'] = 'group_count'

weewx.units.obs_group_dict['disk_root_total'] = 'group_data'
weewx.units.obs_group_dict['disk_root_used'] = 'group_data'
weewx.units.obs_group_dict['disk_root_free'] = 'group_data'

weewx.units.obs_group_dict['disk_home_total'] = 'group_data'
weewx.units.obs_group_dict['disk_home_used'] = 'group_data'
weewx.units.obs_group_dict['disk_home_free'] = 'group_data'

weewx.units.obs_group_dict['ups_temp'] = 'group_temperature'
weewx.units.obs_group_dict['ups_load'] = 'group_power'
weewx.units.obs_group_dict['ups_charge'] = 'group_percent'
weewx.units.obs_group_dict['ups_voltage'] = 'group_voltage'
weewx.units.obs_group_dict['ups_time'] = 'group_deltatime'

Availabe observations

Please see these links for a description for most of the observations:

On a Linux machine the following observations are available:

Memory

File /proc/meminfo is used to get the memory information (see https://www.thegeekdiary.com/understanding-proc-meminfo-file-analyzing-memory-utilization-in-linux/):

  • mem_total - Total memory in kB
  • mem_free - Free memory in kB
  • mem_used - Used memory in kB
  • swap_total - Total swap in kB
  • swap_free - Free swap in kB
  • swap_used - Used swap in kB

CPU

File /proc/stat is used to get the CPU information (see https://www.thegeekdiary.com/understanding-proc-stat-file-in-linux/ or https://support.checkpoint.com/results/sk/sk65143):

  • cpu_user - Time spent with normal processing in user mode
  • cpu_nice - Time spent with niced processes in user mode
  • cpu_system - Time spent with normal processing in kernel mode
  • cpu_idle - Time spent in idle task
  • cpu_iowait - Time waiting for I/O to complete
  • cpu_irq - Servicing interrupts
  • cpu_softirq - Servicing softirqs

Load and processes

File /proc/loadavg is used to get the load information (see https://stackoverflow.com/questions/11987495/what-do-the-numbers-in-proc-loadavg-mean-on-linux or https://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html):

  • load1 - Load average for the last minute
  • load5 - Load average for the last 5 minutes
  • load15 - Load average for the last 15 minutes
  • proc_active - Number of active processes
  • proc_total - Number of total processes

Example skin.conf configs

Adding the cmon observations globally:

[ObservationBindings]
    [[cpu_user]]
        data_binding = cmon_binding
        observation = cpu_user
    [[cpu_system]]
        data_binding = cmon_binding
        observation = cpu_system
    [[load1]]
        data_binding = cmon_binding
        observation = load1
    [[load5]]
        data_binding = cmon_binding
        observation = load5
    [[load15]]
        data_binding = cmon_binding
        observation = load15
    [[mem_used]]
        data_binding = cmon_binding
        observation = mem_used
    [[mem_free]]
        data_binding = cmon_binding
        observation = mem_free
    [[proc_active]]
        data_binding = cmon_binding
        observation = proc_active
    [[proc_total]]
        data_binding = cmon_binding
        observation = proc_total
    [[net_eth0_rbytes]]
        data_binding = cmon_binding
        observation = net_eth0_rbytes
    [[net_eth0_rpackets]]
        data_binding = cmon_binding
        observation = net_eth0_rpackets
    [[net_eth0_tbytes]]
        data_binding = cmon_binding
        observation = net_eth0_tbytes
    [[net_eth0_tpackets]]
        data_binding = cmon_binding
        observation = net_eth0_tpackets
    [[net_wlan0_rbytes]]
        data_binding = cmon_binding
        observation = net_wlan0_rbytes
    [[net_wlan0_rpackets]]
        data_binding = cmon_binding
        observation = net_wlan0_rpackets
    [[net_wlan0_tbytes]]
        data_binding = cmon_binding
        observation = net_wlan0_tbytes
    [[net_wlan0_tpackets]]
        data_binding = cmon_binding
        observation = net_wlan0_tpackets
    [[cpu_temp]]
        data_binding = cmon_binding
        observation = cpu_temp

For some observations, like load1, load5, load15 you should make some updates to the diagrams default configs like this:

[DisplayOptions]
    ...
    [[diagrams]]
        ...
        # Computer monitor.
        [[[cpu_user]]]
            yScaleMin = 0
            curve = linear
        [[[cpu_system]]]
            yScaleMin = 0
            curve = linear
        [[[load1]]]
            yScaleOffset = 0.025
            yScaleMin = 0
            curve = linear
        [[[load5]]]
            yScaleOffset = 0.025
            yScaleMin = 0
            curve = linear
        [[[load15]]]
            yScaleOffset = 0.025
            yScaleMin = 0
            curve = linear
        [[[mem_used]]]
            yScaleMin = 0
            curve = linear
        [[[mem_free]]]
            yScaleMin = 0
            curve = linear

A combined diagram with all loadX observations could look like this:

[[[[cmon_load]]]]
    data_binding = cmon_binding
    label="Load"
    yScaleOffset = 0.025
    yScaleMin = 0
    curve = linear
    rounding = 2
    bottom_date_time_format = "%m/%d"
    [[[[[obs]]]]]
        [[[[[[load1]]]]]]
            observation = "load1"
            color = "#7C0A02"
        [[[[[[load5]]]]]]
            observation = "load5"
            color = "#E89611"
            color_dark = "#E89611"
        [[[[[[load15]]]]]]
            observation = "load15"
            color = "#708238"
            color_dark = "#708238"

CPU diagram:

[[[[cmon_cpu]]]]
    data_binding = cmon_binding
    label="CPU"
    yScaleMin = 0
    curve = linear
    rounding = 0
    bottom_date_time_format = "%m/%d"
    [[[[[obs]]]]]
        [[[[[[cpu_user]]]]]]
            observation = "cpu_user"
            color = "#7C0A02"
        [[[[[[cpu_system]]]]]]
            observation = "cpu_system"
            color = "#E89611"
            color_dark = "#E89611"

Memory diagram:

[[[[cmon_mem]]]]
    data_binding = cmon_binding
    label="Memory"
    yScaleMin = 0
    curve = linear
    rounding = 2
    bottom_date_time_format = "%m/%d"
    [[[[[obs]]]]]
        [[[[[[mem_used]]]]]]
            observation = "mem_used"
            color = "#E89611"
            color_dark = "#E89611"
        [[[[[[mem_free]]]]]]
            observation = "mem_free"
            color = "#708238"
            color_dark = "#708238"
        [[[[[[mem_total]]]]]]
            observation = "mem_total"
            color = "#7C0A02"
            color_dark = "#7C0A02"

Processes:

[[[[cmon_proc]]]]
    data_binding = cmon_binding
    label="Processes"
    yScaleMin = 0
    curve = linear
    rounding = 0
    bottom_date_time_format = "%m/%d"
    [[[[[obs]]]]]
        [[[[[[proc_active]]]]]]
            observation = "proc_active"
            color = "#708238"
            color_dark = "#708238"
        [[[[[[proc_total]]]]]]
            observation = "proc_total"
            color = "#7C0A02"
            color_dark = "#7C0A02"

Network:

[[[[cmon_net]]]]
    data_binding = cmon_binding
    label="Network"
    yScaleMin = 0
    curve = linear
    rounding = 0
    bottom_date_time_format = "%m/%d"
    [[[[[obs]]]]]
        [[[[[[net_eth0_rbytes]]]]]]
            observation = "net_eth0_rbytes"
            color = "#708238"
            color_dark = "#708238"
        [[[[[[net_eth0_rpackets]]]]]]
            observation = "net_eth0_rpackets"
            color = "#8F9779"
            color_dark = "#8F9779"
        [[[[[[net_eth0_tbytes]]]]]]
            observation = "net_eth0_tbytes"
            color = "#E89611"
            color_dark = "#E89611"
        [[[[[[net_eth0_tpackets]]]]]]
            observation = "net_eth0_tpackets"
            color = "#5E1914"
            color_dark = "#5E1914"

Use the new combined diagrams:

computer_monitor_diagram_observations = cpu_temp, cmon_cpu, cmon_load, cmon_mem, cmon_proc, cmon_net

Results in something like that:

Example diagrams

Roundings:

[DisplayOptions]
    [[Rounding]]
        load1 = 2
        load5 = 2
        load15 = 2