@@ -107,11 +107,6 @@ def discovery_yum(section: Section):
107107def check_yum (params : Dict [str , object ], section : Section ):
108108 debug = False
109109
110- def extract_levels (entry , default ):
111- if isinstance (entry , tuple ) and isinstance (entry [0 ], str ):
112- return entry [1 ]
113- return entry
114-
115110 if section .error_message :
116111 yield Result (state = State .UNKNOWN , summary = section .error_message )
117112 return
@@ -127,23 +122,31 @@ def extract_levels(entry, default):
127122 yield Result (state = State .OK , summary = "All packages are up to date" )
128123 yield Metric (name = "normal_updates" , value = 0 )
129124 else :
130- warn , crit = extract_levels (params .get ("normal" , (5 , 10 )), (5 , 10 ))
131- if section .packages >= crit :
132- state = State .CRIT
133- elif section .packages >= warn :
134- state = State .WARN
125+ mode , levels = params .get ("normal" )
126+ if mode == 'fixed' :
127+ warn , crit = levels
128+ if section .packages >= crit :
129+ state = State .CRIT
130+ elif section .packages >= warn :
131+ state = State .WARN
132+ else :
133+ state = State .OK
135134 else :
136135 state = State .OK
137136 yield Result (state = state , summary = f"{ section .packages } normal updates available" )
138137 yield Metric (name = "normal_updates" , value = section .packages )
139138
140139 # === Security Updates ===
141140 if section .security_packages >= 0 :
142- warn , crit = extract_levels (params .get ("security" , (1 , 3 )), (1 , 3 ))
143- if section .security_packages >= crit :
144- state = State .CRIT
145- elif section .security_packages >= warn :
146- state = State .WARN
141+ mode , levels = params .get ("security" )
142+ if mode == 'fixed' :
143+ warn , crit = levels
144+ if section .security_packages >= crit :
145+ state = State .CRIT
146+ elif section .security_packages >= warn :
147+ state = State .WARN
148+ else :
149+ state = State .OK
147150 else :
148151 state = State .OK
149152 if section .security_packages_list :
@@ -204,8 +207,8 @@ def extract_levels(entry, default):
204207 check_ruleset_name = "yum" ,
205208 check_default_parameters = {
206209 "reboot_req" : 2 ,
207- "normal" : (1 , 3 ) ,
208- "security" : ( 5 , 10 ) ,
210+ "normal" : { "fixed" : (1 , 10 )} ,
211+ "security" : { "fixed" : ( 1 , 1 )} ,
209212 "last_update_state" : 1 ,
210213 "last_update_time_diff" : 60 ,
211214 },
0 commit comments