Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failure when some node is unavailable #31

Merged
merged 1 commit into from
May 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/pve_exporter/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,23 @@ def collect(self): # pylint: disable=missing-docstring
}

for node in self._pve.nodes.get():
# Qemu
vmtype = 'qemu'
for vmdata in self._pve.nodes(node['node']).qemu.get():
config = self._pve.nodes(node['node']).qemu(vmdata['vmid']).config.get().items()
for key, metric_value in config:
label_values = ["%s/%s" % (vmtype, vmdata['vmid']), node['node'], vmtype]
if key in metrics:
metrics[key].add_metric(label_values, metric_value)
# LXC
vmtype = 'lxc'
for vmdata in self._pve.nodes(node['node']).lxc.get():
config = self._pve.nodes(node['node']).lxc(vmdata['vmid']).config.get().items()
for key, metric_value in config:
label_values = ["%s/%s" % (vmtype, vmdata['vmid']), node['node'], vmtype]
if key in metrics:
metrics[key].add_metric(label_values, metric_value)
if node["status"] == "online":
# Qemu
vmtype = 'qemu'
for vmdata in self._pve.nodes(node['node']).qemu.get():
config = self._pve.nodes(node['node']).qemu(vmdata['vmid']).config.get().items()
for key, metric_value in config:
label_values = ["%s/%s" % (vmtype, vmdata['vmid']), node['node'], vmtype]
if key in metrics:
metrics[key].add_metric(label_values, metric_value)
# LXC
vmtype = 'lxc'
for vmdata in self._pve.nodes(node['node']).lxc.get():
config = self._pve.nodes(node['node']).lxc(vmdata['vmid']).config.get().items()
for key, metric_value in config:
label_values = ["%s/%s" % (vmtype, vmdata['vmid']), node['node'], vmtype]
if key in metrics:
metrics[key].add_metric(label_values, metric_value)

return metrics.values()

Expand Down