Skip to content

Commit 148ddde

Browse files
committed
fix: close SQLite connections before early exits in docker-stats, podman-stats, fortios-network-io
1 parent 9510231 commit 148ddde

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

check-plugins/docker-stats/docker-stats

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import lib.txt
2222
from lib.globals import STATE_CRIT, STATE_OK, STATE_UNKNOWN, STATE_WARN
2323

2424
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
25-
__version__ = '2026040803'
25+
__version__ = '2026041002'
2626

2727
DESCRIPTION = """Reports CPU and memory usage for all running Docker containers. CPU usage is
2828
normalized by dividing by the number of available host CPU cores. CPU alerts only
@@ -170,8 +170,10 @@ def main():
170170
lib.shell.shell_exec('docker info'),
171171
)
172172
if retc != 0:
173+
lib.db_sqlite.close(conn)
173174
lib.base.oao(f'{stderr}\n{stdout}', STATE_CRIT)
174175
if 'server version:' not in stdout.lower():
176+
lib.db_sqlite.close(conn)
175177
lib.base.cu(
176178
'Unable to parse docker info output.'
177179
' If you are using Podman, use the podman-stats check instead.'
@@ -185,6 +187,7 @@ def main():
185187
lib.shell.shell_exec('docker stats --no-stream'),
186188
)
187189
if retc != 0:
190+
lib.db_sqlite.close(conn)
188191
lib.base.oao(stderr, STATE_CRIT)
189192
else:
190193
# do not call the command, put in test data

check-plugins/fortios-network-io/fortios-network-io

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import lib.url
2323
from lib.globals import STATE_CRIT, STATE_OK, STATE_UNKNOWN, STATE_WARN
2424

2525
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
26-
__version__ = '2026040801'
26+
__version__ = '2026041002'
2727

2828
DESCRIPTION = """Monitors network I/O and link states on all interfaces of FortiGate appliances running FortiOS via the REST API. Alerts only if bandwidth thresholds have been exceeded for a configurable number of consecutive check runs (default: 5), suppressing short spikes. Reports per-interface traffic counters, error rates, and link status."""
2929

@@ -278,6 +278,7 @@ def main():
278278
)
279279
)
280280
if not loads:
281+
lib.db_sqlite.close(conn)
281282
lib.base.oao('Waiting for more data.', STATE_OK)
282283

283284
msg_saturation = ''
@@ -382,6 +383,8 @@ def main():
382383
],
383384
)
384385

386+
lib.db_sqlite.close(conn)
387+
385388
# over and out
386389
if not msg_link and not msg_saturation:
387390
# no warnings, so print the interface with the highest load

check-plugins/podman-stats/podman-stats

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import lib.shell
2222
from lib.globals import STATE_CRIT, STATE_OK, STATE_UNKNOWN, STATE_WARN
2323

2424
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
25-
__version__ = '2026040802'
25+
__version__ = '2026041002'
2626

2727
DESCRIPTION = """Reports CPU and memory usage for all running Podman containers. CPU usage is
2828
normalized by dividing by the number of available host CPU cores. CPU alerts only
@@ -170,20 +170,23 @@ def main():
170170
lib.shell.shell_exec('podman info --format json'),
171171
)
172172
if retc != 0:
173+
lib.db_sqlite.close(conn)
173174
lib.base.oao(f'{stderr}\n{stdout}', STATE_CRIT)
174175
try:
175176
podman_info = json.loads(stdout)
176177
host_cpus = podman_info['host']['cpus']
177178
host_images = podman_info['store']['imageStore']['number']
178179
host_ram = podman_info['host']['memTotal']
179180
except Exception:
181+
lib.db_sqlite.close(conn)
180182
lib.base.cu('Unable to parse podman info output as JSON.')
181183

182184
# get the container statistics for all running containers
183185
stdout, stderr, retc = lib.base.coe(
184186
lib.shell.shell_exec("podman stats --no-stream --format '{{json .}}'"),
185187
)
186188
if retc != 0:
189+
lib.db_sqlite.close(conn)
187190
lib.base.oao(stderr, STATE_CRIT)
188191
else:
189192
# do not call the command, put in test data

0 commit comments

Comments
 (0)