Celsius to Fahrenheit patch (unofficial)

I got tired of dealing with Celsius readings. While I have nothing against Celsius, my small part of the world uses Fahrenheit and I haven’t yet got the Celsius values to register in my head.

I edited the file at /opt/librenms/includes/polling/functions.inc.php and inserted this bit of code around line 178. if ($class == "Temperature") {$sensor_value = ($sensor_value * 1.8) + 32;}

I haven’t tested it extensively but after an hour of running with 84 diverse devices in our LibreNMS instance it hasn’t broke anything yet.

This converts all temperatures from Celsius to Fahrenheit when they are collected and stores them as Fahrenheit. It does not fix all the places in the web UI that use the °C designation. For my needs I only needed to edit the file /opt/librens/includes/html/pages/device/overview/sensors/temperature.inc.php and change the “C” to an “F”. That makes the readings look right in the device overviews. The charts still show a C but I’m just living with that at the moment, I know all values are F so it’s ok.

1 Like

You should submit your code in git hub as a pull request to help the community. :slight_smile:

Well this feels pretty crunchy yet. If it goes public it would be nice to have all references changed from C to F and actually have a setting where you could switch back and forth.

Better yet, and I couldn’t find where to do this, I would rather see it still stored in Celsius but converted as it gets passed to the browser for viewing. But that requires finding every place where you input a temperature (alert settings etc) and the code that handles that has to do F to C conversion on save.

Every temperature value passes through the point I edited I believe so that was the quick and dirty way to get it done.

I’m really not sure what method would be the best…