瀏覽代碼

status.py: Fix for exception while stopped nagios service

master
Dirk Alders 4 月之前
父節點
當前提交
407641b1d5
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3
    1
      status.py

+ 3
- 1
status.py 查看文件

@@ -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))

Loading…
取消
儲存