Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't drop the original message on parsing stats #96

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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