Skip to content

Commit

Permalink
Merge pull request #96 from wdpypere/nagios_result
Browse files Browse the repository at this point in the history
don't drop the original message on parsing stats
  • Loading branch information
stdweird authored Oct 31, 2024
2 parents 3abd968 + 21cdc95 commit 7041b46
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/vsc/utils/nagios.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ def _eval(self, **kwargs):
if "warning" in v and NagiosRange(v['warning']).alert(v['value']):
warn = True
msg.append(k)

if self.message:
msg.append(self.message)
return warn, crit, ', '.join(msg)

def _eval_and_exit(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/nagios_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -129,17 +129,17 @@ 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
Expand Down

0 comments on commit 7041b46

Please sign in to comment.