From 7724cdb6288fe9c60a0235a6bb37df2d72795d7d Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:08:58 +0100 Subject: [PATCH 1/6] don't drop the original message on parsing stats --- lib/vsc/utils/nagios.py | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vsc/utils/nagios.py b/lib/vsc/utils/nagios.py index 4f3e685..a02974f 100644 --- a/lib/vsc/utils/nagios.py +++ b/lib/vsc/utils/nagios.py @@ -524,6 +524,7 @@ def _eval(self, **kwargs): warn = True msg.append(k) + msg.append(self.message) return warn, crit, ', '.join(msg) def _eval_and_exit(self, **kwargs): diff --git a/setup.py b/setup.py index 8b058ad..51c38d6 100755 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ ] PACKAGE = { - 'version': '2.2.7', + 'version': '2.2.8', 'author': [ag, sdw], 'maintainer': [ag, sdw], 'excluded_pkgs_rpm': ['vsc', 'vsc.utils'], # vsc is default, vsc.utils is provided by vsc-base From 5b52f3410a2b7890aa5b1e6b89cf507e9750b24c Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:15:55 +0100 Subject: [PATCH 2/6] update workflow --- .github/workflows/unittest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 53d927b..75f0cd0 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -6,9 +6,9 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - name: install tox From 667d28a3c5bc6dbd225f1dfc51138e312b4c273e Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:18:07 +0100 Subject: [PATCH 3/6] catch None type --- lib/vsc/utils/nagios.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vsc/utils/nagios.py b/lib/vsc/utils/nagios.py index a02974f..cd3dc1e 100644 --- a/lib/vsc/utils/nagios.py +++ b/lib/vsc/utils/nagios.py @@ -523,8 +523,8 @@ def _eval(self, **kwargs): if "warning" in v and NagiosRange(v['warning']).alert(v['value']): warn = True msg.append(k) - - msg.append(self.message) + if self.message: + msg.append(self.message) return warn, crit, ', '.join(msg) def _eval_and_exit(self, **kwargs): From 7ed68d066e58bae096d96f00470c3d388ba0d940 Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:23:04 +0100 Subject: [PATCH 4/6] fix some tests --- test/nagios_simple.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/nagios_simple.py b/test/nagios_simple.py index c44658b..b600e21 100644 --- a/test/nagios_simple.py +++ b/test/nagios_simple.py @@ -109,13 +109,13 @@ def test_simple_single_instance(self): self._basic_test_single_instance(kwargs, 'OK hello | value1=5;5;10;', NAGIOS_EXIT_OK) # goutside warning range, perfdata with warning in message kwargs['value1'] = 7 - self._basic_test_single_instance(kwargs, 'WARNING value1 | value1=7;5;10;', NAGIOS_EXIT_WARNING) + self._basic_test_single_instance(kwargs, 'WARNING value1, hello | value1=7;5;10;', NAGIOS_EXIT_WARNING) # outside critical range? kwargs['value1'] = 10 - self._basic_test_single_instance(kwargs, 'WARNING value1 | value1=10;5;10;', NAGIOS_EXIT_WARNING) + self._basic_test_single_instance(kwargs, 'WARNING value1, hello | value1=10;5;10;', NAGIOS_EXIT_WARNING) # greater kwargs['value1'] = 15 - self._basic_test_single_instance(kwargs, 'CRITICAL value1 | value1=15;5;10;', NAGIOS_EXIT_CRITICAL) + self._basic_test_single_instance(kwargs, 'CRITICAL value1, hello | value1=15;5;10;', NAGIOS_EXIT_CRITICAL) # mixed kwargsmore = { From abea02996f1f54e5b1a20ea0f247743fa3577997 Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:26:32 +0100 Subject: [PATCH 5/6] fix some tests --- test/nagios_simple.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/nagios_simple.py b/test/nagios_simple.py index b600e21..63e3d59 100644 --- a/test/nagios_simple.py +++ b/test/nagios_simple.py @@ -129,22 +129,22 @@ def test_simple_single_instance(self): kwargs.update(kwargsmore) # critical value in message - self._basic_test_single_instance(kwargs, 'CRITICAL value1 | value0=3;5;10; value1=15;5;10; value2=7;5;10;', + self._basic_test_single_instance(kwargs, 'CRITICAL value1, hello | value0=3;5;10; value1=15;5;10; value2=7;5;10;', NAGIOS_EXIT_CRITICAL) # all warning values in message kwargs['value1'] = 7 self._basic_test_single_instance( - kwargs, 'WARNING value1, value2 | value0=3;5;10; value1=7;5;10; value2=7;5;10;', NAGIOS_EXIT_WARNING) + kwargs, 'WARNING value1, value2, hello | value0=3;5;10; value1=7;5;10; value2=7;5;10;', NAGIOS_EXIT_WARNING) # warning in message kwargs['value1'] = 5 - self._basic_test_single_instance(kwargs, 'WARNING value2 | value0=3;5;10; value1=5;5;10; value2=7;5;10;', + self._basic_test_single_instance(kwargs, 'WARNING value2, hello | value0=3;5;10; value1=5;5;10; value2=7;5;10;', NAGIOS_EXIT_WARNING) # no warning/critical; so regular message kwargs['value2'] = 5 - self._basic_test_single_instance(kwargs, 'OK hello | value0=3;5;10; value1=5;5;10; value2=5;5;10;', + self._basic_test_single_instance(kwargs, 'OK hello, hello | value0=3;5;10; value1=5;5;10; value2=5;5;10;', NAGIOS_EXIT_OK) From 21cdc95502c6d8305e9e25ee6c7059b20ff379bd Mon Sep 17 00:00:00 2001 From: Wouter Depypere Date: Thu, 31 Oct 2024 13:28:49 +0100 Subject: [PATCH 6/6] fix some tests --- test/nagios_simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/nagios_simple.py b/test/nagios_simple.py index 63e3d59..c973d75 100644 --- a/test/nagios_simple.py +++ b/test/nagios_simple.py @@ -144,7 +144,7 @@ def test_simple_single_instance(self): # no warning/critical; so regular message kwargs['value2'] = 5 - self._basic_test_single_instance(kwargs, 'OK hello, hello | value0=3;5;10; value1=5;5;10; value2=5;5;10;', + self._basic_test_single_instance(kwargs, 'OK hello | value0=3;5;10; value1=5;5;10; value2=5;5;10;', NAGIOS_EXIT_OK)