From b9495f44c1a0f83124082f63027d899ce29e07fe Mon Sep 17 00:00:00 2001 From: wgebis <32294473+wgebis@users.noreply.github.com> Date: Tue, 13 Mar 2018 22:37:06 +0100 Subject: [PATCH 1/2] Update script This simple modification avoids error during starting daemon before crm_mon will be accessible. --- prometheus-pacemaker-exporter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prometheus-pacemaker-exporter.py b/prometheus-pacemaker-exporter.py index d563988..d4dc7b8 100755 --- a/prometheus-pacemaker-exporter.py +++ b/prometheus-pacemaker-exporter.py @@ -48,7 +48,8 @@ def collect(self): value=p_time(summary.find('last_change').attrib['time'])) yield GaugeMetricFamily('pacemaker_dc_present', 'Whether the cluster has an active DC', value=p_bool(summary.find('current_dc').attrib['present'])) - yield GaugeMetricFamily('pacemaker_dc_with_quorum', 'Whether the cluster has quorum', + if summary.find('current_dc').attrib['present'] == 'true': + yield GaugeMetricFamily('pacemaker_dc_with_quorum', 'Whether the cluster has quorum', value=p_bool(summary.find('current_dc').attrib['with_quorum'])) yield GaugeMetricFamily('pacemaker_nodes_configured', 'Number of configured nodes', value=int(summary.find('nodes_configured').attrib['number'])) From e763a13b8dac560f4992172c49ce57b0b140f4d5 Mon Sep 17 00:00:00 2001 From: wgebis <32294473+wgebis@users.noreply.github.com> Date: Tue, 13 Mar 2018 23:17:28 +0100 Subject: [PATCH 2/2] Support for printing group resources --- prometheus-pacemaker-exporter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prometheus-pacemaker-exporter.py b/prometheus-pacemaker-exporter.py index d4dc7b8..fc976c4 100755 --- a/prometheus-pacemaker-exporter.py +++ b/prometheus-pacemaker-exporter.py @@ -110,6 +110,9 @@ def collect(self): elif node.tag == 'clone': for i, resource in enumerate(node.findall('resource')): resource_elements.append((p_bool(node.attrib['unique']), str(i), resource)) + elif node.tag == 'group': + for i, resource in enumerate(node.findall('resource')): + resource_elements.append((True, str(i), resource)) resource_metrics = { 'active': (p_bool, RGauge('resource_active', 'Resource is active')),