Skip to content

Commit

Permalink
fix(replication): Coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
znerol committed Apr 20, 2024
1 parent 0823231 commit 9098038
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pve_exporter/collector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def collect_pve(config, host, cluster, node, options: CollectorsOptions):
if cluster and options.cluster:
registry.register(ClusterInfoCollector(pve))
if cluster and options.version:
registry.register(VersionCollector(pve))
registry.register(VersionCollector(pve))
if node and options.config:
registry.register(NodeConfigCollector(pve))
if node and options.replication:
Expand Down
17 changes: 12 additions & 5 deletions src/pve_exporter/collector/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def collect(self): # pylint: disable=missing-docstring

class NodeReplicationCollector:
"""
Collects Proxmox VE Replication information directly from status, i.e. replication duration, last_sync, last_try, next_sync, fail_count.
Collects Proxmox VE Replication information directly from status, i.e. replication duration,
last_sync, last_try, next_sync, fail_count.
For manual test: "pvesh get /nodes/<node>/replication/<id>/status"
"""

Expand Down Expand Up @@ -106,15 +107,21 @@ def collect(self): # pylint: disable=missing-docstring
node = entry['name']
break

for vmdata in self._pve("nodes/{0}/replication/".format(node)).get():
for vmdata in self._pve(f"nodes/{node}/replication/").get():
# Add info metric
label_values = [str(vmdata['id']), str(vmdata['type']), f"node/{vmdata['source']}", f"node/{vmdata['target']}", f"{vmdata['vmtype']}/{vmdata['guest']}"]

label_values = [
str(vmdata['id']),
str(vmdata['type']),
f"node/{vmdata['source']}",
f"node/{vmdata['target']}",
f"{vmdata['vmtype']}/{vmdata['guest']}",
]
info_metrics['info'].add_metric(label_values, 1)

# Add metrics
label_values = [str(vmdata['id'])]
for key, metric_value in self._pve("nodes/{0}/replication/{1}/status".format(node,vmdata['id'])).get().items():
status = self._pve(f"nodes/{node}/replication/{vmdata['id']}/status").get().items()
for key, metric_value in status:
if key in metrics:
metrics[key].add_metric(label_values, metric_value)

Expand Down

0 comments on commit 9098038

Please sign in to comment.