-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: handle changed opnsense api since 22.7.x
- Loading branch information
Showing
1 changed file
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# check_opnsense.py - A check plugin for monitoring OPNsense firewalls. | ||
# Copyright (C) 2018 Nicolai Buchwitz <[email protected]> | ||
# | ||
# Version: 0.1.0 | ||
# Version: 0.1.1 | ||
# | ||
# ------------------------------------------------------------------------------ | ||
# This program is free software; you can redistribute it and/or | ||
|
@@ -211,15 +211,19 @@ def check_updates(self) -> None: | |
url = self.get_url("core/firmware/status") | ||
data = self.request(url) | ||
|
||
if data["status"] == "ok" and data["status_upgrade_action"] == "all": | ||
count = data["updates"] | ||
if data["status"] in ("none", "error"): | ||
# no update information available -> trigger check | ||
data = self.request(url, method="post") | ||
|
||
has_update = data["status"] in ("update", "upgrade") | ||
needs_reboot = data["status_reboot"] == "1" | ||
|
||
if has_update: | ||
self.check_result = CheckState.WARNING | ||
self.check_message = "{} pending updates".format(count) | ||
self.check_message = data["status_msg"] | ||
|
||
if data["upgrade_needs_reboot"]: | ||
if needs_reboot: | ||
self.check_result = CheckState.CRITICAL | ||
self.check_message = "{}. Subsequent reboot required.".format(self.check_message) | ||
else: | ||
self.check_message = "System up to date" | ||
|
||
|