diff --git a/NEWS b/NEWS index bf94e756..ae64db73 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Enhancements and new features: * Allow export of Docker and sensors plugins stats to InfluxDB, StatsD... (issue #600) * Server password configuration for the browser mode (issue #500) + * Support Fahrenheit unit in the sensor plugin using the --fahrenheit command line option (issue #620) * Display an error if export is not used in the standalone/client mode (issue #614) Version 2.4.2 diff --git a/conf/glances.conf b/conf/glances.conf index 2773a53f..16f04594 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -96,7 +96,7 @@ critical=90 #allow=zfs [sensors] -# Sensors core limits +# Sensors core limits (in Celsius...) # Default values if not defined: 60/70/80 temperature_core_careful=60 temperature_core_warning=70 diff --git a/glances/core/glances_main.py b/glances/core/glances_main.py index b278160e..433559ea 100644 --- a/glances/core/glances_main.py +++ b/glances/core/glances_main.py @@ -188,6 +188,8 @@ Start the client browser (browser mode):\n\ dest='process_tree', help='display processes as a tree') parser.add_argument('-b', '--byte', action='store_true', default=False, dest='byte', help='display network rate in byte per second') + parser.add_argument('--fahrenheit', action='store_true', default=False, + dest='fahrenheit', help='display temperature in Fahrenheit (default is Celsius)') parser.add_argument('-1', '--percpu', action='store_true', default=False, dest='percpu', help='start Glances in per CPU mode') parser.add_argument('--fs-free-space', action='store_false', default=False, diff --git a/glances/plugins/glances_sensors.py b/glances/plugins/glances_sensors.py index e4ff1109..679bc1d2 100644 --- a/glances/plugins/glances_sensors.py +++ b/glances/plugins/glances_sensors.py @@ -194,8 +194,15 @@ class Plugin(GlancesPlugin): msg = "{0:12} {1:3}".format(label[:11], i['unit']) except (KeyError, UnicodeEncodeError): msg = "{0:16}".format(label[:15]) + if args.fahrenheit: + msg = msg.replace('°C', '°F') ret.append(self.curse_add_line(msg)) - msg = '{0:>7}'.format(i['value']) + if args.fahrenheit: + # Convert Celsius to Fahrenheit + # T(°F) = T(°C) × 1.8 + 32 + msg = '{0:>7}'.format(i['value'] * 1.8 + 32) + else: + msg = '{0:>7}'.format(i['value']) ret.append(self.curse_add_line( msg, self.get_views(item=i[self.get_key()], key='value',