Browse Source

Fix startup issues for collectd.

- Use encodeutils from olso library to handle string encodings.
 - Expand the generator into a list.
 - Use python3 iterator __next__().

Note: there needs to be a separate task to remove the Encoding parameter from python_plugins.conf which can be cherry-picked only for python3 deployments.

Story: 2008454
Task: 42647
Depends-On: Iaa7bd0cadd3b1d097b276dcc37ebceaeb208a6a5

Signed-off-by: Andrei Grosu <andrei.grosu@windriver.com>
Change-Id: I58cd4829806e98b1e15471ce97a7c7ba6a2fe135
(cherry picked from commit f2e5263206)
changes/19/802319/2
Andrei Grosu 3 months ago
committed by Charles Short
parent
commit
aa8665cebf
  1. 1
      collectd-extensions/centos/collectd-extensions.spec
  2. 2
      collectd-extensions/src/cpu.py
  3. 3
      collectd-extensions/src/fm_notifier.py
  4. 2
      collectd-extensions/src/memory.py
  5. 2
      collectd-extensions/src/plugin_common.py

1
collectd-extensions/centos/collectd-extensions.spec

@ -45,6 +45,7 @@ Requires: collectd-python
Requires: fm-api
Requires: python-httplib2
Requires: python-oslo-concurrency
Requires: python-oslo-utils
Requires: tsconfig
Requires: /bin/systemctl

2
collectd-extensions/src/cpu.py

@ -194,7 +194,7 @@ def get_cpuacct():
# Walk the first level cgroups and get cpuacct usage
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
dir_list = os.walk(CPUACCT).next()[1]
dir_list = next(os.walk(CPUACCT))[1]
for name in dir_list:
cg_path = '/'.join([CPUACCT, name])
acct = get_cgroup_cpuacct(cg_path)

3
collectd-extensions/src/fm_notifier.py

@ -88,6 +88,7 @@ import re
import socket
import collectd
from threading import RLock as Lock
from oslo_utils import encodeutils
from fm_api import constants as fm_constants
from fm_api import fm_api
import tsconfig.tsconfig as tsc
@ -380,7 +381,7 @@ class DegradeObject:
collectd.info("%s: %s" % (PLUGIN_DEGRADE, message))
mtce_socket.settimeout(1.0)
mtce_socket.sendto(message, (self.addr, self.port))
mtce_socket.sendto(encodeutils.safe_encode(message), (self.addr, self.port))
mtce_socket.close()
else:
collectd.error("%s %s failed to open socket (%s)" %

2
collectd-extensions/src/memory.py

@ -261,7 +261,7 @@ def get_platform_memory():
# Walk the first level cgroups and get memory usage
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
dir_list = os.walk(MEMCONT).next()[1]
dir_list = next(os.walk(MEMCONT))[1]
for name in dir_list:
cg_path = '/'.join([MEMCONT, name])
m = get_cgroup_memory(cg_path)

2
collectd-extensions/src/plugin_common.py

@ -785,7 +785,7 @@ def range_to_list(csv_range=None):
if not csv_range:
return []
ranges = [(lambda L: range(L[0], L[-1] + 1))(map(int, r.split('-')))
ranges = [(lambda L: range(L[0], L[-1] + 1))(list(map(int, r.split('-'))))
for r in csv_range.split(',')]
return [y for x in ranges for y in x]

Loading…
Cancel
Save