From 92e8ad402b8a8738e8294e0dc5081719068cefd5 Mon Sep 17 00:00:00 2001 From: Sanjay Chari Date: Wed, 23 Mar 2022 16:16:34 +0530 Subject: [PATCH] Fix iostat collectd plugin for OSP 16 The iostat collectd plugin does not work on OSP 16 due to changes in syntax between python2 and python3. This patch fixes the issue. The patch has been tested for iostat_undercloud_collectd_plugin, iostat_compute_collectd_plugin and iostat_controller_collectd_plugin, but should work for other roles too. Closes-Bug: 1954367 Change-Id: I6e5ec8bcefda4e6d7cc160150a8292ad030f43d7 --- browbeat-containers/collectd-openstack/Dockerfile | 1 + .../files/collectd_iostat_python.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/browbeat-containers/collectd-openstack/Dockerfile b/browbeat-containers/collectd-openstack/Dockerfile index fe50d2372..c5a345b32 100644 --- a/browbeat-containers/collectd-openstack/Dockerfile +++ b/browbeat-containers/collectd-openstack/Dockerfile @@ -29,6 +29,7 @@ ADD files/collectd_gnocchi_status.py /usr/local/bin/collectd_gnocchi_status.py ADD files/collectd_rabbitmq_monitoring.py /usr/local/bin/collectd_rabbitmq_monitoring.py ADD files/collectd_swift_stat.py /usr/local/bin/collectd_swift_stat.py ADD files/collectd_pacemaker_monitoring.py /usr/local/bin/collectd_pacemaker_monitoring.py +ADD files/collectd_iostat_python.py /usr/local/bin/collectd_iostat_python.py ADD files/ovs_flows.sh /usr/local/bin/ovs_flows.sh ADD files/ovn_monitoring.sh /usr/local/bin/ovn_monitoring.sh diff --git a/browbeat-containers/collectd-openstack/files/collectd_iostat_python.py b/browbeat-containers/collectd-openstack/files/collectd_iostat_python.py index fff8f49f7..2773365f4 100644 --- a/browbeat-containers/collectd-openstack/files/collectd_iostat_python.py +++ b/browbeat-containers/collectd-openstack/files/collectd_iostat_python.py @@ -96,7 +96,7 @@ class IOStat(object): See I{man iostat} for more details. """ dstats = {} - dsi = input.rfind('Device:') + dsi = input.rfind('Device') if dsi == -1: raise ParseError('Unknown input format: %r' % input) @@ -178,12 +178,12 @@ class IOStat(object): extdoptions.remove('N') dstats = self._run(options) extdstats = self._run(extdoptions) - dsd = self._get_childs_data(dstats) - edd = self._get_childs_data(extdstats) + dsd = self._get_childs_data(dstats).decode("utf-8") + edd = self._get_childs_data(extdstats).decode("utf-8") ds = self.parse_diskstats(dsd) eds = self.parse_diskstats(edd) - for dk, dv in ds.iteritems(): + for dk, dv in ds.items(): if dk in eds: ds[dk].update(eds[dk]) @@ -366,7 +366,7 @@ class IOMon(object): value *= self.names[name]['m'] else: val_type = 'gauge' - tbl = string.maketrans('/-%', '___') + tbl = str.maketrans('/-%', '___') type_instance = name.translate(tbl) value = ds[disk][name] self.dispatch_value( @@ -388,7 +388,7 @@ if __name__ == '__main__': for disk in ds: for metric in ds[disk]: - tbl = string.maketrans('/-%', '___') + tbl = str.maketrans('/-%', '___') metric_name = metric.translate(tbl) print("%s.%s:%s" % (disk, metric_name, ds[disk][metric]))