From 9a00692cfa84a53205bc2054fc3c6e27a77abe90 Mon Sep 17 00:00:00 2001 From: Sanjay Chari Date: Wed, 20 Oct 2021 13:50:52 +0530 Subject: [PATCH] Fix in pacemaker monitoring Pacemaker monitoring was reporting resource failures as part of the total resource count for each individual resource. This patch fixes the issue. Change-Id: Idb4f39030d6423dc891301ac2b0facb30e01ed6a --- .../files/collectd_pacemaker_monitoring.py | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py b/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py index f13f3a143..462a752b2 100644 --- a/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py +++ b/browbeat-containers/collectd-openstack/files/collectd_pacemaker_monitoring.py @@ -72,32 +72,46 @@ def read_func(): elif "resource_total_count" in component: resource = component.split("_")[0] val = 0 - for line in latest_output: + # Flag to make sure that failures are not counted + # in resource total count. + is_failures_total = False + for line in latest_output[-1::-1]: + if "Failed" in line: + is_failures_total = True if (resource == "haproxy" or resource == "galera" or resource == "rabbitmq" or resource == "redis"): - if resource+"-bundle-" in line and "Guest" not in line: + if resource+"-bundle-" in line and "Guest" not in line and not is_failures_total: val += 1 if resource == "ovn": - if "ovn-dbs-bundle-" in line and "Guest" not in line: + if "ovn-dbs-bundle-" in line and "Guest" not in line and not is_failures_total: val += 1 if resource == "cinder": - if "openstack-cinder-volume-" in line and "Guest" not in line: + if "openstack-cinder-volume-" in line and "Guest" not in line and not is_failures_total: val += 1 + if is_failures_total and "Daemon Status" in line: + is_failures_total = False elif "resource_master_count" in component: resource = component.split("_")[0] val = 0 - for line in latest_output: + # Flag to make sure that failures are not counted + # in resource master count + is_failures_master = False + for line in latest_output[-1::-1]: + if "Failed" in line: + is_failures_master = True if (resource == "haproxy" or resource == "galera" or resource == "rabbitmq" or resource == "redis"): - if resource+"-bundle-" in line and "Master" in line: + if resource+"-bundle-" in line and "Master" in line and not is_failures_master: val += 1 if resource == "ovn": - if "ovn-dbs-bundle-" in line and "Master" in line: + if "ovn-dbs-bundle-" in line and "Master" in line and not is_failures_master: val += 1 if resource == "cinder": - if "openstack-cinder-volume-" in line and "Master" in line: + if "openstack-cinder-volume-" in line and "Master" in line and not is_failures_master: val += 1 + if is_failures_master and "Daemon Status" in line: + is_failures_master = False if "daemon_status" in component: daemon = component.split("_")[0]