diff --git a/check_monit.py b/check_monit.py index 96dc452..0e2c30f 100755 --- a/check_monit.py +++ b/check_monit.py @@ -94,7 +94,7 @@ def get_service_output(service_type, element): load1 = float(element.findall('system/load/avg01')[0].text) load5 = float(element.findall('system/load/avg05')[0].text) load15 = float(element.findall('system/load/avg15')[0].text) - output.append('load={0},{1},{2}'.format(load1, load5, load15)) + output.append('load1={0};load5={1};load15={2}'.format(load1, load5, load15)) user = float(element.findall('system/cpu/user')[0].text) system = float(element.findall('system/cpu/system')[0].text) diff --git a/test_check_monit.py b/test_check_monit.py index 8034a65..79edd5b 100644 --- a/test_check_monit.py +++ b/test_check_monit.py @@ -108,7 +108,7 @@ def test_main_xml_error(self, mock_get, mock_print): def test_main_ok(self, mock_get, mock_print): args = commandline(['-H', 'localhost', '-P', 'password', '-U', 'user']) - d = """e4a88a4293441301bf72d6ee07dd4af216926070155.33.030450scratch/root/.monitrc
::1
80800
Linux5.10#1 SMP Debianx86_64220305200scratch1692607316642649001000672092233720368547758070.000.000.000.10.10.00.00.00.40.00.00.010.62147040.00
""" + d = """e4a88a4293441301bf72d6ee07dd4af216926070155.33.030450scratch/root/.monitrc
::1
80800
Linux5.10#1 SMP Debianx86_64220305200scratch1692607316642649001000672092233720368547758071.234.567.890.10.10.00.00.00.40.00.00.010.62147040.00
""" mock_get.return_value = MockRequest(200, d) @@ -118,7 +118,7 @@ def test_main_ok(self, mock_get, mock_print): calls = [mock.call('[OK]: Monit Service Status 1/1'), mock.call(' \\_ [OK]: scratch'), - mock.call(' load=0.0,0.0,0.0;user=0.1%;system=0.1%;nice=0.0%;hardirq=0.0%;memory=10.6%')] + mock.call(' load1=1.23;load5=4.56;load15=7.89;user=0.1%;system=0.1%;nice=0.0%;hardirq=0.0%;memory=10.6%')] mock_print.assert_has_calls(calls) @@ -127,7 +127,7 @@ def test_main_ok(self, mock_get, mock_print): def test_main_critical(self, mock_get, mock_print): args = commandline(['-H', 'localhost', '-P', 'password', '-U', 'user']) - d = """e4a88a4293441301bf72d6ee07dd4af216926070155.33.030450scratch/root/.monitrc
::1
80800
Linux5.10#1 SMP Debianx86_64220305200scratch1692607316642649101000672092233720368547758070.000.000.000.10.10.00.00.00.40.00.00.010.62147040.00
""" + d = """e4a88a4293441301bf72d6ee07dd4af216926070155.33.030450scratch/root/.monitrc
::1
80800
Linux5.10#1 SMP Debianx86_64220305200scratch1692607316642649101000672092233720368547758071.234.567.890.10.10.00.00.00.40.00.00.010.62147040.00
""" mock_get.return_value = MockRequest(200, d) @@ -137,6 +137,6 @@ def test_main_critical(self, mock_get, mock_print): calls = [mock.call('[CRITICAL]: Monit Service Status 0/1'), mock.call(' \\_ [CRITICAL]: scratch'), - mock.call(' load=0.0,0.0,0.0;user=0.1%;system=0.1%;nice=0.0%;hardirq=0.0%;memory=10.6%')] + mock.call(' load1=1.23;load5=4.56;load15=7.89;user=0.1%;system=0.1%;nice=0.0%;hardirq=0.0%;memory=10.6%')] mock_print.assert_has_calls(calls)