Browse Source

status.py: Fix for exception while stopped nagios service

master
Dirk Alders 4 months ago
parent
commit
407641b1d5
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      status.py

+ 3
- 1
status.py View File

184
 
184
 
185
 
185
 
186
 class nagios_status(__nagios_status__):
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
     KEY_DATA = 'data'
188
     KEY_DATA = 'data'
189
     KEY_SERVICELIST = 'servicelist'
189
     KEY_SERVICELIST = 'servicelist'
190
 
190
 
218
         s = nagios_status(args.hostname, args.secure, args.last)
218
         s = nagios_status(args.hostname, args.secure, args.last)
219
     except requests.ConnectionError:
219
     except requests.ConnectionError:
220
         print(headline(not args.monochrome) + "Can not connect to given host.")
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
     else:
223
     else:
222
         if args.all:
224
         if args.all:
223
             print(s.__str__(color=not args.monochrome))
225
             print(s.__str__(color=not args.monochrome))

Loading…
Cancel
Save