Skip to content

Commit 7fbe46e

Browse files
committed
adjust cu() error messages, preventing duplicate tracebacks
1 parent a2e9306 commit 7fbe46e

File tree

14 files changed

+42
-42
lines changed

14 files changed

+42
-42
lines changed

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__ = '2023071203'
25+
__version__ = '2023071301'
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`
@@ -121,8 +121,8 @@ def main():
121121
endtime
122122
create_retc
123123
prune_retc
124-
except UnboundLocalError as e:
125-
lib.base.cu('Could not find all expected values in the logfile.\n{}'.format(e))
124+
except UnboundLocalError:
125+
lib.base.cu('Could not find all expected values in the logfile.')
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/countdown/countdown

Lines changed: 3 additions & 3 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__ = '2023071203'
26+
__version__ = '2023071301'
2727

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

@@ -116,8 +116,8 @@ def main():
116116
# over and out
117117
lib.base.oao(msg, state, always_ok=args.ALWAYS_OK)
118118

119-
except Exception as e:
120-
lib.base.cu('Something seems to be wrong with the input parameter format or its timestamps. The error was: {}'.format(e))
119+
except Exception:
120+
lib.base.cu('Something seems to be wrong with the input parameter format or its timestamps')
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
@@ -29,7 +29,7 @@ except ImportError:
2929

3030

3131
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
32-
__version__ = '2023071203'
32+
__version__ = '2023071301'
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
@@ -137,9 +137,9 @@ def main():
137137
# https://github.com/Linuxfabrik/monitoring-plugins/issues/57: changed from 0.25 to 1.25
138138
try:
139139
cpu_times_percent = psutil.cpu_times_percent(interval=1.25, percpu=False)
140-
except ValueError as e:
140+
except ValueError:
141141
lib.db_sqlite.close(conn)
142-
lib.base.cu('psutil raised error "{}"'.format(e))
142+
lib.base.cu('psutil raised an error')
143143

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

check-plugins/disk-io/disk-io

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ except ImportError as e:
3131

3232

3333
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
34-
__version__ = '2023071203'
34+
__version__ = '2023071301'
3535

3636
DESCRIPTION = """Checks disk IO."""
3737

@@ -149,7 +149,7 @@ def main():
149149
try:
150150
disk_io_counters = psutil.disk_io_counters(perdisk=True)
151151
except ValueError as e:
152-
lib.base.cu('psutil raised error "{}"'.format(e))
152+
lib.base.cu('psutil raised an error')
153153

154154
now = lib.time.now()
155155

check-plugins/docker-stats/docker-stats

Lines changed: 2 additions & 2 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__ = '2023071203'
27+
__version__ = '2023071301'
2828

2929
DESCRIPTION = """This check prints various statistics for all running Docker containers, in much the
3030
same way as the Unix application top, using the "docker stats" command."""
@@ -165,7 +165,7 @@ def main():
165165
strpos2 = stdout.find('\n', strpos1)
166166
host_cpus = int(stdout[strpos1:strpos2])
167167
except:
168-
lib.base.cu('{}'.format('Unable to compute docker info.'))
168+
lib.base.cu('Unable to compute docker info')
169169

170170
# get the container statistics for all running containers
171171
cmd = 'docker stats --no-stream'

check-plugins/fs-inodes/fs-inodes

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

2222
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
23-
__version__ = '2023071201'
23+
__version__ = '2023071301'
2424

2525
DESCRIPTION = 'Checks the used inode space in percent, default on "/", "/tmp" and "/boot".'
2626

@@ -105,8 +105,8 @@ def main():
105105
elif inodes_used >= args.WARN:
106106
state = lib.base.get_worst(state, STATE_WARN)
107107
msg = msg[:-2] + ' (WARN), '
108-
except Exception as e:
109-
lib.base.cu('Something seems to be wrong with the input parameter. The error was: {}'.format(e))
108+
except Exception:
109+
lib.base.cu('Something seems to be wrong with the input parameter')
110110

111111
# over and out
112112
lib.base.oao(msg[:-2], state, perfdata, always_ok=args.ALWAYS_OK)

check-plugins/matomo-reporting/matomo-reporting

Lines changed: 2 additions & 2 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__ = '2023071203'
25+
__version__ = '2023071301'
2626

2727
DESCRIPTION = """This plugin lets you check the most common analytics values from Matomo, for one
2828
or several websites and for any given date and period."""
@@ -144,7 +144,7 @@ def main():
144144
url = args.URL + ('/' if not args.URL.endswith('/') else '') + 'index.php?method=API.get&idSite={}&period={}&date={}&module=API&token_auth={}&format=json&filter_limit=1'.format(args.IDSITE, args.PERIOD, args.DATE, args.PASSWORD)
145145
result = lib.base.coe(lib.url.fetch_json(url, insecure=args.INSECURE, no_proxy=args.NO_PROXY, timeout=args.TIMEOUT))
146146
if 'result' in result and result['result'] == 'error':
147-
lib.base.cu('{}'.format(result['message']))
147+
lib.base.cu(result['message'])
148148

149149
# init some vars
150150
msg = ''

check-plugins/network-io/network-io

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ except ImportError as e:
2929

3030

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

3434
DESCRIPTION = """Checks network IO."""
3535

@@ -132,8 +132,8 @@ def main():
132132
# get interface data and store it to database
133133
try:
134134
net_io_counters = psutil.net_io_counters(pernic=True, nowrap=True)
135-
except ValueError as e:
136-
lib.base.cu('psutil raised error "{}"'.format(e))
135+
except ValueError:
136+
lib.base.cu('psutil raised an error')
137137

138138
now = lib.time.now()
139139

check-plugins/openstack-nova-list/openstack-nova-list

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ except ImportError:
3636

3737

3838
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
39-
__version__ = '2023071202'
39+
__version__ = '2023071301'
4040

4141
DESCRIPTION = """Nova is the OpenStack project that provides a way to provision compute
4242
instances (aka virtual servers).
@@ -210,11 +210,11 @@ def main():
210210
try:
211211
nova = client.Client(2, session=session.Session(auth=auth)) # NOVA_API_VERSION=2
212212
except Exception as e:
213-
lib.base.cu(e.message)
213+
lib.base.cu('An error occurred while connecting to Nova')
214214
try:
215215
servers = nova.servers.list()
216216
except Exception as e:
217-
lib.base.cu(e.message)
217+
lib.base.cu('An error occurred while getting the server list from Nova')
218218

219219
# init some vars
220220
msg = ''

check-plugins/pip-updates/pip-updates

Lines changed: 2 additions & 2 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__ = '2023071203'
27+
__version__ = '2023071301'
2828

2929
DESCRIPTION = """Checks if there are outdated Python packages, installed via `pip`."""
3030

@@ -216,7 +216,7 @@ def main():
216216
try:
217217
packages = json.loads(stdout)
218218
except:
219-
return lib.base.cu('ValueError: No JSON object could be decoded')
219+
return lib.base.cu('Failed to parse JSON.')
220220

221221
# init some vars
222222
if args.VIRTUALENV:

0 commit comments

Comments
 (0)