Support Fahrenheit (issue #620)

pull/630/head
nicolargo 2015-06-19 23:14:21 +02:00
parent 4b1f5a2731
commit 5b397d8e90
4 changed files with 12 additions and 2 deletions

1
NEWS
View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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',