Skip to content

Commit a2e9306

Browse files
committed
Consistently reporting errors using cu() instead of oao()
1 parent 9309f6e commit a2e9306

File tree

126 files changed

+351
-350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+351
-350
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Features:
4949

5050
Monitoring Plugins:
5151

52+
* All plugins: Consistently reporting errors using cu() instead of oao()
5253
* fail2ban: Improve output, add unit-test
5354
* grafana-version: Add Grafana v9.5
5455
* infomaniak-events: Add filter for service categories

check-plugins/apache-httpd-status/apache-httpd-status

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2424
STATE_UNKNOWN, STATE_WARN)
2525

2626
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
27-
__version__ = '2023051201'
27+
__version__ = '2023071203'
2828

2929
DESCRIPTION = 'Checks how well an Apache httpd server is performing.'
3030

@@ -120,7 +120,7 @@ def main():
120120
# fetch the URL
121121
result = lib.base.coe(lib.url.fetch(URL, insecure=args.INSECURE))
122122
if 'Scoreboard: ' not in result:
123-
lib.base.oao('Malformed Apache server info.', STATE_UNKNOWN)
123+
lib.base.cu('Malformed Apache server info.')
124124
else:
125125
# do not call the command, put in test data
126126
stdout, stderr, retc = lib.test.test(args.TEST)
@@ -152,7 +152,7 @@ def main():
152152
try:
153153
key, value = item.split(': ')
154154
except:
155-
lib.base.oao('Malformed Apache server info.', STATE_UNKNOWN)
155+
lib.base.cu('Malformed Apache server info.')
156156

157157
if key == 'ServerUptimeSeconds':
158158
apache['ServerUptimeSeconds'] = int(value) # continous counter
@@ -176,7 +176,7 @@ def main():
176176
# parse the "scoreboard" and count the elements
177177
apache['TotalWorkers'] = len(apache['Scoreboard'])
178178
if apache['TotalWorkers'] == 0:
179-
lib.base.oao('Malformed Apache server info.', STATE_UNKNOWN)
179+
lib.base.cu('Malformed Apache server info.')
180180

181181
# from mod_status.c:
182182
workers['closing'] = apache['Scoreboard'].count('C') # SERVER_CLOSING

check-plugins/apache-httpd-version/apache-httpd-version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import lib.version # pylint: disable=C0413
2121
from lib.globals import (STATE_UNKNOWN) # pylint: disable=C0413
2222

2323
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
24-
__version__ = '2023071001'
24+
__version__ = '2023071203'
2525

2626
DESCRIPTION = 'Tracks if Apache httpd is EOL.'
2727

@@ -77,7 +77,7 @@ def main():
7777
# fetch data
7878
installed_version = get_installed_version()
7979
if not installed_version:
80-
lib.base.oao('Apache httpd not found.', STATE_UNKNOWN)
80+
lib.base.cu('Apache httpd not found.')
8181
try:
8282
installed_major, installed_minor, installed_patch = installed_version.split('.')
8383
except:

check-plugins/axenita-stats/axenita-stats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2323
STATE_UNKNOWN, STATE_WARN)
2424

2525
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
26-
__version__ = '2023051201'
26+
__version__ = '2023071201'
2727

2828
DESCRIPTION = 'With this plugin you can track some values of the Axenita application.'
2929

@@ -110,7 +110,7 @@ def main():
110110
try:
111111
stdout = json.loads(stdout)
112112
except:
113-
lib.base.oao('ValueError: No JSON object could be decoded', STATE_UNKNOWN)
113+
lib.base.cu('ValueError: No JSON object could be decoded')
114114

115115
if 'readmodel' in args.TEST[0]:
116116
achilles_readmodel = stdout

check-plugins/borgbackup/borgbackup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2222
STATE_UNKNOWN, STATE_WARN)
2323

2424
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
25-
__version__ = '2023051201'
25+
__version__ = '2023071203'
2626

