mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
systemd_status: reformat docstring to perlpod format
This commit is contained in:
parent
ca27b12937
commit
f8fef4cf73
1 changed files with 45 additions and 19 deletions
|
@ -1,14 +1,40 @@
|
||||||
#!/usr/bin/python3 -tt
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
# pylint: enable=invalid-name
|
# pylint: enable=invalid-name
|
||||||
|
|
||||||
"""Munin plugin to monitor systemd service status.
|
"""Munin plugin to monitor systemd service status.
|
||||||
Copyright 2018, Kim B. Heino, b@bbbs.net, Foobar Oy
|
|
||||||
License GPLv2+
|
|
||||||
|
|
||||||
#%# capabilities=autoconf
|
=head1 NAME
|
||||||
#%# family=auto
|
|
||||||
|
systemd_status - monitor systemd service status, including normal services,
|
||||||
|
mounts, hotplugs and socket activations
|
||||||
|
|
||||||
|
=head1 APPLICABLE SYSTEMS
|
||||||
|
|
||||||
|
Linux systems with systemd installed.
|
||||||
|
|
||||||
|
=head1 CONFIGURATION
|
||||||
|
|
||||||
|
No configuration is required for this plugin.
|
||||||
|
|
||||||
|
Warning level for systemd "failed" state is set to 0:0. If any of the services
|
||||||
|
enters "failed" state, Munin will emit warning.
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Kim B. Heino <b@bbbs.net>
|
||||||
|
|
||||||
|
=head1 LICENSE
|
||||||
|
|
||||||
|
GPLv2
|
||||||
|
|
||||||
|
=head1 MAGIC MARKERS
|
||||||
|
|
||||||
|
#%# family=auto
|
||||||
|
#%# capabilities=autoconf
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -49,26 +75,26 @@ def fetch():
|
||||||
"""Print runtime values."""
|
"""Print runtime values."""
|
||||||
# Get data
|
# Get data
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output([
|
# deb9/py3.5 doesn't have encoding parameter in subprocess
|
||||||
'/bin/systemctl',
|
output = subprocess.check_output(['/bin/systemctl', 'list-units'])
|
||||||
'list-units']) # deb9/py3.5 doesn't have encoding parameter
|
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, subprocess.CalledProcessError):
|
||||||
return
|
return
|
||||||
|
output = output.decode('utf-8', 'ignore')
|
||||||
|
|
||||||
# Parse data
|
# Parse data
|
||||||
states = {state: 0 for state in STATES}
|
states = {state: 0 for state in STATES}
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
line = line.decode('utf-8').split()
|
token = line.split()
|
||||||
if len(line) < 4:
|
if len(token) < 4:
|
||||||
continue
|
continue
|
||||||
if len(line[0]) < 3: # Skip failed-bullet
|
if len(token[0]) < 3: # Skip failed-bullet
|
||||||
line = line[1:]
|
token = token[1:]
|
||||||
if line[0].endswith('.scope'): # Ignore scopes
|
if token[0].endswith('.scope'):
|
||||||
continue
|
continue # Ignore scopes
|
||||||
if re.match(r'user.*@\d+\.service', line[0]):
|
if re.match(r'user.*@\d+\.service', token[0]):
|
||||||
continue
|
continue # These fail randomly in older systemd
|
||||||
if line[3] in states:
|
if token[3] in states:
|
||||||
states[line[3]] = states[line[3]] + 1
|
states[token[3]] = states[token[3]] + 1
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
for state in STATES:
|
for state in STATES:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue