fixed agent

This commit is contained in:
George Pochiscan 2020-09-03 18:22:01 +03:00
parent a69edee91b
commit 3d4779c3ff
1 changed files with 9 additions and 7 deletions

View File

@ -28,8 +28,8 @@ import sys
import getopt import getopt
import pprint import pprint
import json import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning import urllib3
import requests
def usage(): def usage():
sys.stderr.write("""Check_MK Hitachi VSP sys.stderr.write("""Check_MK Hitachi VSP
@ -57,7 +57,7 @@ except getopt.GetoptError as err:
sys.exit(1) sys.exit(1)
opt_demo = True opt_demo = False
opt_cert = True opt_cert = True
args_dict = {} args_dict = {}
@ -78,9 +78,11 @@ for o,a in opts:
def query(url): def query(url):
if opt_cert == False: if not opt_cert:
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
response = requests.get(url, auth = (args_dict["username"], args_dict["password"]), verify=opt_cert) response = requests.get(url,
auth=(args_dict["username"], args_dict["password"]),
verify=opt_cert)
raw_json = response.text raw_json = response.text
return raw_json return raw_json
@ -253,7 +255,7 @@ def process_storage_clprs():
full_data = json.loads(raw_json) full_data = json.loads(raw_json)
data = full_data["data"] data = full_data["data"]
output("clprId\tcacheMemoryCapacity\tcacheMemoryUsedCapacity\twritePendingDataCapacity\t" output("clprId\tcacheMemoryCapacity\tcacheMemoryUsedCapacity\twritePendingDataCapacity\t"
"cacheUsageRate") "writePendingDataCapacity\tcacheUsageRate")
for clpr in data: for clpr in data:
output("%s\t%s\t%s\t%s\t%s" % (clpr["clprId"], clpr["cacheMemoryCapacity"], clpr["cacheMemoryUsedCapacity"], output("%s\t%s\t%s\t%s\t%s" % (clpr["clprId"], clpr["cacheMemoryCapacity"], clpr["cacheMemoryUsedCapacity"],
clpr["writePendingDataCapacity"], clpr["cacheUsageRate"])) clpr["writePendingDataCapacity"], clpr["cacheUsageRate"]))