diff --git a/collectd-extensions/debian/deb_folder/rules b/collectd-extensions/debian/deb_folder/rules index 5230773..67ea7d9 100755 --- a/collectd-extensions/debian/deb_folder/rules +++ b/collectd-extensions/debian/deb_folder/rules @@ -11,6 +11,10 @@ export LOCAL_CONFIG_EXTENSIONS_DIR = $(ROOT)/opt/collectd/extensions/config dh $@ override_dh_install: + + # Adjustments in the configuration files for debian + sed -i '/Encoding "utf-8"/D' python_plugins.conf + install -m 755 -d $(ROOT)/etc install -m 755 -d $(LOCAL_UNIT_DIR) install -m 755 -d $(LOCAL_DEFAULT_PLUGIN_DIR) diff --git a/collectd-extensions/src/fm_notifier.py b/collectd-extensions/src/fm_notifier.py index 16644db..57045b9 100755 --- a/collectd-extensions/src/fm_notifier.py +++ b/collectd-extensions/src/fm_notifier.py @@ -87,6 +87,7 @@ import os import re import socket import collectd +import six from threading import RLock as Lock from oslo_utils import encodeutils from fm_api import constants as fm_constants @@ -1570,7 +1571,14 @@ def init_func(): # The path to where collectd is looking for its plugins is specified # at the end of the /etc/collectd.conf file. # Because so we search for the 'Include' label in reverse order. - for line in reversed(open("/etc/collectd.conf", 'r').readlines()): + # collectd.conf will be in different places based on OS family + if six.PY2: + # Centos + conf_dir = "/etc/collectd.conf" + else: + # Debian + conf_dir = "/etc/collectd/collectd.conf" + for line in reversed(open(conf_dir, 'r').readlines()): if line.startswith('Include'): plugin_path = line.split(' ')[1].strip("\n").strip('"') + '/' fmAlarmObject.plugin_path = plugin_path diff --git a/collectd-extensions/src/ntpq.py b/collectd-extensions/src/ntpq.py index 5ef55d7..3808820 100755 --- a/collectd-extensions/src/ntpq.py +++ b/collectd-extensions/src/ntpq.py @@ -63,6 +63,7 @@ import os import subprocess import uuid import collectd +import six from fm_api import constants as fm_constants from fm_api import fm_api import tsconfig.tsconfig as tsc @@ -709,7 +710,12 @@ def read_func(): return 0 # Do NTP Query - data = subprocess.check_output([PLUGIN_EXEC, PLUGIN_EXEC_OPTIONS]) + if six.PY2: + # Centos + data = subprocess.check_output([PLUGIN_EXEC, PLUGIN_EXEC_OPTIONS]) + else: + # Debian + data = subprocess.check_output([PLUGIN_EXEC, PLUGIN_EXEC_OPTIONS], encoding='utf-8') # Keep this FIT test code but make it commented out for security # diff --git a/collectd-extensions/src/ptp.py b/collectd-extensions/src/ptp.py index 467a9b1..b9d6dfc 100755 --- a/collectd-extensions/src/ptp.py +++ b/collectd-extensions/src/ptp.py @@ -36,6 +36,7 @@ import subprocess import tsconfig.tsconfig as tsc import plugin_common as pc import re +import six from fm_api import constants as fm_constants from fm_api import fm_api from glob import glob @@ -62,14 +63,27 @@ PLUGIN_TYPE = 'time_offset' PLUGIN_TYPE_INSTANCE = 'nsec' # Primary PTP service name -PLUGIN_SERVICE = 'ptp4l.service' +if six.PY2: + # Centos + PLUGIN_SERVICE = 'ptp4l.service' +else: + # Debian + PLUGIN_SERVICE = 'ptp4l@.service' # Plugin configuration file # # This plugin looks for the timestamping mode in the ptp4l config file. # time_stamping hardware # -PLUGIN_CONF_FILE = '/etc/ptp4l.conf' + +# ptp4l config file will be in different location based on OS family +if six.PY2: + # Centos + PLUGIN_CONF_FILE = '/etc/ptp4l.conf' +else: + # Debian + PLUGIN_CONF_FILE = '/etc/linuxptp/ptp4l.conf' + PLUGIN_CONF_TIMESTAMPING = 'time_stamping' @@ -1181,7 +1195,6 @@ def check_clock_class(instance): data = subprocess.check_output([PLUGIN_STATUS_QUERY_EXEC, '-f', conf_file, '-u', '-b', '0', 'GET GRANDMASTER_SETTINGS_NP']).decode() - # Save all parameters in an ordered dict m = OrderedDict() obj.resp = data.split('\n') diff --git a/collectd-extensions/src/service_res.py b/collectd-extensions/src/service_res.py index 978d517..e25f6d0 100644 --- a/collectd-extensions/src/service_res.py +++ b/collectd-extensions/src/service_res.py @@ -5,6 +5,7 @@ import collectd import os +import six import subprocess import plugin_common as pc from datetime import datetime @@ -154,7 +155,17 @@ def init_func(): def check_service_status(service): cmd = service["service_plugin_cmdline"] env = service["service_plugin_env"] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, shell=True) + if six.PY2: + # Centos + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, shell=True) + else: + # Debian + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, shell=True, + encoding='utf-8') proc.wait() new_status = (proc.communicate()[0] or "").strip()