diff --git a/mnpw/nagios.py b/mnpw/nagios.py index 74f34006e1fa626c7cc63a11073b842cbad0dfb9..dd5bbdc16464f078aaaa1cd135e893cbd5f99610 100644 --- a/mnpw/nagios.py +++ b/mnpw/nagios.py @@ -50,12 +50,12 @@ def parse_perf_data(line): # noqa: MC0001 for i in range(len(value) - 1, 0, -1): if value[i].isdigit(): break - value, unit = ( + pd["value"], pd["unit"] = ( float(value[: i + 1]), value[i + 1 :], # noqa: E203 ) - pd["value"] = value - pd["unit"] = unit + else: + pd["value"] = float(value) # Get the remaining fields, if available. try: diff --git a/tests/test_nagios.py b/tests/test_nagios.py index a021e3aa9dbc7e0e221a900c0a7dc313a5cf80f2..385961b71c5bd1939c67162c7317f2258059f775 100644 --- a/tests/test_nagios.py +++ b/tests/test_nagios.py @@ -119,8 +119,7 @@ def test_data_perf(line): assert isinstance(pd.name, str) assert len(pd.name) > 0 assert isinstance(pd.value, float) - assert isinstance(pd.unit, str) - assert len(pd.unit) > 0 + assert isinstance(pd.unit, (str, type(None))) assert isinstance(pd.warning, (float, type(None))) assert isinstance(pd.critical, (float, type(None))) assert isinstance(pd.min, (float, type(None)))