mirror of
https://github.com/recklessop/Zerto_Exporter.git
synced 2026-07-05 08:43:14 -04:00
Update python-node-exporter.py
updated how scratch used storage is calculated. Zerto volumes API shows data per volume, not per VM, so needed to sum the values.
This commit is contained in:
@@ -67,16 +67,19 @@ def GetDataFunc():
|
|||||||
volapi = requests.get(url=uri, timeout=5, headers=h2, verify=verifySSL)
|
volapi = requests.get(url=uri, timeout=5, headers=h2, verify=verifySSL)
|
||||||
volapi_json = volapi.json()
|
volapi_json = volapi.json()
|
||||||
|
|
||||||
if(bool(volapi_json)){
|
if(bool(volapi_json)):
|
||||||
for volume in volapi_json :
|
for volume in volapi_json :
|
||||||
metricsDictionary["scratch_volume_size_used_in_bytes{ProtectedVM=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = volume["Size"]["UsedInBytes"]
|
#metricsDictionary["scratch_volume_provisioned_size_in_bytes{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = volume["Size"]["ProvisionedInBytes"]
|
||||||
metricsDictionary["scratch_volume_provisioned_size_in_bytes{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = volume["Size"]["ProvisionedInBytes"]
|
metrickey = "scratch_volume_size_in_bytes{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"
|
||||||
|
if (metrickey in metricsDictionary):
|
||||||
|
metricsDictionary[metrickey] = metricsDictionary[metrickey] + volume["Size"]["UsedInBytes"]
|
||||||
|
else:
|
||||||
|
metricsDictionary[metrickey] = volume["Size"]["UsedInBytes"]
|
||||||
percentage_used = (volume["Size"]["UsedInBytes"] / volume["Size"]["ProvisionedInBytes"] * 100)
|
percentage_used = (volume["Size"]["UsedInBytes"] / volume["Size"]["ProvisionedInBytes"] * 100)
|
||||||
percentage_used = round(percentage_used, 1)
|
percentage_used = round(percentage_used, 1)
|
||||||
metricsDictionary["scratch_volume_percentage_used{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = percentage_used
|
#metricsDictionary["scratch_volume_percentage_used{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = percentage_used
|
||||||
}
|
|
||||||
|
|
||||||
# This function will get data every 5 seconds
|
# This function will get data every 30 seconds
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
# open file to write new data
|
# open file to write new data
|
||||||
@@ -107,4 +110,4 @@ def WebServer():
|
|||||||
|
|
||||||
# run WebServer func in the background
|
# run WebServer func in the background
|
||||||
background_thread = Thread(target = WebServer)
|
background_thread = Thread(target = WebServer)
|
||||||
background_thread.start()
|
background_thread.start()
|
||||||
Reference in New Issue
Block a user