2727
DESCRIPTION = '''Checks the date and return code of the last borgbackup, according to the logfile.
2828
`cat /var/log/borg/borg-prune.log`
@@ -88,7 +88,7 @@ def main():
8888
# end: 2020-04-08 23:00:13
8989

9090
if os.path.exists(path) <= 0 and not os.path.isfile(path):
91-
lib.base.oao('Logfile {} not found or empty.'.format(path), STATE_UNKNOWN)
91+
lib.base.cu('Logfile {} not found or empty.'.format(path))
9292

9393
mount_lines = ''
9494
with open('/proc/mounts') as mountlist:
@@ -122,7 +122,7 @@ def main():
122122
create_retc
123123
prune_retc
124124
except UnboundLocalError as e:
125-
lib.base.oao('Could not find all expected values in the logfile.\n{}'.format(e), STATE_UNKNOWN)
125+
lib.base.cu('Could not find all expected values in the logfile.\n{}'.format(e))
126126

127127
# We ignore retc 1, as it means operation reached its normal end, but there were warnings from borg.
128128
state = STATE_OK

check-plugins/cometsystem/cometsystem

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2525

2626
__author__ = """Linuxfabrik GmbH, Zurich/Switzerland;
2727
originally written by Dominik Riva, Universitätsspital Basel/Switzerland"""
28-
__version__ = '2023051201'
28+
__version__ = '2023071203'
2929

3030
DESCRIPTION = """This check targets the JSON endpoint of https://www.cometsystem.com/ Web Sensors.
3131
"""
@@ -168,7 +168,7 @@ def main():
168168
stdout, stderr, retc = lib.test.test(args.TEST)
169169
result = json.loads(stdout)
170170
if 'ch1' not in result:
171-
lib.base.oao('Malformed Comet System Web Sensors status file.', STATE_UNKNOWN)
171+
lib.base.cu('Malformed Comet System Web Sensors status file.')
172172

173173
# init some vars
174174
msg = ''

check-plugins/countdown/countdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2323
STATE_UNKNOWN, STATE_WARN)
2424

2525
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
26-
__version__ = '2023051201'
26+
__version__ = '2023071203'
2727

2828
DESCRIPTION = 'Warns before an expiration date is scheduled to occur.'
2929

@@ -117,7 +117,7 @@ def main():
117117
lib.base.oao(msg, state, always_ok=args.ALWAYS_OK)
118118

119119
except Exception as e:
120-
lib.base.oao('Something seems to be wrong with the input parameter format or its timestamps. The error was: {}'.format(e), STATE_UNKNOWN)
120+
lib.base.cu('Something seems to be wrong with the input parameter format or its timestamps. The error was: {}'.format(e))
121121

122122

123123
if __name__ == '__main__':

check-plugins/cpu-usage/cpu-usage

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2525
try:
2626
import psutil # pylint: disable=C0413
2727
except ImportError:
28-
lib.base.oao('Python module "psutil" is not installed.', STATE_UNKNOWN)
28+
lib.base.cu('Python module "psutil" is not installed.')
2929

3030

3131
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
32-
__version__ = '2023051201'
32+
__version__ = '2023071203'
3333

3434
DESCRIPTION = """Mainly provides utilization percentages for each specific CPU time. Takes a time
3535
period into account: the cpu usage within a certain amount of time has to be equal
@@ -139,7 +139,7 @@ def main():
139139
cpu_times_percent = psutil.cpu_times_percent(interval=1.25, percpu=False)
140140
except ValueError as e:
141141
lib.db_sqlite.close(conn)
142-
lib.base.oao('psutil raised error "{}"'.format(e), STATE_UNKNOWN)
142+
lib.base.cu('psutil raised error "{}"'.format(e))
143143

144144
# this is what we want to warn about: 100% - idle - nice
145145
stats['cpu_usage'] = round(

check-plugins/crypto-policy/crypto-policy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ from lib.globals import (STATE_OK, STATE_UNKNOWN, # pylint: disable=C0413
2020
STATE_WARN)
2121

2222
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
23-
__version__ = '2023051201'
23+
__version__ = '2023071203'
2424

2525
DESCRIPTION = """Checks the current crypto policy against a desired one,
2626
and returns a warning on a non-match."""
@@ -72,7 +72,7 @@ def main():
7272
# execute the shell command and return its result and exit code
7373
success, result = lib.shell.shell_exec(CMD)
7474
if not success:
75-
lib.base.oao('Crypto policies are not applicable to your system.', STATE_UNKNOWN)
75+
lib.base.cu('Crypto policies are not applicable to your system.')
7676
stdout, stderr, retc = result
7777
crypto_policy = stdout.strip()
7878

check-plugins/csv-values/csv-values

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
3232
STATE_UNKNOWN, STATE_WARN)
3333

3434
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
35-
__version__ = '2023051201'
35+
__version__ = '2023071201'
3636

3737
DESCRIPTION = """This check imports a CSV file into an SQLite database and can then run a separate
3838
warning query and/or a critical query against it. The result - the number of
@@ -247,7 +247,7 @@ def main():
247247
sys.exit(STATE_UNKNOWN)
248248

249249
if args.WARNING_QUERY is None and args.CRITICAL_QUERY is None:
250-
lib.base.oao('Nothing to check, no queries provided.', STATE_UNKNOWN)
250+
lib.base.cu('Nothing to check, no queries provided.')
251251
if args.WARNING_QUERY is None:
252252
args.WARNING_QUERY = ''
253253
if args.CRITICAL_QUERY is None:
@@ -278,7 +278,7 @@ def main():
278278
)
279279
proto, url = split_url
280280
if proto not in ['http', 'https', 'smb']:
281-
lib.base.oao('The protocol "{}" is not supported.'.format(proto), STATE_UNKNOWN)
281+
lib.base.cu('The protocol "{}" is not supported.'.format(proto))
282282

283283
if proto in ['http', 'https']:
284284
header = {}

0 commit comments

Comments
 (0)