check_systemd 2.2.0__tar.gz → 2.2.1__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.
- {check_systemd-2.2.0 → check_systemd-2.2.1}/PKG-INFO +5 -5
- {check_systemd-2.2.0 → check_systemd-2.2.1}/README.md +4 -4
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/PKG-INFO +5 -5
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.py +55 -8
- {check_systemd-2.2.0 → check_systemd-2.2.1}/LICENSE +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/MANIFEST.in +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/SOURCES.txt +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/dependency_links.txt +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/entry_points.txt +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/requires.txt +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/check_systemd.egg-info/top_level.txt +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/setup.cfg +0 -0
- {check_systemd-2.2.0 → check_systemd-2.2.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: check_systemd
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
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
|
|
@@ -102,7 +102,7 @@ Description: [](https
|
|
|
102
102
|
To detect failed units this monitoring script runs:
|
|
103
103
|
|
|
104
104
|
```sh
|
|
105
|
-
systemctl list-units --all
|
|
105
|
+
systemctl list-units --all
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
To get the startup time it executes:
|
|
@@ -126,9 +126,9 @@ Description: [](https
|
|
|
126
126
|
## Testing
|
|
127
127
|
|
|
128
128
|
```
|
|
129
|
-
pyenv install 3.
|
|
130
|
-
pyenv install 3.
|
|
131
|
-
pyenv local 3.
|
|
129
|
+
pyenv install 3.6.12
|
|
130
|
+
pyenv install 3.7.9
|
|
131
|
+
pyenv local 3.6.12 3.7.9
|
|
132
132
|
pip3 install tox
|
|
133
133
|
tox
|
|
134
134
|
```
|
|
@@ -94,7 +94,7 @@ Performance data:
|
|
|
94
94
|
To detect failed units this monitoring script runs:
|
|
95
95
|
|
|
96
96
|
```sh
|
|
97
|
-
systemctl list-units --all
|
|
97
|
+
systemctl list-units --all
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
To get the startup time it executes:
|
|
@@ -118,9 +118,9 @@ systemctl list-timers --all
|
|
|
118
118
|
## Testing
|
|
119
119
|
|
|
120
120
|
```
|
|
121
|
-
pyenv install 3.
|
|
122
|
-
pyenv install 3.
|
|
123
|
-
pyenv local 3.
|
|
121
|
+
pyenv install 3.6.12
|
|
122
|
+
pyenv install 3.7.9
|
|
123
|
+
pyenv local 3.6.12 3.7.9
|
|
124
124
|
pip3 install tox
|
|
125
125
|
tox
|
|
126
126
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: check-systemd
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
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
|
|
@@ -102,7 +102,7 @@ Description: [](https
|
|
|
102
102
|
To detect failed units this monitoring script runs:
|
|
103
103
|
|
|
104
104
|
```sh
|
|
105
|
-
systemctl list-units --all
|
|
105
|
+
systemctl list-units --all
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
To get the startup time it executes:
|
|
@@ -126,9 +126,9 @@ Description: [](https
|
|
|
126
126
|
## Testing
|
|
127
127
|
|
|
128
128
|
```
|
|
129
|
-
pyenv install 3.
|
|
130
|
-
pyenv install 3.
|
|
131
|
-
pyenv local 3.
|
|
129
|
+
pyenv install 3.6.12
|
|
130
|
+
pyenv install 3.7.9
|
|
131
|
+
pyenv local 3.6.12 3.7.9
|
|
132
132
|
pip3 install tox
|
|
133
133
|
tox
|
|
134
134
|
```
|
|
@@ -14,7 +14,7 @@ import re
|
|
|
14
14
|
import nagiosplugin
|
|
15
15
|
from nagiosplugin import Metric
|
|
16
16
|
|
|
17
|
-
__version__ = '2.2.
|
|
17
|
+
__version__ = '2.2.1'
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class SystemctlListUnitsResource(nagiosplugin.Resource):
|
|
@@ -41,8 +41,8 @@ class SystemctlListUnitsResource(nagiosplugin.Resource):
|
|
|
41
41
|
# We don’t use `systemctl --failed --no-legend`, because we want to
|
|
42
42
|
# collect performance data of all units.
|
|
43
43
|
try:
|
|
44
|
-
p = subprocess.Popen(['systemctl', 'list-units', '--all',
|
|
45
|
-
|
|
44
|
+
# p = subprocess.Popen(['./test/bin/ok/systemctl', 'list-units', '--all'], # noqa: E501
|
|
45
|
+
p = subprocess.Popen(['systemctl', 'list-units', '--all'],
|
|
46
46
|
stderr=subprocess.PIPE,
|
|
47
47
|
stdin=subprocess.PIPE,
|
|
48
48
|
stdout=subprocess.PIPE)
|
|
@@ -61,16 +61,32 @@ class SystemctlListUnitsResource(nagiosplugin.Resource):
|
|
|
61
61
|
'inactive': [],
|
|
62
62
|
}
|
|
63
63
|
if stdout:
|
|
64
|
-
|
|
64
|
+
lines = stdout.decode('utf-8').splitlines()
|
|
65
|
+
table_heading = lines[0]
|
|
66
|
+
|
|
67
|
+
# Remove the first line because it is the header.
|
|
68
|
+
|
|
69
|
+
# Remove the last seven lines:
|
|
70
|
+
|
|
71
|
+
# empty line
|
|
72
|
+
# LOAD = Reflects whether the unit definition...
|
|
73
|
+
# ACTIVE = The high-level unit activation state...
|
|
74
|
+
# SUB = The low-level unit activation state...
|
|
75
|
+
# empty line
|
|
76
|
+
# xxx loaded units listed. Pass --all to see ...
|
|
77
|
+
# To show all installed unit files use...
|
|
78
|
+
table_body = lines[1:-7]
|
|
79
|
+
table_parser = TableParser(table_heading)
|
|
80
|
+
# Output of `systemctl list-units --all:
|
|
65
81
|
# UNIT LOAD ACTIVE SUB JOB DESCRIPTION
|
|
66
82
|
# foobar.service loaded active waiting Description text
|
|
67
83
|
count_units = 0
|
|
68
|
-
for line in
|
|
69
|
-
split_line = line.split()
|
|
84
|
+
for line in table_body:
|
|
70
85
|
# foobar.service
|
|
71
|
-
unit =
|
|
86
|
+
unit = table_parser.get_column_text(line, 'UNIT')
|
|
72
87
|
# failed
|
|
73
|
-
active =
|
|
88
|
+
active = table_parser.get_column_text(line, 'ACTIVE')
|
|
89
|
+
|
|
74
90
|
# Only count not excluded units.
|
|
75
91
|
if not self.re_match(unit):
|
|
76
92
|
# Quick fix:
|
|
@@ -183,6 +199,37 @@ class SystemdAnalyseResource(nagiosplugin.Resource):
|
|
|
183
199
|
context='startup_time')
|
|
184
200
|
|
|
185
201
|
|
|
202
|
+
class TableParser:
|
|
203
|
+
"""A parser for the various table outputs of different systemd commands."""
|
|
204
|
+
|
|
205
|
+
def __init__(self, heading_row):
|
|
206
|
+
"""
|
|
207
|
+
:param str heading_row: A row with column titles.
|
|
208
|
+
"""
|
|
209
|
+
self.heading_row = heading_row
|
|
210
|
+
|
|
211
|
+
def detect_column_boundaries(self, column_title):
|
|
212
|
+
"""
|
|
213
|
+
:param str column_title: The title of the column, for example UNIT,
|
|
214
|
+
ACTIVE. The column title must be included in the heading row.
|
|
215
|
+
"""
|
|
216
|
+
match = re.search(re.compile(column_title + r'\s*'), self.heading_row)
|
|
217
|
+
return [match.start(), match.end()]
|
|
218
|
+
|
|
219
|
+
def get_column_text(self, row, column_title):
|
|
220
|
+
"""Get the text of a certain column, that is specified by the column
|
|
221
|
+
title. Leading and trailing whitespaces are removed.
|
|
222
|
+
|
|
223
|
+
:param str row: The current row of the table to extract a certain
|
|
224
|
+
column.
|
|
225
|
+
:param str column_title: The title of the column, for example UNIT,
|
|
226
|
+
ACTIVE. The column title must be included in the heading row.
|
|
227
|
+
"""
|
|
228
|
+
boundaries = self.detect_column_boundaries(column_title)
|
|
229
|
+
column = row[boundaries[0]:boundaries[1]]
|
|
230
|
+
return column.strip()
|
|
231
|
+
|
|
232
|
+
|
|
186
233
|
class SystemctlListTimersResource(nagiosplugin.Resource):
|
|
187
234
|
"""There is one type of systemd "degradation" which is normally not
|
|
188
235
|
detected: dead / inactive timers.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|