Bladeren bron

status.py: Fix for exception while stopped nagios service

master
Dirk Alders 2 maanden geleden
bovenliggende
commit
407641b1d5
1 gewijzigde bestanden met toevoegingen van 3 en 1 verwijderingen
  1. 3
    1
      status.py

+ 3
- 1
status.py Bestand weergeven

@@ -184,7 +184,7 @@ class __nagios_status__(dict):
184 184
 
185 185
 
186 186
 class nagios_status(__nagios_status__):
187
-    URL = "nagios4/cgi-bin/statusjson.cgi?query=servicelist&details=true"  # &servicestatus=warning"
187
+    URL = "nagios4/cgi-bin/statusjson.cgi?query=servicelist&details=true"
188 188
     KEY_DATA = 'data'
189 189
     KEY_SERVICELIST = 'servicelist'
190 190
 
@@ -218,6 +218,8 @@ if __name__ == "__main__":
218 218
         s = nagios_status(args.hostname, args.secure, args.last)
219 219
     except requests.ConnectionError:
220 220
         print(headline(not args.monochrome) + "Can not connect to given host.")
221
+    except requests.exceptions.JSONDecodeError:
222
+        print(headline(not args.monochrome) + "No data received. Nagios is possibly down.")
221 223
     else:
222 224
         if args.all:
223 225
             print(s.__str__(color=not args.monochrome))

Laden…
Annuleren
Opslaan