@@ -69,49 +69,57 @@ def check_suseconnect(
6969    if  (specs  :=  get_data (section )) is  None :
7070        return 
7171
72-     state , infotext  =  0 , "Status: %(registration_status)s"  %  specs 
73-     if  params ["status" ] !=  "Ignore"  and  params ["status" ] !=  specs ["registration_status" ]:
74-         state  =  2 
75-     yield  state , infotext 
72+     if  "registration_status"  in  specs :
73+         state , infotext  =  0 , "Status: %s"  %  specs ["registration_status" ]
74+         if  params ["status" ] !=  "Ignore"  and  params ["status" ] !=  specs ["registration_status" ]:
75+             state  =  2 
76+         yield  state , infotext 
77+ 
78+     if  "subscription_status"  in  specs :
79+         state , infotext  =  0 , "Subscription: %s"  %  specs ["subscription_status" ]
80+         if  (
81+             params ["subscription_status" ] !=  "Ignore" 
82+             and  params ["subscription_status" ] !=  specs ["subscription_status" ]
83+         ):
84+             state  =  2 
85+         yield  state , infotext 
7686
77-     state , infotext  =  0 , "Subscription: %(subscription_status)s"  %  specs 
7887    if  (
79-         params ["subscription_status" ] !=  "Ignore" 
80-         and  params ["subscription_status" ] !=  specs ["subscription_status" ]
88+         "subscription_type"  in  specs 
89+         and  "registration_code"  in  specs 
90+         and  "starts_at"  in  specs 
91+         and  "expires_at"  in  specs 
8192    ):
82-         state  =  2 
83-     yield  state , infotext 
84- 
85-     yield  (
86-         0 ,
87-         (
88-             "Subscription type: %(subscription_type)s, Registration code: %(registration_code)s, " 
89-             "Starts at: %(starts_at)s, Expires at: %(expires_at)s" 
93+         yield  (
94+             0 ,
95+             (
96+                 "Subscription type: %(subscription_type)s, Registration code: %(registration_code)s, " 
97+                 "Starts at: %(starts_at)s, Expires at: %(expires_at)s" 
98+             )
99+             %  specs ,
90100        )
91-         %  specs ,
92-     )
93101
94-     expiration_date  =  time .strptime (specs ["expires_at" ], "%Y-%m-%d %H:%M:%S %Z" )
95-     expiration_time  =  time .mktime (expiration_date ) -  time .time ()
102+          expiration_date  =  time .strptime (specs ["expires_at" ], "%Y-%m-%d %H:%M:%S %Z" )
103+          expiration_time  =  time .mktime (expiration_date ) -  time .time ()
96104
97-     if  expiration_time  >  0 :
98-         warn , crit  =  params ["days_left" ]
99-         days2seconds  =  24  *  60  *  60 
105+          if  expiration_time  >  0 :
106+              warn , crit  =  params ["days_left" ]
107+              days2seconds  =  24  *  60  *  60 
100108
101-         if  expiration_time  <=  crit  *  days2seconds :
102-             state  =  2 
103-         elif  expiration_time  <=  warn  *  days2seconds :
104-             state  =  1 
105-         else :
106-             state  =  0 
109+              if  expiration_time  <=  crit  *  days2seconds :
110+                  state  =  2 
111+              elif  expiration_time  <=  warn  *  days2seconds :
112+                  state  =  1 
113+              else :
114+                  state  =  0 
107115
108-         infotext  =  "Expires in: %s"  %  render .timespan (expiration_time )
109-         if  state :
110-             infotext  +=  " (warn/crit at %d/%d days)"  %  (warn , crit )
116+              infotext  =  "Expires in: %s"  %  render .timespan (expiration_time )
117+              if  state :
118+                  infotext  +=  " (warn/crit at %d/%d days)"  %  (warn , crit )
111119
112-         yield  state , infotext 
113-     else :
114-         yield  2 , "Expired since: %s"  %  render .timespan (- 1.0  *  expiration_time )
120+              yield  state , infotext 
121+          else :
122+              yield  2 , "Expired since: %s"  %  render .timespan (- 1.0  *  expiration_time )
115123
116124
117125check_info ["suseconnect" ] =  LegacyCheckDefinition (
0 commit comments