Temperature monitoring

chchia

Member
Aug 18, 2020
64
23
13
46
Hi, i followed this guide, successfully added proxmox to monitor my host machine temperature.
https://blog.csdn.net/xiaobo060/article/details/105930003

do you think this can be implemented to proxmox officially? otherwise i need to manually add it again each time proxmox updated the related files.
1612962507027.png

i fully aware that using this method the user should know about how to find a proper sensors name that one need to be displayed on the webpage, it required user interaction, users need to find out the proper id name show in lm-sensors and i understood every CPU and MOBO may have all different naming.

can proxmox put this pre-built with user possibility to enter the variable by themself, so that the value of the temperature can be shown?
 
Nice Find,

I would advise, before doing so to check if the `sensors` output is the same as the author suggests, otherwise, the javascript snippet won't work

I suppose equivalently you can add other info too
 
can proxmox put this pre-built with user possibility to enter the variable by themself, so that the value of the temperature can be shown?
One of the issues might be that the output of the `sensors` command might not be consistent across hardware which would make the JavaScript code to fail, I suppose there is a nice area for development though
 
For CPU temperature it shouldn't be too hard to automate since there are only a few cpu temperature drivers.

The code could just look under '/sys/class/hwmon/hwmon*/name' for one of the cpu temperature driver names and add the data.

/sys/class/hwmon/hwmon2/ # grep -F '' name temp* name:k10temp temp1_input:50500 temp1_label:Tctl temp2_input:50500 temp2_label:Tdie temp3_input:42000 temp3_label:Tccd1 temp4_input:39000 temp4_label:Tccd2

This would also be very easy to automate for hard drives, either via hddtemp or smartctl.

For nvme drives they can use '/sys/class/hwmon/hwmon*' to get the data same as for CPUs.

For other random sensors data it would likely be more complicated to add in an automated fashion but perhaps it could source input from something user provided eg 'sensors' output.
 
Last edited:
necrobump
I followed some guides and want to share my result with community:
2023-04-18 20_34_24.png


First step check utilities you want to use = lm-sensors and upower.
apt install ...

Next we need to add information sources to /usr/share/perl5/PVE/API2/Nodes.pm
thermal state and batterystate - two variables to provide text to parse later.
Code:
      $res->{pveversion} = PVE::pvecfg::package() . "/" .
            PVE::pvecfg::version_text();

        $res->{thermalstate} = `sensors -j`;

        $res->{batterystate} = `upower -i /org/freedesktop/UPower/devices/battery_BAT1`;

        my $dinfo = df('/', 1);     # output is bytes

Next we need to give some space for two new lines: /usr/share/pve-manager/js/pvemanagerlib.js
The only thing we need to change - height, make it 380 for three extra lines.
JavaScript:
Ext.define('PVE.node.StatusView', {
    extend: 'Proxmox.panel.StatusView',
    alias: 'widget.pveNodeStatus',

    height: 380,
    bodyPadding: '15 5 15 5',

Next step is to parse and render data. We do it in the same file, locate PVE Manager Version line and add elements with temperature, battery charge, battery wearout.
JavaScript:
        {
            itemId: 'version',
            colspan: 2,
            printBar: false,
            title: gettext('PVE Manager Version'),
            textField: 'pveversion',
            value: '',
        },
        {
            itemId: 'thermal',
            colspan: 2,
            printBar: false,
            title: gettext('CPU Themperature'),
            textField: 'thermalstate',
            renderer: function(value) {
                 let objValue = JSON.parse(value);
                 let package = objValue["coretemp-isa-0000"]["Package id 0"]["temp1_input"];
                 return `Package:${package}°C`;
            }
        },
        {
            itemId: 'battery',
            colspan: 2,
            printBar: false,
            title: gettext('Battery charge'),
            textField: 'batterystate',
            renderer: function(value) {
                 const voltage = value.match(/voltage:.*?(\d*[,.]\d*)\s*?V/)[1];
                 const percentage = value.match(/percentage:.*?([\d\.]+)%/)[1];
                 return `${voltage}V  ${percentage}%`;
            }
        },
        {
            itemId: 'batteryhealth',
            colspan: 2,
            printBar: false,
            title: gettext('Battery wearout'),
            textField: 'batterystate',
            renderer: function(value) {
                 const energyfd = value.match(/energy-full-design:.*?(\d*[,.]\d*)\s*?Wh/)[1];
                 const energyf = value.match(/energy-full:.*?(\d*[,.]\d*)\s*?Wh/)[1];
                 const capacity = value.match(/capacity:.*?([\d\.]+)%/)[1];
                 return `${energyf} Wh max / ${energyfd} Wh design = ${capacity}%`;
            }
        }


Command to see changes:
systemctl restart pveproxy
If UI can't load - first comment or remove blocks one by one from file pvemanagerlib. First one only provides information and shouldn't break anything.
 
  • Like
Reactions: no-usernames-left
This looks very promising, thanks for sharing. What would be left missing to be solved (I mean for me, I am just starting) is the ability to shutdown the server when the temperature reaches a certain level. If I run sensors, it says (high = 79º crit = 89º), so I have three questions: 1) what is the typical temperature to initiate a temperature shutdown ? 2) how to automate a pve shutdown ? 3) how does that impact on the guests ? I guess someone can point me to a good tutorial :)
 
If it's an intel cpu, look into ARK.

Normally the CPU will automatically throttle down if it gets too hot, so you don't have to shutdown.
Thanks. I guess you mean I should take a look here. https://ark.intel.com/content/www/us/en/ark.html

I will see where it leads me.

Actually it is my first experience with proxmox, a couple of Dell servers , a USB connected UPS (I got Nut ups to communicate, I need to figure how to initiate a server shutdown still) and air conditioning on the room. I guess I will figure out soon how to shutdown the proxmox servers based on battery status.

If I run ups myups | grep "ups.temperature" I can get what the ups reports as temperature, wherever that sensor is located. From the reading I get I guess it is room temperature or very similar, so I am guessing I could also use that information to eventually start a shutdown if room temperature starts getting hot.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!