From 8c1abefb170e79a855065f10bf7e5f1c8b837939 Mon Sep 17 00:00:00 2001 From: Markus Frei Date: Tue, 9 Jul 2024 13:43:38 +0200 Subject: [PATCH] service: Minor improvements --- CHANGELOG.md | 13 ++++++++----- check-plugins/service/README.rst | 9 +++++---- check-plugins/service/service | 6 ++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fed7b0cf..59d9cd38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,16 +11,19 @@ and this project does NOT adhere to [Semantic Versioning](https://semver.org/spe ## [Unreleased] +### Breaking Changes + +Monitoring Plugins: + +* service: Implement `--starttype`, as code was missing (parameter is now appending); implement unit-tests + + ### Fixed ("bug") Icinga Director: * crypto-policy: New defaults according to LFOps crypto_policy role -* mysql-query: fix director basket - -Monitoring Plugins: - -* service: Implement `--starttype` as code was missing; implement unit-tests +* mysql-query: Fix director basket ## 2024060401 diff --git a/check-plugins/service/README.rst b/check-plugins/service/README.rst index 8cd72239..b12be541 100644 --- a/check-plugins/service/README.rst +++ b/check-plugins/service/README.rst @@ -16,7 +16,8 @@ Example: Hints: * For use in Icinga Director: If the service name contains a ``$``, this dollar sign must be escaped with another dollar sign. Since the plugin is capable of regular expressions, this character must also be escaped with a backslash. So if you want to check ``my$service``, you have to specify ``my\$$service``. -* On the command line: If you want to check ``my$service``, you have to specify ``my\$service``. +* On the Windows command line: If you want to check ``my$service``, you have to specify ``my\$service``. +* On the Windows command line: Only use double quotes to provide regexes to ``--service``; if running unit tests on Linux, use single quotes instead. Fact Sheet @@ -74,7 +75,7 @@ Check that exactly one service named "BFE" (exact match) is running, otherwise W .. code-block:: bash - service --service='^bfe$' --status=running --warning=1:1 + service --service="^bfe$" --status=running --warning=1:1 Output: @@ -90,7 +91,7 @@ Check that there are at least 10 but not more than 20 Windows Services named "my .. code-block:: bash - service --service='^myapp[0-9]{4}$' --starttype=automatic --status=running --warning=10:19 + service --service="^myapp[0-9]{4}$" --starttype=automatic --status=running --warning=10:19 Output: @@ -107,7 +108,7 @@ Check that ALL services with startup type "automatic" are running, except for a .. code-block:: bash - service --service='^(?!DPS|MSDTC|MapsBroker|UsoSvc|Dnscache|gpsvc$).*$' --starttype=automatic --status=continue_pending --status=pause_pending --status=paused --status=start_pending --status=stop_pending --status=stopped --warning 0 + service --service="^(?!DPS|MSDTC|MapsBroker|UsoSvc|Dnscache|gpsvc$).*$" --starttype=automatic --status=continue_pending --status=pause_pending --status=paused --status=start_pending --status=stop_pending --status=stopped --warning 0 Output (shortened): diff --git a/check-plugins/service/service b/check-plugins/service/service index 6614f77a..b99ab69b 100755 --- a/check-plugins/service/service +++ b/check-plugins/service/service @@ -28,7 +28,7 @@ except ImportError: __author__ = 'Linuxfabrik GmbH, Zurich/Switzerland' -__version__ = '2024070901' +__version__ = '2024070902' DESCRIPTION = '''Checks the state of one or more Windows services. You have to provide the case-insensitive "Service Name", not the "Display Name". Supports Python regular @@ -192,8 +192,10 @@ def main(): except re.error as rerr: lib.base.cu('Invalid regex "{}": {}'.format(args.SERVICE, rerr)) except psutil.NoSuchProcess: - lib.base.cu('Service `{}` not found'.format(args.SERVICE)) + lib.base.cu('r`{}` does not match any service name.'.format(args.SERVICE)) + if not table_data: + lib.base.cu('r`{}` does not match any service name.'.format(args.SERVICE)) svc_cnt = len(table_data) # build the message