From 2b8936a83395567584f14311929f1dd705c3c7b8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Sep 2019 13:34:35 +0200 Subject: [PATCH 1/3] Fix for PVEv6 --- PVE-Zabbix.py | 4 ++-- PVEApi.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PVE-Zabbix.py b/PVE-Zabbix.py index 0168026..2df3864 100755 --- a/PVE-Zabbix.py +++ b/PVE-Zabbix.py @@ -5,8 +5,8 @@ from VM import VM from Storage import Storage USERNAME = "zabbix@pve" -PASSWORD = "zabbix" -HOST = "172.16.3.11:8006" +PASSWORD = "KbCurGdt82NTgBye" +HOST = "localhost:8006" conn = PVEApi(HOST, USERNAME, PASSWORD) nodelist = conn.get_node_list() diff --git a/PVEApi.py b/PVEApi.py index 8575ea2..fa5afa6 100755 --- a/PVEApi.py +++ b/PVEApi.py @@ -135,7 +135,10 @@ class PVEApi(object): active = storage[u'active'] enabled = storage[u'enabled'] avail = storage[u'avail'] - used_fraction = storage[u'used_fraction'] + try: + used_fraction = storage[u'used_fraction'] + except KeyError: + used_fraction = "Error getting value" stor = Storage(node, name, total, used, active, enabled, avail, used_fraction) storagelist.append(stor) return storagelist From 84607d5399ca228547d565147ba1f0536735f375 Mon Sep 17 00:00:00 2001 From: osiu97 Date: Wed, 23 Oct 2019 08:18:50 +0200 Subject: [PATCH 2/3] Added Exception to work with offline hosts in cluster --- PVEApi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PVEApi.py b/PVEApi.py index fa5afa6..5363c1d 100755 --- a/PVEApi.py +++ b/PVEApi.py @@ -73,7 +73,10 @@ class PVEApi(object): vmlist = list() for node in nodelist: url = self.url + '/nodes/' + node.name + '/qemu' - response = json.load(urllib2.urlopen(self.get_request(url), context=ssl._create_unverified_context())) + try: + response = json.load(urllib2.urlopen(self.get_request(url), context=ssl._create_unverified_context())) + except Exception as e: + passs resources = response['data'] for machine in resources: name = machine[u'name'] From 10b832c71db3da75ebb1b3aefb5bfccfb35dbdef Mon Sep 17 00:00:00 2001 From: osiu97 Date: Wed, 23 Oct 2019 10:48:46 +0200 Subject: [PATCH 3/3] fixed typo --- PVEApi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PVEApi.py b/PVEApi.py index 5363c1d..2305e04 100755 --- a/PVEApi.py +++ b/PVEApi.py @@ -76,7 +76,7 @@ class PVEApi(object): try: response = json.load(urllib2.urlopen(self.get_request(url), context=ssl._create_unverified_context())) except Exception as e: - passs + pass resources = response['data'] for machine in resources: name = machine[u'name']