check_systemd 2.0.8__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: check_systemd
3
- Version: 2.0.8
3
+ Version: 2.1.0
4
4
  Summary: Nagios / Icinga monitoring plugin to check systemd for failed units.
5
5
  Home-page: https://github.com/Josef-Friedrich/check_systemd
6
6
  Author: Josef Friedrich
@@ -11,12 +11,16 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
11
11
 
12
12
  # check_systemd
13
13
 
14
- Nagios / Icinga monitoring plugin to check systemd for failed units.
14
+ `check_systemd` is a
15
+ [Nagios](https://www.nagios.org) / [Icinga](https://icinga.com)
16
+ monitoring plugin to check [systemd](https://systemd.io) for failed
17
+ units.
15
18
 
16
- This Python script will report a degraded system to Nagios / Icinga.
17
- It requires only the nagiosplugin library.
19
+ This Python script will report a degraded system to your monitoring solution.
20
+ It requires only the
21
+ [nagiosplugin](https://nagiosplugin.readthedocs.io/en/stable) library.
18
22
 
19
- You can also test a single service with -s parameter.
23
+ You can also test a single service with the `-u, --unit` parameter.
20
24
 
21
25
  Released under GNU GPLv2 License.
22
26
 
@@ -29,10 +33,10 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
29
33
  ## Command line interface
30
34
 
31
35
  ```
32
- usage: nosetests [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
36
+ usage: check_systemd [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
33
37
 
34
38
  Copyright (c) 2014-18 Andrea Briganti a.k.a 'Kbyte' <kbytesys@gmail.com>
35
- Copyright (c) 2019 Josef Friedrich <josef@friedrich.rocks>
39
+ Copyright (c) 2019-20 Josef Friedrich <josef@friedrich.rocks>
36
40
 
37
41
  Nagios / Icinga monitoring plugin to check systemd for failed units.
38
42
 
@@ -41,10 +45,10 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
41
45
  -c SECONDS, --critical SECONDS
42
46
  Startup time in seconds to result in critical status.
43
47
  -e UNIT, --exclude UNIT
44
- Exclude a systemd unit from the checks. This option
45
- can be applied multiple times. For example: -e mnt-
46
- data.mount -e task.service.
47
- -u UNIT, --unit UNIT Name of the systemd unit that is beeing tested.
48
+ Exclude a systemd unit from the checks. This option can be applied multiple times, for example: -e mnt-data.mount -e
49
+ task.service. Regular expressions can be used to exclude multiple units at once, for example: -e 'user@\d+\.service'. For
50
+ more informations see the Python documentation about regular expressions (https://docs.python.org/3/library/re.html).
51
+ -u UNIT, --unit UNIT Name of the systemd unit that is being tested.
48
52
  -v, --verbose Increase output verbosity (use up to 3 times).
49
53
  -V, --version show program's version number and exit
50
54
  -w SECONDS, --warning SECONDS
@@ -64,14 +68,27 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
64
68
 
65
69
  * https://github.com/Josef-Friedrich/check_systemd
66
70
  * https://exchange.icinga.com/joseffriedrich/check_systemd
67
- * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd
71
+ * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd/details
68
72
 
69
73
  ## Testing
70
74
 
71
75
  ```
76
+ pyenv install 3.7.6
77
+ pyenv install 3.8.1
78
+ pyenv local 3.7.6 3.8.1
72
79
  pip3 install tox
73
80
  tox
74
81
  ```
82
+
83
+ ## Deploying
84
+
85
+ Edit version number in check_systemd.py (without `v`)
86
+
87
+ ```
88
+ git tag v2.0.11
89
+ git push --tags
90
+ ```
91
+
75
92
  Keywords: nagios,systemd
76
93
  Platform: UNKNOWN
77
94
  Classifier: Development Status :: 5 - Production/Stable
@@ -3,12 +3,16 @@
3
3
 
4
4
  # check_systemd
5
5
 
6
- Nagios / Icinga monitoring plugin to check systemd for failed units.
6
+ `check_systemd` is a
7
+ [Nagios](https://www.nagios.org) / [Icinga](https://icinga.com)
8
+ monitoring plugin to check [systemd](https://systemd.io) for failed
9
+ units.
7
10
 
8
- This Python script will report a degraded system to Nagios / Icinga.
9
- It requires only the nagiosplugin library.
11
+ This Python script will report a degraded system to your monitoring solution.
12
+ It requires only the
13
+ [nagiosplugin](https://nagiosplugin.readthedocs.io/en/stable) library.
10
14
 
11
- You can also test a single service with -s parameter.
15
+ You can also test a single service with the `-u, --unit` parameter.
12
16
 
13
17
  Released under GNU GPLv2 License.
14
18
 
@@ -21,10 +25,10 @@ pip3 install check_systemd
21
25
  ## Command line interface
22
26
 
23
27
  ```
24
- usage: nosetests [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
28
+ usage: check_systemd [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
25
29
 
26
30
  Copyright (c) 2014-18 Andrea Briganti a.k.a 'Kbyte' <kbytesys@gmail.com>
27
- Copyright (c) 2019 Josef Friedrich <josef@friedrich.rocks>
31
+ Copyright (c) 2019-20 Josef Friedrich <josef@friedrich.rocks>
28
32
 
29
33
  Nagios / Icinga monitoring plugin to check systemd for failed units.
30
34
 
@@ -33,10 +37,10 @@ optional arguments:
33
37
  -c SECONDS, --critical SECONDS
34
38
  Startup time in seconds to result in critical status.
35
39
  -e UNIT, --exclude UNIT
36
- Exclude a systemd unit from the checks. This option
37
- can be applied multiple times. For example: -e mnt-
38
- data.mount -e task.service.
39
- -u UNIT, --unit UNIT Name of the systemd unit that is beeing tested.
40
+ Exclude a systemd unit from the checks. This option can be applied multiple times, for example: -e mnt-data.mount -e
41
+ task.service. Regular expressions can be used to exclude multiple units at once, for example: -e 'user@\d+\.service'. For
42
+ more informations see the Python documentation about regular expressions (https://docs.python.org/3/library/re.html).
43
+ -u UNIT, --unit UNIT Name of the systemd unit that is being tested.
40
44
  -v, --verbose Increase output verbosity (use up to 3 times).
41
45
  -V, --version show program's version number and exit
42
46
  -w SECONDS, --warning SECONDS
@@ -56,11 +60,23 @@ Performance data:
56
60
 
57
61
  * https://github.com/Josef-Friedrich/check_systemd
58
62
  * https://exchange.icinga.com/joseffriedrich/check_systemd
59
- * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd
63
+ * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd/details
60
64
 
61
65
  ## Testing
62
66
 
63
67
  ```
68
+ pyenv install 3.7.6
69
+ pyenv install 3.8.1
70
+ pyenv local 3.7.6 3.8.1
64
71
  pip3 install tox
65
72
  tox
66
- ```
73
+ ```
74
+
75
+ ## Deploying
76
+
77
+ Edit version number in check_systemd.py (without `v`)
78
+
79
+ ```
80
+ git tag v2.0.11
81
+ git push --tags
82
+ ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: check-systemd
3
- Version: 2.0.8
3
+ Version: 2.1.0
4
4
  Summary: Nagios / Icinga monitoring plugin to check systemd for failed units.
5
5
  Home-page: https://github.com/Josef-Friedrich/check_systemd
6
6
  Author: Josef Friedrich
@@ -11,12 +11,16 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
11
11
 
12
12
  # check_systemd
13
13
 
14
- Nagios / Icinga monitoring plugin to check systemd for failed units.
14
+ `check_systemd` is a
15
+ [Nagios](https://www.nagios.org) / [Icinga](https://icinga.com)
16
+ monitoring plugin to check [systemd](https://systemd.io) for failed
17
+ units.
15
18
 
16
- This Python script will report a degraded system to Nagios / Icinga.
17
- It requires only the nagiosplugin library.
19
+ This Python script will report a degraded system to your monitoring solution.
20
+ It requires only the
21
+ [nagiosplugin](https://nagiosplugin.readthedocs.io/en/stable) library.
18
22
 
19
- You can also test a single service with -s parameter.
23
+ You can also test a single service with the `-u, --unit` parameter.
20
24
 
21
25
  Released under GNU GPLv2 License.
22
26
 
@@ -29,10 +33,10 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
29
33
  ## Command line interface
30
34
 
31
35
  ```
32
- usage: nosetests [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
36
+ usage: check_systemd [-h] [-c SECONDS] [-e UNIT | -u UNIT] [-v] [-V] [-w SECONDS]
33
37
 
34
38
  Copyright (c) 2014-18 Andrea Briganti a.k.a 'Kbyte' <kbytesys@gmail.com>
35
- Copyright (c) 2019 Josef Friedrich <josef@friedrich.rocks>
39
+ Copyright (c) 2019-20 Josef Friedrich <josef@friedrich.rocks>
36
40
 
37
41
  Nagios / Icinga monitoring plugin to check systemd for failed units.
38
42
 
@@ -41,10 +45,10 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
41
45
  -c SECONDS, --critical SECONDS
42
46
  Startup time in seconds to result in critical status.
43
47
  -e UNIT, --exclude UNIT
44
- Exclude a systemd unit from the checks. This option
45
- can be applied multiple times. For example: -e mnt-
46
- data.mount -e task.service.
47
- -u UNIT, --unit UNIT Name of the systemd unit that is beeing tested.
48
+ Exclude a systemd unit from the checks. This option can be applied multiple times, for example: -e mnt-data.mount -e
49
+ task.service. Regular expressions can be used to exclude multiple units at once, for example: -e 'user@\d+\.service'. For
50
+ more informations see the Python documentation about regular expressions (https://docs.python.org/3/library/re.html).
51
+ -u UNIT, --unit UNIT Name of the systemd unit that is being tested.
48
52
  -v, --verbose Increase output verbosity (use up to 3 times).
49
53
  -V, --version show program's version number and exit
50
54
  -w SECONDS, --warning SECONDS
@@ -64,14 +68,27 @@ Description: [![pypi.org](http://img.shields.io/pypi/v/check_systemd.svg)](https
64
68
 
65
69
  * https://github.com/Josef-Friedrich/check_systemd
66
70
  * https://exchange.icinga.com/joseffriedrich/check_systemd
67
- * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd
71
+ * https://exchange.nagios.org/directory/Plugins/System-Metrics/Processes/check_systemd/details
68
72
 
69
73
  ## Testing
70
74
 
71
75
  ```
76
+ pyenv install 3.7.6
77
+ pyenv install 3.8.1
78
+ pyenv local 3.7.6 3.8.1
72
79
  pip3 install tox
73
80
  tox
74
81
  ```
82
+
83
+ ## Deploying
84
+
85
+ Edit version number in check_systemd.py (without `v`)
86
+
87
+ ```
88
+ git tag v2.0.11
89
+ git push --tags
90
+ ```
91
+
75
92
  Keywords: nagios,systemd
76
93
  Platform: UNKNOWN
77
94
  Classifier: Development Status :: 5 - Production/Stable
@@ -4,8 +4,7 @@
4
4
  You can redistribute it and/or modify it under the terms of the GNU General
5
5
  Public License as published by the Free Software Foundation, either version 2
6
6
  of the License.
7
- Copyright 2014-18 Andrea Briganti a.k.a 'Kbyte'
8
- Copyright 2019 Josef Friedrich
7
+ Copyright see argparse help text.
9
8
  """
10
9
  import io
11
10
  import subprocess
@@ -15,7 +14,7 @@ import re
15
14
  import nagiosplugin
16
15
  from nagiosplugin import Metric
17
16
 
18
- __version__ = '2.0.8'
17
+ __version__ = '2.1.0'
19
18
 
20
19
 
21
20
  class SystemdctlListUnitsResource(nagiosplugin.Resource):
@@ -27,6 +26,12 @@ class SystemdctlListUnitsResource(nagiosplugin.Resource):
27
26
  def __init__(self, excludes=[]):
28
27
  self.excludes = excludes
29
28
 
29
+ def re_match(self, unit):
30
+ for exclude in self.excludes:
31
+ if re.match(exclude, unit):
32
+ return(True)
33
+ return(False)
34
+
30
35
  def probe(self):
31
36
  """Query system state and return metrics.
32
37
 
@@ -66,13 +71,20 @@ class SystemdctlListUnitsResource(nagiosplugin.Resource):
66
71
  unit = split_line[0]
67
72
  # failed
68
73
  active = split_line[2]
69
- # Only count not excludes units.
70
- if unit not in self.excludes:
74
+ # Only count not excluded units.
75
+ if not self.re_match(unit):
76
+ # Quick fix:
77
+ # Issue on Arch: “not-found” in column ACTIVE
78
+ # maybe cli table output changed on newer versions of
79
+ # systemd?
80
+ # maybe .split() is not working correctly?
81
+ if active not in units:
82
+ units[active] = []
71
83
  units[active].append(unit)
72
84
  count_units += 1
73
85
 
74
86
  for unit in units['failed']:
75
- if unit not in self.excludes:
87
+ if not self.re_match(unit):
76
88
  yield Metric(name=unit, value='failed', context='unit')
77
89
 
78
90
  for active, unit_names in units.items():
@@ -103,6 +115,7 @@ def format_timespan_to_seconds(fmt_timespan):
103
115
  'h': 60 * 60,
104
116
  'min': 60,
105
117
  's': 1,
118
+ 'ms': 0.001,
106
119
  }
107
120
  result = 0
108
121
  for span in fmt_timespan.split():
@@ -163,7 +176,7 @@ class SystemctlIsActiveResource(nagiosplugin.Resource):
163
176
 
164
177
  def __init__(self, *args, **kwargs):
165
178
  self.unit = kwargs.pop('unit')
166
- super(nagiosplugin.Resource, self).__init__(*args, **kwargs)
179
+ super().__init__(*args, **kwargs)
167
180
 
168
181
  def probe(self):
169
182
  """Query system state and return metrics.
@@ -275,7 +288,7 @@ def get_argparser():
275
288
  formatter_class=argparse.RawDescriptionHelpFormatter,
276
289
  description= # noqa: E251
277
290
  'Copyright (c) 2014-18 Andrea Briganti a.k.a \'Kbyte\' <kbytesys@gmail.com>\n' # noqa: E501
278
- 'Copyright (c) 2019 Josef Friedrich <josef@friedrich.rocks>\n'
291
+ 'Copyright (c) 2019-20 Josef Friedrich <josef@friedrich.rocks>\n'
279
292
  '\n'
280
293
  'Nagios / Icinga monitoring plugin to check systemd for failed units.\n', # noqa: E501
281
294
  epilog= # noqa: E251
@@ -303,15 +316,20 @@ def get_argparser():
303
316
  action='append',
304
317
  default=[],
305
318
  help='Exclude a systemd unit from the checks. This option can be '
306
- 'applied multiple times. For example: -e mnt-data.mount -e '
307
- 'task.service.',
319
+ 'applied multiple times, for example: -e mnt-data.mount -e '
320
+ 'task.service. Regular expressions can be used to exclude '
321
+ 'multiple units at once, for example: '
322
+ '-e \'user@\\d+\\.service\'. '
323
+ 'For more informations see the Python documentation about '
324
+ 'regular expressions '
325
+ '(https://docs.python.org/3/library/re.html).',
308
326
  )
309
327
 
310
328
  exclusive_group.add_argument(
311
329
  '-u', '--unit',
312
330
  type=str,
313
331
  dest='unit',
314
- help='Name of the systemd unit that is beeing tested.',
332
+ help='Name of the systemd unit that is being tested.',
315
333
  )
316
334
 
317
335
  parser.add_argument(
@@ -337,7 +355,6 @@ def get_argparser():
337
355
  return parser
338
356
 
339
357
 
340
- @nagiosplugin.guarded
341
358
  def main():
342
359
  args = get_argparser().parse_args()
343
360
 
File without changes
File without changes
File without changes
File without changes