Skip to content

Instantly share code, notes, and snippets.

@tasosmitsi
Last active February 12, 2025 22:25
Show Gist options
  • Save tasosmitsi/17b2a7964dfb72a4b33e918fd52e4455 to your computer and use it in GitHub Desktop.
Save tasosmitsi/17b2a7964dfb72a4b33e918fd52e4455 to your computer and use it in GitHub Desktop.
Displaying CPU Temperature in Proxmox PVE Summary in Real Time
  1. Let's install lm-sensors to show us the information we need. Type the following in the proxmox shell apt get install lm-sensors. Next we can check if its working. To do this we can type sensors and hit enter. You should see something like this:

    coretemp-isa-0000
    Adapter: ISA adapter
    Package id 0:  +53.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 0:        +50.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 4:        +48.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 8:        +48.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 12:       +50.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 16:       +48.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 20:       +49.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 24:       +51.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 25:       +51.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 26:       +51.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 27:       +51.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 28:       +53.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 29:       +53.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 30:       +53.0°C  (high = +100.0°C, crit = +100.0°C)
    Core 31:       +53.0°C  (high = +100.0°C, crit = +100.0°C)
  2. Adding the output of sensors to information. Here we will use Nano to edit some files. In your shell, type the following: nano /usr/share/perl5/PVE/API2/Nodes.pm. Next, you can press F6 to search for my $dinfo and press enter.

    The code should look like this:

    $res->{pveversion} = PVE::pvecfg::package() . "/" .
        PVE::pvecfg::version_text();
    
    my $dinfo = df('/', 1);     # output is bytes

    We are going to add the following line of code in between: $res->{thermalstate} = \sensors\;

    So the final result should look like this:

    $res->{pveversion} = PVE::pvecfg::package() . "/" .
        PVE::pvecfg::version_text();
    
    $res->{thermalstate} = `sensors`;
    
    my $dinfo = df('/', 1);     # output is bytes

    Now press Ctrl+O to save and Ctrl+X to exit.

  3. Now it's time to make space for the new information. We will need to edit another file, so once again we will use Nano. Type the following command into your shell: nano /usr/share/pve-manager/js/pvemanagerlib.js. Once in, press F6 to search for widget.pveNodeStatus and press enter.

    You will get a snippit of code that looks like this:

    Ext.define('PVE.node.StatusView', {
    extend: 'PVE.panel.StatusView',
    alias: 'widget.pveNodeStatus',
    
    height: 300,
    bodyPadding: '5 15 5 15',
    
    layout: {
        type: 'table',
        columns: 2,
        tableAttrs: {
            style: {
                width: '100%'
            }
        }
    },

    Next change the bodyPadding: '5 15 5 15' to bodyPadding: '20 15 20 15', as well as the height: 300 to height: 360,

    Keep this file open, we are not yet done.

  4. Ok! Now press F6 again to search for itemId: 'version' and press enter. You will see a section of code like this:

    {
        itemId: 'version',
        colspan: 2,
        printBar: false,
        title: gettext('Manager Version'),
        textField: 'pveversion',
        value: '',
    },

    Ok now we need to add some code after this part. The code is:

    {
        itemId: 'thermal',
        colspan: 2,
        printBar: false,
        iconCls: 'fa fa-fw fa-thermometer-half',
        title: gettext('CPU Thermal State'),
        textField: 'thermalstate',
        renderer:function(value){
            const pk = value.match(/Package id 0.*?\+([\d\.]+)Â/)[1];
            const c0 = value.match(/Core 0.*?\+([\d\.]+)Â/)[1];
            const c1 = value.match(/Core 1.*?\+([\d\.]+)Â/)[1];
            const c2 = value.match(/Core 2.*?\+([\d\.]+)Â/)[1];
            const c3 = value.match(/Core 3.*?\+([\d\.]+)Â/)[1];
            return `Package: ${pk}| Core 0: ${c0}| Core 1: ${c1}| Core >
            }
    }

    Therefore your final result should look something like this:

    {
        itemId: 'version',
        colspan: 2,
        printBar: false,
        title: gettext('Manager Version'),
        textField: 'pveversion',
        value: '',
    },
    {
        itemId: 'thermal',
        colspan: 2,
        printBar: false,
        iconCls: 'fa fa-fw fa-thermometer-half',
        title: gettext('CPU Thermal State'),
        textField: 'thermalstate',
        renderer:function(value){
            const pk = value.match(/Package id 0.*?\+([\d\.]+)Â/)[1];
            const c0 = value.match(/Core 0.*?\+([\d\.]+)Â/)[1];
            const c1 = value.match(/Core 1.*?\+([\d\.]+)Â/)[1];
            const c2 = value.match(/Core 2.*?\+([\d\.]+)Â/)[1];
            const c3 = value.match(/Core 3.*?\+([\d\.]+)Â/)[1];
            return `Package: ${pk}| Core 0: ${c0}| Core 1: ${c1}| Core >
            }
    }

    Now we can finally press Ctrl+O to save and Ctrl+X to exit.

  5. Restart the summary page. To do this you will have to type in the following command: systemctl restart pveproxy. This will restart the Proxmox web interface and apply the changes we made.

Credits and Acknowledgements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment