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
This commit is contained in:
parent
fdc0d099fb
commit
f2e5263206
|
@ -46,6 +46,7 @@ Requires: fm-api
|
||||||
Requires: python3-httplib2
|
Requires: python3-httplib2
|
||||||
Requires: python3-influxdb
|
Requires: python3-influxdb
|
||||||
Requires: python3-oslo-concurrency
|
Requires: python3-oslo-concurrency
|
||||||
|
Requires: python3-oslo-utils
|
||||||
Requires: tsconfig
|
Requires: tsconfig
|
||||||
Requires: /bin/systemctl
|
Requires: /bin/systemctl
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ def get_cpuacct():
|
||||||
|
|
||||||
# Walk the first level cgroups and get cpuacct usage
|
# Walk the first level cgroups and get cpuacct usage
|
||||||
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
|
# (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:
|
for name in dir_list:
|
||||||
cg_path = '/'.join([CPUACCT, name])
|
cg_path = '/'.join([CPUACCT, name])
|
||||||
acct = get_cgroup_cpuacct(cg_path)
|
acct = get_cgroup_cpuacct(cg_path)
|
||||||
|
|
|
@ -88,6 +88,7 @@ import re
|
||||||
import socket
|
import socket
|
||||||
import collectd
|
import collectd
|
||||||
from threading import RLock as Lock
|
from threading import RLock as Lock
|
||||||
|
from oslo_utils import encodeutils
|
||||||
from fm_api import constants as fm_constants
|
from fm_api import constants as fm_constants
|
||||||
from fm_api import fm_api
|
from fm_api import fm_api
|
||||||
import tsconfig.tsconfig as tsc
|
import tsconfig.tsconfig as tsc
|
||||||
|
@ -387,7 +388,7 @@ class DegradeObject:
|
||||||
collectd.info("%s: %s" % (PLUGIN_DEGRADE, message))
|
collectd.info("%s: %s" % (PLUGIN_DEGRADE, message))
|
||||||
|
|
||||||
mtce_socket.settimeout(1.0)
|
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()
|
mtce_socket.close()
|
||||||
else:
|
else:
|
||||||
collectd.error("%s %s failed to open socket (%s)" %
|
collectd.error("%s %s failed to open socket (%s)" %
|
||||||
|
|
|
@ -261,7 +261,7 @@ def get_platform_memory():
|
||||||
|
|
||||||
# Walk the first level cgroups and get memory usage
|
# Walk the first level cgroups and get memory usage
|
||||||
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
|
# (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:
|
for name in dir_list:
|
||||||
cg_path = '/'.join([MEMCONT, name])
|
cg_path = '/'.join([MEMCONT, name])
|
||||||
m = get_cgroup_memory(cg_path)
|
m = get_cgroup_memory(cg_path)
|
||||||
|
|
|
@ -785,7 +785,7 @@ def range_to_list(csv_range=None):
|
||||||
|
|
||||||
if not csv_range:
|
if not csv_range:
|
||||||
return []
|
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(',')]
|
for r in csv_range.split(',')]
|
||||||
return [y for x in ranges for y in x]
|
return [y for x in ranges for y in x]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue