d3s-nagios-plugins 1.0.2__py3-none-any.whl

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.
d3s/__init__.py ADDED
File without changes
d3s/nagios.py ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Nagios-releated utilities.
21
+ """
22
+
23
+ import subprocess
24
+ import sys
25
+
26
+
27
+ class NagiosPluginBase:
28
+ """
29
+ Base class for Nagios plugins.
30
+
31
+ Note that this class offers a lot of functionality that could be
32
+ better implemented in standalone modules. But packing it all into
33
+ one class make the implementation of individual plugins much faster.
34
+ """
35
+
36
+ STATUS_NAMES = ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
37
+
38
+ def __init__(self, name):
39
+ self.name_ = name
40
+ self.status_ = 0
41
+ self.message_ = "empty message"
42
+ self.perf_data_ = {}
43
+
44
+ def collect(self):
45
+ """ Called from run() to actually ollect monitored information. """
46
+ raise NotImplementedError("Re-implement in subclass!")
47
+
48
+ def add_perf_data(self, name, value):
49
+ """ Add performance data. """
50
+ self.perf_data_[name] = value
51
+
52
+ def get_perf_data(self, name):
53
+ """ Get performance data. """
54
+ return self.perf_data_[name]
55
+
56
+ def set_message(self, msg):
57
+ """ Set the main plugin message. """
58
+ self.message_ = msg
59
+
60
+ def set_message_from_perf(self, msg):
61
+ """ Set the main plugin message with {placeholders} from perf data. """
62
+ self.set_message(msg.format(**self.perf_data_))
63
+
64
+ def worsen_to_warning(self):
65
+ """ Final plugin status would be warning or worse. """
66
+ if self.status_ == 0:
67
+ self.status_ = 1
68
+
69
+ def worsen_to_critical(self):
70
+ """ Final plugin status would be critical. """
71
+ if (self.status_ == 0) or (self.status_ == 1):
72
+ self.status_ = 2
73
+
74
+ # pylint: disable=no-self-use
75
+ def read_file(self, filename):
76
+ """ Read given file and return list of its lines (rstripped). """
77
+ with open(filename, "r") as inp:
78
+ for line in inp:
79
+ yield line.rstrip()
80
+
81
+ # pylint: disable=no-self-use
82
+ def read_command_output(self, cmd):
83
+ """ Run given command and return list of lines on stdout (rstripped). """
84
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as proc:
85
+ for line in proc.stdout:
86
+ yield line.decode('utf-8').rstrip()
87
+ proc.wait()
88
+
89
+ # pylint: disable=no-self-use
90
+ def grep_lines(self, regexp, lines):
91
+ """ Return lines matching regular expression. """
92
+ for line in lines:
93
+ res = regexp.search(line)
94
+ if res is not None:
95
+ yield res
96
+
97
+ def contains_line(self, regexp, lines):
98
+ """ Returns whether some line matches regular expression. """
99
+ try:
100
+ next(self.grep_lines(regexp, lines))
101
+ return True
102
+ except StopIteration:
103
+ return False
104
+
105
+ def run(self, terminate=False):
106
+ """ Main of the plugin that does the work. """
107
+ self.collect()
108
+ status_name = NagiosPluginBase.STATUS_NAMES[self.status_]
109
+ print("{name} {status} - {message}{perf}".format(
110
+ name=self.name_,
111
+ status=status_name,
112
+ message=self.message_,
113
+ perf=self.format_perf_data_()))
114
+ if terminate:
115
+ sys.exit(self.status_)
116
+
117
+ def format_perf_data_(self):
118
+ """ Formats performance data as CSV. """
119
+ if not self.perf_data_:
120
+ return ""
121
+ res = []
122
+ for key, value in self.perf_data_.items():
123
+ res.append("{}={}".format(key, value))
124
+ return "|{}".format(",".join(res))
File without changes
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Checks basic system health, useful for collecting basic stats.
21
+
22
+ Usage:
23
+ <no parameters needed>
24
+
25
+ Example output:
26
+
27
+ HEALTH OK - up 1 day, 0.79 load, 1 ready tasks|\
28
+ mem_total_kb=16300840,mem_avail_kb=9947436,\
29
+ load_1min=0.39,load_5min=0.79,load_15min=0.86,\
30
+ tasks_runnable=1,tasks_total=952,\
31
+ uptime=1 day
32
+
33
+ """
34
+
35
+ import re
36
+ from d3s.nagios import NagiosPluginBase
37
+
38
+
39
+ class CheckHealth(NagiosPluginBase):
40
+ """
41
+ Collects basic information about running Linux system.
42
+
43
+ There are not critical/warning limits as its main purpose is to collect
44
+ basic system information for later processing via perf data section.
45
+ """
46
+
47
+ MEM_INFO_RE = re.compile('^([^:]*):[ \t]*([0-9]*) kB$')
48
+ LOAD_AVG_RE = re.compile('''
49
+ ^([0-9.]+) # 1 min
50
+ \\s+
51
+ ([0-9.]+) # 5 min
52
+ \\s+
53
+ ([0-9.]+) # 15 min
54
+ \\s+
55
+ ([0-9]+)/([0-9]+) # runnable/total tasks in the system
56
+ \\s+.*$ # ignore rest of line
57
+ ''', re.VERBOSE)
58
+ UPTIME_RE = re.compile('^.*up[ \t]+([^,]*),.*$')
59
+
60
+ def __init__(self):
61
+ NagiosPluginBase.__init__(self, 'HEALTH')
62
+
63
+ def collect(self):
64
+ # Read memory information
65
+ for entry in self.grep_lines(CheckHealth.MEM_INFO_RE, self.read_file('/proc/meminfo')):
66
+ key = entry.group(1)
67
+ value = entry.group(2)
68
+ if key == 'MemTotal':
69
+ self.add_perf_data('mem_total_kb', value)
70
+ elif key == 'MemAvailable':
71
+ self.add_perf_data('mem_avail_kb', value)
72
+
73
+ # Get load average
74
+ entry = next(self.grep_lines(CheckHealth.LOAD_AVG_RE, self.read_file('/proc/loadavg')))
75
+ self.add_perf_data('load_1min', entry.group(1))
76
+ self.add_perf_data('load_5min', entry.group(2))
77
+ self.add_perf_data('load_15min', entry.group(3))
78
+ self.add_perf_data('tasks_runnable', entry.group(4))
79
+ self.add_perf_data('tasks_total', entry.group(5))
80
+
81
+ # Read uptime information
82
+ entry = next(self.grep_lines(CheckHealth.UPTIME_RE, self.read_command_output(['uptime'])))
83
+ self.add_perf_data('uptime', entry.group(1))
84
+
85
+ # Format final message
86
+ self.set_message_from_perf("up {uptime}, {load_5min} load, {tasks_runnable} ready tasks")
87
+
88
+ def main():
89
+ """
90
+ Module main for execution from shell script.
91
+ """
92
+ CheckHealth().run(True)
93
+
94
+ if __name__ == '__main__':
95
+ main()
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Checks available memory.
21
+
22
+ Usage:
23
+ <no parameters needed>
24
+
25
+ Example output:
26
+ MEM OK - 16G, 9G available (57%)|\
27
+ mem_total_kb=16300840K,mem_avail_kb=9298876K,mem_avail_percent=57.\
28
+ top_1_app=java:1681144:10.3:00_31_06:last-argument,\
29
+ top_2_app=...\
30
+ ...
31
+
32
+ """
33
+
34
+ import re
35
+ from d3s.nagios import NagiosPluginBase
36
+ from d3s.units import SmartUnit
37
+
38
+
39
+ class CheckMemory(NagiosPluginBase):
40
+ """
41
+ Checks available memory and warns if there is not enough memory.
42
+
43
+ Also reports top memory-eaters.
44
+ """
45
+
46
+ MEM_INFO_RE = re.compile('^([^:]*):[ \t]*([0-9]*) kB$')
47
+ TOP_EATERS_CMD = [
48
+ 'ps',
49
+ '-e', '--no-header',
50
+ '--sort=-%mem',
51
+ '-o', 'rss,%mem,comm,time,command'
52
+ ]
53
+ TOP_EATERS_RE = re.compile('''
54
+ ^([0-9]+)\\s+
55
+ ([0-9.]+)\\s+
56
+ ([^ \t]+)\\s+
57
+ ([0-9][0-9]:[0-9][0-9]:[0-9][0-9])\\s+
58
+ .*?([^ \t]+)$
59
+ ''', re.VERBOSE)
60
+
61
+ def __init__(self):
62
+ NagiosPluginBase.__init__(self, 'MEM')
63
+ self.top_eaters_count = 5
64
+ self.warn_on = 0.1
65
+ self.critical_on = 0.05
66
+
67
+ def collect(self):
68
+ # Read memory information
69
+ for entry in self.grep_lines(CheckMemory.MEM_INFO_RE, self.read_file('/proc/meminfo')):
70
+ key = entry.group(1)
71
+ value = entry.group(2)
72
+ if key == 'MemTotal':
73
+ self.add_perf_data('mem_total_kb', SmartUnit(int(value), 'K'))
74
+ elif key == 'MemAvailable':
75
+ self.add_perf_data('mem_avail_kb', SmartUnit(int(value), 'K'))
76
+
77
+ avail_amount = self.get_perf_data('mem_avail_kb') / self.get_perf_data('mem_total_kb')
78
+ self.add_perf_data('mem_avail_percent', avail_amount * 100)
79
+
80
+ if avail_amount < self.warn_on:
81
+ self.worsen_to_warning()
82
+
83
+ if avail_amount < self.critical_on:
84
+ self.worsen_to_critical()
85
+
86
+ # Find top memory-eaters.
87
+ top_output = self.read_command_output(CheckMemory.TOP_EATERS_CMD)
88
+ index = 1
89
+ for line in self.grep_lines(CheckMemory.TOP_EATERS_RE, top_output):
90
+ value = '{command}:{rss}:{mem}:{time}:{arg}'.format(
91
+ rss=line.group(1),
92
+ mem=line.group(2),
93
+ command=line.group(3).replace(':', '_'),
94
+ time=line.group(4).replace(':', '_'),
95
+ arg=line.group(5).replace(':', '_')
96
+ )
97
+ key = 'top_{}_app'.format(index)
98
+ self.add_perf_data(key, value)
99
+ index = index + 1
100
+ if index > self.top_eaters_count:
101
+ break
102
+
103
+ # Format final message
104
+ self.set_message_from_perf("{mem_total_kb:smart}, {mem_avail_kb:smart} available"
105
+ + " ({mem_avail_percent:.0f}%)")
106
+
107
+ def main():
108
+ """
109
+ Module main for execution from shell script.
110
+ """
111
+ CheckMemory().run(True)
112
+
113
+ if __name__ == '__main__':
114
+ main()
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Checks avaiable updates.
21
+
22
+ Usage:
23
+ <no parameters needed>
24
+
25
+ Example output:
26
+
27
+
28
+
29
+ """
30
+
31
+ import re
32
+ import urllib.request
33
+ from d3s.nagios import NagiosPluginBase
34
+
35
+
36
+ class CheckOsUpdates(NagiosPluginBase):
37
+ """
38
+ Checks available updates and warns when too many packages are outdated.
39
+ """
40
+
41
+ OS_RELEASE_RE = re.compile('^([a-z_A-Z]+)=["]?([^"]*)["]?$')
42
+
43
+ FEDORA_LIST_UPDATES_CMD = [
44
+ 'dnf',
45
+ 'list',
46
+ '--quiet',
47
+ 'updates'
48
+ ]
49
+
50
+ FEDORA_RELEASE_LIST_URL = 'https://download.fedoraproject.org/pub/fedora/linux/releases/'
51
+
52
+ FEDORA_RELEASE_RE = re.compile('''
53
+ a\\s+
54
+ href=['"]([0-9]+)/?['"][ \t>]
55
+ ''', re.VERBOSE)
56
+
57
+ def __init__(self):
58
+ NagiosPluginBase.__init__(self, 'OS-UPDATES')
59
+ self.warn_on = 50
60
+ self.critical_on = 200
61
+
62
+ # pylint: disable=no-self-use
63
+ def get_fedora_latest_(self):
64
+ """ Get latest Fedora release as integer. """
65
+ response = urllib.request.urlopen(CheckOsUpdates.FEDORA_RELEASE_LIST_URL)
66
+ text = response.read().decode('utf-8')
67
+ releases = re.findall(CheckOsUpdates.FEDORA_RELEASE_RE, text)
68
+ return max([int(r) for r in releases])
69
+
70
+ def collect_fedora_(self):
71
+ """ Collect information for Fedora distribution. """
72
+ self.add_perf_data('os_latest_version', self.get_fedora_latest_())
73
+ if self.get_perf_data('os_version') + 1 < self.get_perf_data('os_latest_version'):
74
+ self.worsen_to_critical()
75
+ message_suffix = ' too old ({os_latest_version} available)'
76
+ else:
77
+ message_suffix = ''
78
+
79
+ outdated_list = self.read_command_output(CheckOsUpdates.FEDORA_LIST_UPDATES_CMD)
80
+ outdated = sum(1 for _ in outdated_list)
81
+ # Strip header
82
+ if outdated > 1:
83
+ outdated = outdated - 1
84
+ self.add_perf_data('os_outdated_packages', outdated)
85
+
86
+ if outdated > self.warn_on:
87
+ self.worsen_to_warning()
88
+ if outdated > self.critical_on:
89
+ self.worsen_to_critical()
90
+
91
+ self.set_message_from_perf('Fedora {os_version}' + message_suffix
92
+ + ', {os_outdated_packages} out-dated packages')
93
+
94
+
95
+ def collect(self):
96
+ self.add_perf_data('os_id', 'unknown')
97
+ try:
98
+ release_file = self.read_file('/etc/os-release')
99
+ for entry in self.grep_lines(CheckOsUpdates.OS_RELEASE_RE, release_file):
100
+ key = entry.group(1)
101
+ value = entry.group(2)
102
+ if key == 'ID':
103
+ self.add_perf_data('os_id', value)
104
+ elif key == 'VERSION_ID':
105
+ self.add_perf_data('os_version', int(value))
106
+ except IOError:
107
+ pass
108
+
109
+ kernel_release = next(self.read_command_output(['uname', '-r']))
110
+ self.add_perf_data('os_kernel', kernel_release)
111
+
112
+ os_id = self.get_perf_data('os_id')
113
+ if os_id == 'unknown':
114
+ self.worsen_to_critical()
115
+ self.set_message('unknown OS')
116
+ elif os_id == 'fedora':
117
+ self.collect_fedora_()
118
+ else:
119
+ self.worsen_to_critical()
120
+ self.set_message_from_perf('unsupported OS {os_id}')
121
+
122
+
123
+ def main():
124
+ """
125
+ Module main for execution from shell script.
126
+ """
127
+ CheckOsUpdates().run(True)
128
+
129
+ if __name__ == '__main__':
130
+ main()
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Checks that systemd unit is enabled and running.
21
+
22
+ Usage:
23
+ --service UNIT
24
+
25
+ Example output:
26
+
27
+ SRV OK - httpd running, 12.6M, 6 tasks|\
28
+ service_name=httpd,service_tasks=6,service_memory=12.6M
29
+
30
+ """
31
+
32
+ import re
33
+ import argparse
34
+ from d3s.nagios import NagiosPluginBase
35
+
36
+
37
+ class CheckSystemdService(NagiosPluginBase):
38
+ """
39
+ Checks that given service is running and enabled.
40
+ """
41
+
42
+ DETAILS_BASE_RE = re.compile('''
43
+ ^\\s+(Tasks|Memory):
44
+ \\s+
45
+ ([^ \t]+)
46
+ .*$
47
+ ''', re.VERBOSE)
48
+
49
+ def __init__(self):
50
+ NagiosPluginBase.__init__(self, 'SRV')
51
+ parser = argparse.ArgumentParser()
52
+ parser.add_argument('--service', dest='service', metavar='UNIT', required=True)
53
+ args = parser.parse_args()
54
+ self.service = args.service
55
+
56
+ def collect(self):
57
+ self.add_perf_data('service_name', self.service)
58
+
59
+ is_enabled_output = self.read_command_output(['systemctl', 'is-enabled', self.service])
60
+ is_enabled = self.contains_line(re.compile('^enabled$'), is_enabled_output)
61
+ if not is_enabled:
62
+ self.worsen_to_warning()
63
+
64
+ is_active_output = self.read_command_output(['systemctl', 'is-active', self.service])
65
+ is_active = self.contains_line(re.compile('^active$'), is_active_output)
66
+ if not is_active:
67
+ self.worsen_to_critical()
68
+
69
+ status_output = self.read_command_output(['systemctl', 'status', self.service])
70
+ for line in self.grep_lines(CheckSystemdService.DETAILS_BASE_RE, status_output):
71
+ key = line.group(1)
72
+ if key == 'Tasks':
73
+ self.add_perf_data('service_tasks', line.group(2))
74
+ elif key == 'Memory':
75
+ self.add_perf_data('service_memory', line.group(2))
76
+
77
+ details = ', {service_memory}, {service_tasks} tasks'
78
+ if not is_active:
79
+ self.set_message_from_perf('{service_name} not running')
80
+ elif not is_enabled:
81
+ self.set_message_from_perf('{service_name} running but not enabled' + details)
82
+ else:
83
+ self.set_message_from_perf('{service_name} running' + details)
84
+
85
+
86
+ def main():
87
+ """
88
+ Module main for execution from shell script.
89
+ """
90
+ CheckSystemdService().run(True)
91
+
92
+ if __name__ == '__main__':
93
+ main()
d3s/units.py ADDED
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # Copyright 2019 Vojtech Horky
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ """
20
+ Unit conversion utilities.
21
+ """
22
+
23
+
24
+ class SmartUnit:
25
+ """
26
+ Holds arbitrary value but formats it in a reasonable unit.
27
+ """
28
+
29
+ def __init__(self, value, size, unit=''):
30
+ self.value = value
31
+ self.size = size
32
+ self.unit = unit
33
+
34
+ def get_reasonable_value_with_unit_(self):
35
+ """ Does the actual conversion to a reasonable unit. """
36
+ units_1024 = ['K', 'M', 'G', 'T']
37
+ value = self.value
38
+ if self.size in units_1024:
39
+ value = value * (1024 ^ (units_1024.index(self.size) + 1))
40
+ unit = ""
41
+ if value > 4096:
42
+ value = value / 1024
43
+ unit = "K"
44
+ if value > 4096:
45
+ value = value / 1024
46
+ unit = "M"
47
+ if value > 4096:
48
+ value = value / 1024
49
+ unit = "G"
50
+
51
+ return (value, unit)
52
+
53
+ def __format__(self, format_name):
54
+ value = self.value
55
+ size = self.size
56
+ if format_name == 'smart':
57
+ (value, size) = self.get_reasonable_value_with_unit_()
58
+ format_name = ':.0f'
59
+
60
+ fmt = '{' + format_name + '}{}{}'
61
+ return fmt.format(value, size, self.unit)
62
+
63
+ def __rtruediv__(self, other):
64
+ return float(self.value) / float(other)
65
+
66
+ def __truediv__(self, other):
67
+ return float(self.value) / float(other)
68
+
69
+ def __float__(self):
70
+ return float(self.value)
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: d3s-nagios-plugins
3
+ Version: 1.0.2
4
+ Summary: Collection of various Nagios plugins
5
+ Home-page: https://github.com/d-iii-s/d3s-nagios-plugins
6
+ Author: Vojtech Horky
7
+ Author-email: horky@d3s.mff.cuni.cz
8
+ License: Apache-2.0
9
+ Keywords: Nagios monitoring
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Dynamic: license-file
14
+
15
+ # D3S Nagios Plugins
16
+
17
+ A collection of various mini-plugins for Nagios.
18
+
19
+
20
+
21
+ ## Installation (inside virtualenv)
22
+
23
+ ```shell
24
+ python -m venv env
25
+ . ./env/bin/activate
26
+ pip install -e .
27
+ # Now it is possible to run any of the ./env/bin/nagios_d3s_check_* scripts
28
+ ```
29
+
30
+
31
+
32
+ ## Available plugins
33
+
34
+
35
+ ### `check_health`
36
+
37
+ Only collects basic system status (uptime, free memory, ...), useful only
38
+ for performance data analysis.
39
+
40
+
41
+ ### `check_memory`
42
+
43
+ Checks available memory.
44
+
45
+
46
+ ### `check_os_updates`
47
+
48
+ Checks that GNU/Linux system is up-to-date.
49
+
50
+
51
+ ### `check_systemd_service`
52
+
53
+ Checks that systemd unit is enabled and running.
@@ -0,0 +1,14 @@
1
+ d3s/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ d3s/nagios.py,sha256=8HG5tzsgfo7q86620xQkOit882K5vLa5pP0FkzmRs3k,4039
3
+ d3s/units.py,sha256=WuiCgiwZE-kiYysxg16S1K0O82hLDseChvFctTOQjQU,2021
4
+ d3s/nagios_plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ d3s/nagios_plugins/check_health.py,sha256=JWzoTqdjjVJ74XQkNkILrzyxgwg-s5FyaBGJBxAlvYc,3019
6
+ d3s/nagios_plugins/check_memory.py,sha256=RclE451FkLWG0KGR8W0lian9wg4EYy4b6HOcBiQxRRE,3518
7
+ d3s/nagios_plugins/check_os_updates.py,sha256=LnkKziYNGT4i6tJXX-BLGLVf0ls7dyMTpVeykZrBH_c,3960
8
+ d3s/nagios_plugins/check_systemd_service.py,sha256=S72t8ynOdGyJXlaJXtliNYmG09gnOXiCORAcA0wNnK0,2902
9
+ d3s_nagios_plugins-1.0.2.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
10
+ d3s_nagios_plugins-1.0.2.dist-info/METADATA,sha256=dDy-pyR4hDQoSaVTmrRDO3zFJKFE0r0LCCDl4uwvkfU,984
11
+ d3s_nagios_plugins-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ d3s_nagios_plugins-1.0.2.dist-info/entry_points.txt,sha256=prQKAJmbQ8VyROVvTnvGN9P2_GBJSET6PVsUDj3TLjs,296
13
+ d3s_nagios_plugins-1.0.2.dist-info/top_level.txt,sha256=5AgpI6HR-7S4SdA8DaKPTjEMMnM_pyTgLIXccLuigKY,4
14
+ d3s_nagios_plugins-1.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ nagios_d3s_check_health = d3s.nagios_plugins.check_health:main
3
+ nagios_d3s_check_memory = d3s.nagios_plugins.check_memory:main
4
+ nagios_d3s_check_os_updates = d3s.nagios_plugins.check_os_updates:main
5
+ nagios_d3s_check_systemd_service = d3s.nagios_plugins.check_systemd_service:main
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1 @@
1
+ d3s