Skip to content

Commit 7041b46

Browse files
authored
Merge pull request #96 from wdpypere/nagios_result
don't drop the original message on parsing stats
2 parents 3abd968 + 21cdc95 commit 7041b46

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

.github/workflows/unittest.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
runs-on: ubuntu-20.04
77
steps:
88
- name: Checkout code
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010
- name: Setup Python
11-
uses: actions/setup-python@v4
11+
uses: actions/setup-python@v5
1212
with:
1313
python-version: ${{ matrix.python }}
1414
- name: install tox

lib/vsc/utils/nagios.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ def _eval(self, **kwargs):
523523
if "warning" in v and NagiosRange(v['warning']).alert(v['value']):
524524
warn = True
525525
msg.append(k)
526-
526+
if self.message:
527+
msg.append(self.message)
527528
return warn, crit, ', '.join(msg)
528529

529530
def _eval_and_exit(self, **kwargs):

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
]
4242

4343
PACKAGE = {
44-
'version': '2.2.7',
44+
'version': '2.2.8',
4545
'author': [ag, sdw],
4646
'maintainer': [ag, sdw],
4747
'excluded_pkgs_rpm': ['vsc', 'vsc.utils'], # vsc is default, vsc.utils is provided by vsc-base

test/nagios_simple.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ def test_simple_single_instance(self):
109109
self._basic_test_single_instance(kwargs, 'OK hello | value1=5;5;10;', NAGIOS_EXIT_OK)
110110
# goutside warning range, perfdata with warning in message
111111
kwargs['value1'] = 7
112-
self._basic_test_single_instance(kwargs, 'WARNING value1 | value1=7;5;10;', NAGIOS_EXIT_WARNING)
112+
self._basic_test_single_instance(kwargs, 'WARNING value1, hello | value1=7;5;10;', NAGIOS_EXIT_WARNING)
113113
# outside critical range?
114114
kwargs['value1'] = 10
115-
self._basic_test_single_instance(kwargs, 'WARNING value1 | value1=10;5;10;', NAGIOS_EXIT_WARNING)
115+
self._basic_test_single_instance(kwargs, 'WARNING value1, hello | value1=10;5;10;', NAGIOS_EXIT_WARNING)
116116
# greater
117117
kwargs['value1'] = 15
118-
self._basic_test_single_instance(kwargs, 'CRITICAL value1 | value1=15;5;10;', NAGIOS_EXIT_CRITICAL)
118+
self._basic_test_single_instance(kwargs, 'CRITICAL value1, hello | value1=15;5;10;', NAGIOS_EXIT_CRITICAL)
119119

120120
# mixed
121121
kwargsmore = {
@@ -129,17 +129,17 @@ def test_simple_single_instance(self):
129129
kwargs.update(kwargsmore)
130130

131131
# critical value in message
132-
self._basic_test_single_instance(kwargs, 'CRITICAL value1 | value0=3;5;10; value1=15;5;10; value2=7;5;10;',
132+
self._basic_test_single_instance(kwargs, 'CRITICAL value1, hello | value0=3;5;10; value1=15;5;10; value2=7;5;10;',
133133
NAGIOS_EXIT_CRITICAL)
134134

135135
# all warning values in message
136136
kwargs['value1'] = 7
137137
self._basic_test_single_instance(
138-
kwargs, 'WARNING value1, value2 | value0=3;5;10; value1=7;5;10; value2=7;5;10;', NAGIOS_EXIT_WARNING)
138+
kwargs, 'WARNING value1, value2, hello | value0=3;5;10; value1=7;5;10; value2=7;5;10;', NAGIOS_EXIT_WARNING)
139139

140140
# warning in message
141141
kwargs['value1'] = 5
142-
self._basic_test_single_instance(kwargs, 'WARNING value2 | value0=3;5;10; value1=5;5;10; value2=7;5;10;',
142+
self._basic_test_single_instance(kwargs, 'WARNING value2, hello | value0=3;5;10; value1=5;5;10; value2=7;5;10;',
143143
NAGIOS_EXIT_WARNING)
144144

145145
# no warning/critical; so regular message

0 commit comments

Comments
 (0)