Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
znerol committed Dec 23, 2024
1 parent b1459dd commit 5e413e0
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/pve_exporter/collector/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ def collect(self): # pylint: disable=missing-docstring
labels=['id']),
}

ha_metric = GaugeMetricFamily(
'pve_ha_state',
'HA service status (for HA managed VMs).',
labels=['id', 'state'])

info_metrics = {
'guest': GaugeMetricFamily(
'pve_guest_info',
Expand All @@ -236,7 +241,7 @@ def collect(self): # pylint: disable=missing-docstring
labels=['id', 'node', 'storage']),
}

guest_states = [
ha_guest_states = [
'stopped',
'request_stop',
'request_start',
Expand All @@ -251,22 +256,11 @@ def collect(self): # pylint: disable=missing-docstring
]

ha_lookup = {
'lxc': guest_states,
'qemu': guest_states,
'node': [
'online',
'maintenance',
'unknown',
'fence',
'gone',
]
'lxc': ha_guest_states,
'qemu': ha_guest_states,
'node': ['online', 'maintenance', 'unknown', 'fence', 'gone']
}

ha_metric = GaugeMetricFamily(
'pve_ha_state',
'HA service status (for HA managed VMs).',
labels=['id', 'state'])

info_lookup = {
'lxc': {
'labels': ['id', 'node', 'name', 'type', 'template', 'tags'],
Expand All @@ -292,7 +286,7 @@ def collect(self): # pylint: disable=missing-docstring

if restype in ha_lookup:
for state in ha_lookup[restype]:
value = (resource.get('hastate', None) == state)
value = resource.get('hastate', None) == state
ha_metric.add_metric([resource['id'], state], value)

label_values = [resource['id']]
Expand Down

0 comments on commit 5e413e0

Please sign in to comment.