mirror of
https://github.com/recklessop/Zerto_Exporter.git
synced 2026-07-02 23:53:13 -04:00
Update python-node-exporter.py
added journal volume size and number of VMDKs per VM
This commit is contained in:
@@ -273,7 +273,7 @@ def GetDataFunc():
|
||||
metricsDictionary["vm_status{VmIdentifier=\"" + vm['VmIdentifier'] + "\",VmName=\"" + vm['VmName'] + "\",VmRecoveryVRA=\"" + vm["RecoveryHostName"] + "\",VmPriority=\"" + str(vm['Priority']) + "\"}"] = vm["Status"]
|
||||
metricsDictionary["vm_substatus{VmIdentifier=\"" + vm['VmIdentifier'] + "\",VmName=\"" + vm['VmName'] + "\",VmRecoveryVRA=\"" + vm["RecoveryHostName"] + "\",VmPriority=\"" + str(vm['Priority']) + "\"}"] = vm["SubStatus"]
|
||||
|
||||
## Volumes API
|
||||
## Volumes API for Scratch Volumes
|
||||
uri = "https://" + zvm_url + ":" + zvm_port + "/v1/volumes?volumeType=scratch"
|
||||
volapi = requests.get(url=uri, timeout=5, headers=h2, verify=verifySSL)
|
||||
volapi_json = volapi.json()
|
||||
@@ -291,6 +291,28 @@ def GetDataFunc():
|
||||
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
|
||||
|
||||
## Volumes API for Journal Volumes
|
||||
uri = "https://" + zvm_url + ":" + zvm_port + "/v1/volumes?volumeType=journal"
|
||||
volapi = requests.get(url=uri, timeout=5, headers=h2, verify=verifySSL)
|
||||
volapi_json = volapi.json()
|
||||
|
||||
if(bool(volapi_json)):
|
||||
for volume in volapi_json :
|
||||
#metricsDictionary["scratch_volume_provisioned_size_in_bytes{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"] = volume["Size"]["ProvisionedInBytes"]
|
||||
# Determine the key for a given VM, then see if the key is already in the dictionary, if it is add the next disk to the total. If not, create a new key.
|
||||
metrickey = "vm_journal_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"]
|
||||
|
||||
metrickey = "vm_journal_volume_count{ProtectedVm=\"" + volume['ProtectedVm']['Name'] + "\", ProtectedVmIdentifier=\"" + volume['ProtectedVm']['Identifier'] + "\", OwningVRA=\"" + volume['OwningVm']['Name'] + "\"}"
|
||||
if (metrickey in metricsDictionary):
|
||||
metricsDictionary[metrickey] = metricsDictionary[metrickey] + 1
|
||||
else:
|
||||
metricsDictionary[metrickey] = 1
|
||||
|
||||
|
||||
### VRA API
|
||||
uri = "https://" + zvm_url + ":" + zvm_port + "/v1/vras/"
|
||||
service = requests.get(url=uri, timeout=3, headers=h2, verify=verifySSL)
|
||||
|
||||
Reference in New Issue
Block a user