Module: check_mk
Branch: master
Commit: 3b47bc8cdb43bc706cc49a371b8b30899c8651c7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3b47bc8cdb43bc…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu May 17 13:54:59 2018 +0200
6109 FIX temperature.include, etherbox.temp: fix unicode error
Use unicode strings for the units in temperature.include and remove
UTF-8 decoding in etherbox.temp. Adapt ra32e_sensors tests to work
correctly.
Change-Id: Ibb50cf652016e1b291b41cc8f936568d003ecedb
---
.werks/6109 | 13 +++++++++++++
checks/etherbox | 2 +-
checks/temperature.include | 4 ++--
tests/unit/checks/test_ra32e_sensors_check.py | 14 +++++++-------
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/.werks/6109 b/.werks/6109
new file mode 100644
index 0000000..4d3530e
--- /dev/null
+++ b/.werks/6109
@@ -0,0 +1,13 @@
+Title: temperature.include, etherbox.temp: fix unicode error
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1526558045
+
+Use unicode strings for the units in temperature.include and remove
+UTF-8 decoding in etherbox.temp. Adapt ra32e_sensors tests to work
+correctly.
diff --git a/checks/etherbox b/checks/etherbox
index 1721f98..61591e0 100644
--- a/checks/etherbox
+++ b/checks/etherbox
@@ -103,7 +103,7 @@ def check_etherbox_temp(item, params, info):
uom = { "0": "c", "1": "f", "2":
"k" }[info[0][0][0]]
temp = int(value) / 10.0
state, infotext, perfdata = check_temperature(temp, params,
"etherbox_temp_%s" % item, uom)
- return state, "[%s] %s" % (name, infotext.decode("utf8")),
perfdata
+ return state, "[%s] %s" % (name, infotext), perfdata
check_info["etherbox.temp"] = {
diff --git a/checks/temperature.include b/checks/temperature.include
index c7748dc..73268d5 100644
--- a/checks/temperature.include
+++ b/checks/temperature.include
@@ -82,8 +82,8 @@ def render_temp(n, output_unit, relative=False):
return "%.1f" % t
temp_unitsym = {
- "c": "°C",
- "f": "°F",
+ "c": u"°C",
+ "f": u"°F",
"k": "K",
}
diff --git a/tests/unit/checks/test_ra32e_sensors_check.py
b/tests/unit/checks/test_ra32e_sensors_check.py
index b5b2dc4..06df2ed 100644
--- a/tests/unit/checks/test_ra32e_sensors_check.py
+++ b/tests/unit/checks/test_ra32e_sensors_check.py
@@ -14,7 +14,7 @@ pytestmark = pytest.mark.checks
('ra32e_sensors.humidity', []),
],
[
- ('ra32e_sensors', "Internal", {}, BasicCheckResult(0,
'20.7 °C', [('temp', 20.70)])),
+ ('ra32e_sensors', "Internal", {}, BasicCheckResult(0,
u'20.7 °C', [('temp', 20.70)])),
('ra32e_sensors', "Heat Index", {}, BasicCheckResult(3,
'no data for sensor')),
('ra32e_sensors.humidity', "Internal", {},
BasicCheckResult(3, 'no data for sensor')),
]
@@ -29,7 +29,7 @@ pytestmark = pytest.mark.checks
('ra32e_sensors', "Internal", {},
BasicCheckResult(3, 'no data for sensor')),
('ra32e_sensors', "Heat Index", {},
- BasicCheckResult(0, '20.7 °C', [('temp', 20.70)])),
+ BasicCheckResult(0, u'20.7 °C', [('temp', 20.70)])),
('ra32e_sensors.humidity', "Internal", {},
BasicCheckResult(0, '60.0%', [('humidity', 60.0, 101, 101,
0, 100)])),
]
@@ -41,7 +41,7 @@ pytestmark = pytest.mark.checks
],
[
('ra32e_sensors', "Sensor 2", {},
- BasicCheckResult(0, '25.8 °C', [('temp', 25.8)])),
+ BasicCheckResult(0, u'25.8 °C', [('temp', 25.8)])),
]
),
( # temp/active sensor
@@ -52,7 +52,7 @@ pytestmark = pytest.mark.checks
],
[
('ra32e_sensors', "Sensor 5", {'levels': (30.0,
35.0)},
- BasicCheckResult(1, '31.0 °C (warn/crit at 30.0/35.0 °C)',
[('temp', 31.0, 30.0, 35.0)])),
+ BasicCheckResult(1, u'31.0 °C (warn/crit at 30.0/35.0 °C)',
[('temp', 31.0, 30.0, 35.0)])),
('ra32e_sensors.power', "Sensor 5", {},
BasicCheckResult(2, 'Device status: no power detected(2)')),
('ra32e_sensors.power', "Sensor 5",
{'map_device_states': [('no power detected', 1)]},
@@ -69,13 +69,13 @@ pytestmark = pytest.mark.checks
],
[
('ra32e_sensors', "Sensor 8", {},
- BasicCheckResult(0, '25.8 °C', [('temp', 25.8)])),
+ BasicCheckResult(0, u'25.8 °C', [('temp', 25.8)])),
('ra32e_sensors', "Heat Index 1", {'levels': (27.0,
28.0)},
- BasicCheckResult(2, '28.0 °C (warn/crit at 27.0/28.0 °C)',
[('temp', 28.0, 27.0, 28.0)])),
+ BasicCheckResult(2, u'28.0 °C (warn/crit at 27.0/28.0 °C)',
[('temp', 28.0, 27.0, 28.0)])),
('ra32e_sensors.voltage', "Sensor 8", {'voltage':
(210, 180)},
BasicCheckResult(1, 'Voltage: 200 V (warn/crit below 210/180 V)',
[('voltage', 200)])),
('ra32e_sensors', "Sensor 1", {'levels_lower':
(30.0, 25.0)},
- BasicCheckResult(1, '27.9 °C (warn/crit below 30.0/25.0 °C)',
[('temp', 27.9)])),
+ BasicCheckResult(1, u'27.9 °C (warn/crit below 30.0/25.0 °C)',
[('temp', 27.9)])),
('ra32e_sensors.humidity', "Sensor 1",
{'levels_lower': (85.0, 75.0)},
BasicCheckResult(1, '75.0% (warn/crit below 85.0%/75.0%)',
[('humidity', 75.0, None, None, 0, 100)])),
]),