From 36db723d73a6c65fc73907793efeda5ce1e31ab8 Mon Sep 17 00:00:00 2001 From: znerol Date: Thu, 2 Jan 2025 17:04:36 +0100 Subject: [PATCH] Extend storage info (#312) --- README.rst | 9 ++++++--- src/pve_exporter/collector/cluster.py | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 078ad56..44cbc50 100644 --- a/README.rst +++ b/README.rst @@ -126,6 +126,9 @@ Here's an example of the metrics exported. # TYPE pve_up gauge pve_up{id="node/proxmox"} 1.0 pve_up{id="qemu/100"} 1.0 + pve_up{id="storage/proxmox/local"} 1.0 + pve_up{id="storage/proxmox/local-lvm"} 1.0 + pve_up{id="storage/proxmox/vms"} 1.0 # HELP pve_disk_size_bytes Storage size in bytes (for type 'storage'), root image size for VMs (for types 'qemu' and 'lxc'). # TYPE pve_disk_size_bytes gauge pve_disk_size_bytes{id="qemu/100"} 6.8719476736e+010 @@ -211,9 +214,9 @@ Here's an example of the metrics exported. pve_guest_info{id="qemu/100",name="samplevm1",node="proxmox",type="qemu",tags="tag1;tag2"} 1.0 # HELP pve_storage_info Storage info # TYPE pve_storage_info gauge - pve_storage_info{id="storage/proxmox/local",node="proxmox",storage="local"} 1.0 - pve_storage_info{id="storage/proxmox/local-lvm",node="proxmox",storage="local-lvm"} 1.0 - pve_storage_info{id="storage/proxmox/vms",node="proxmox",storage="vms"} 1.0 + pve_storage_info{content="iso,vztmpl,rootdir",id="storage/proxmox/local",node="proxmox",plugintype="dir",storage="local"} 1.0 + pve_storage_info{content="backup",id="storage/proxmox/local-lvm",node="proxmox",plugintype="lvm",storage="local-lvm"} 1.0 + pve_storage_info{content="images",id="storage/proxmox/vms",node="proxmox",plugintype="rbd",storage="vms"} 1.0 # HELP pve_node_info Node info # TYPE pve_node_info gauge pve_node_info{id="node/proxmox",level="",name="proxmox",nodeid="0"} 1.0 diff --git a/src/pve_exporter/collector/cluster.py b/src/pve_exporter/collector/cluster.py index e46ab34..d327ce5 100644 --- a/src/pve_exporter/collector/cluster.py +++ b/src/pve_exporter/collector/cluster.py @@ -43,6 +43,10 @@ def collect(self): # pylint: disable=missing-docstring label_values = [resource['id']] status_metrics.add_metric(label_values, resource['status'] == 'running') + for resource in self._pve.cluster.resources.get(type='storage'): + label_values = [resource['id']] + status_metrics.add_metric(label_values, resource['status'] == 'available') + yield status_metrics @@ -325,7 +329,7 @@ def collect(self): # pylint: disable=missing-docstring 'storage': GaugeMetricFamily( 'pve_storage_info', 'Storage info', - labels=['id', 'node', 'storage']), + labels=['id', 'node', 'storage', 'plugintype', 'content']), } info_lookup = { @@ -338,7 +342,7 @@ def collect(self): # pylint: disable=missing-docstring 'gauge': info_metrics['guest'], }, 'storage': { - 'labels': ['id', 'node', 'storage'], + 'labels': ['id', 'node', 'storage', 'plugintype', 'content'], 'gauge': info_metrics['storage'], }, }