File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 5
5
# check_opnsense.py - A check plugin for monitoring OPNsense firewalls.
6
6
# Copyright (C) 2018 Nicolai Buchwitz <[email protected] >
7
7
#
8
- # Version: 0.1.0
8
+ # Version: 0.1.1
9
9
#
10
10
# ------------------------------------------------------------------------------
11
11
# This program is free software; you can redistribute it and/or
@@ -211,18 +211,27 @@ def check_updates(self) -> None:
211
211
url = self .get_url ("core/firmware/status" )
212
212
data = self .request (url )
213
213
214
- if data ["status" ] == "ok" and data ["status_upgrade_action" ] == "all" :
214
+ if (
215
+ data ["status" ] == "ok"
216
+ and data .get ("status_upgrade_action" , "" ) == "all"
217
+ and "updates" in data
218
+ ):
219
+ # legacy api call
215
220
count = data ["updates" ]
216
221
217
222
self .check_result = CheckState .WARNING
218
- self .check_message = "{ } pending updates". format ( count )
219
-
220
- if data [ "upgrade_needs_reboot" ]:
221
- self .check_result = CheckState .CRITICAL
222
- self .check_message = "{}. Subsequent reboot required." . format ( self . check_message )
223
+ self .check_message = f" { count } pending updates"
224
+ elif data [ "status" ] == "update" :
225
+ # api call since 22.7.x
226
+ self .check_result = CheckState .WARNING
227
+ self .check_message = data [ "status_msg" ]
223
228
else :
224
229
self .check_message = "System up to date"
225
230
231
+ if data ["upgrade_needs_reboot" ]:
232
+ self .check_result = CheckState .CRITICAL
233
+ self .check_message = f"{ self .check_message } . Subsequent reboot required."
234
+
226
235
def __init__ (self ) -> None :
227
236
self .options = {}
228
237
self .perfdata = []
You can’t perform that action at this time.
0 commit comments