Fix Ceph collectd plugin errors for OSP17

Ceph SocketPath has changed in OSP17. Now the path
includes fsid also.

Change-Id: I2afb25cf2ef971b668c9c92f9552f35863ee0eb3
This commit is contained in:
rajeshP524 2024-04-05 15:59:50 +05:30
parent e3c8ec2285
commit 8485df3535
8 changed files with 48 additions and 4 deletions

View File

@ -313,8 +313,11 @@ class CollectdCephStorage(object):
if check_output:
output = subprocess.check_output(command)
else:
stdin, stdout, stderr = os.popen3(' '.join(command))
output = stdout.read()
process = subprocess.Popen(' '.join(command), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode != 0:
raise RuntimeError("Error occurred: {}".format(stderr.decode('utf-8')))
output = stdout.decode('utf-8')
except Exception as exc:
collectd.error(
'collectd-ceph-storage: {} exception: {}'.format(command, exc))

View File

@ -342,6 +342,17 @@
when: "('CephStorage' in group_names and ceph_storage_collectd_plugin)"
# End CephStorage OSD monitoring
- name: Get Ceph cluster fsid
shell: ls /var/run/ceph/
register: ceph_cluster_fsid
become: true
when: "rhosp_version is version('17.0', '>=')"
delegate_to: controller-0
- name: set fact for ceph cluster id
set_fact:
ceph_cluster_fsid: "{{ ceph_cluster_fsid.stdout }}"
- name: Configure collectd.conf
template:
src: "{{config_type}}.collectd.conf.j2"

View File

@ -110,7 +110,11 @@ PreCacheChain "PreCache"
LongRunAvgLatency false
ConvertSpecialMetricTypes true
<Daemon "osd.{{inventory_hostname}}.{{cephstorage_osd_socket.stdout}}">
{% if rhosp_version | float >= 17.0 %}
SocketPath "/var/run/ceph/{{ceph_cluster_fsid}}/ceph-osd.{{cephstorage_osd_socket.stdout}}.asok"
{% else %}
SocketPath "/var/run/ceph/ceph-osd.{{cephstorage_osd_socket.stdout}}.asok"
{% endif %}
</Daemon>
</Plugin>

View File

@ -204,7 +204,11 @@ PreCacheChain "PreCache"
LongRunAvgLatency false
ConvertSpecialMetricTypes true
<Daemon "mon.{{inventory_hostname}}">
{% if rhosp_version | float >= 17.0 %}
SocketPath "/var/run/ceph/{{ceph_cluster_fsid}}/ceph-mon.{{inventory_hostname}}.asok"
{% else %}
SocketPath "/var/run/ceph/ceph-mon.{{inventory_hostname}}.asok"
{% endif %}
</Daemon>
</Plugin>

View File

@ -165,6 +165,17 @@
when: "('CephStorage' in group_names and ceph_storage_collectd_plugin) and (rhosp_version is version('17.0', '<'))"
# End CephStorage OSD monitoring
- name: Get Ceph cluster fsid
shell: ls /var/run/ceph/
register: ceph_cluster_fsid
become: true
when: "rhosp_version is version('17.0', '>=')"
delegate_to: controller-0
- name: set fact for ceph cluster id
set_fact:
ceph_cluster_fsid: "{{ ceph_cluster_fsid.stdout }}"
- name: Get 1st OSD socket
shell: cephadm shell -- ls /var/run/ceph/ | head -n 1 | egrep -o '[0-9]+'
register: cephstorage_osd_socket

View File

@ -109,7 +109,11 @@ PreCacheChain "PreCache"
LongRunAvgLatency false
ConvertSpecialMetricTypes true
<Daemon "osd.{{inventory_hostname}}.{{cephstorage_osd_socket.stdout}}">
{% if rhosp_version | float >= 17.0 %}
SocketPath "/var/run/ceph/{{ceph_cluster_fsid}}/ceph-osd.{{cephstorage_osd_socket.stdout}}.asok"
{% else %}
SocketPath "/var/run/ceph/ceph-osd.{{cephstorage_osd_socket.stdout}}.asok"
{% endif %}
</Daemon>
</Plugin>

View File

@ -121,7 +121,11 @@ PreCacheChain "PreCache"
LongRunAvgLatency false
ConvertSpecialMetricTypes true
<Daemon "mon.{{inventory_hostname}}">
{% if rhosp_version | float >= 17.0 %}
SocketPath "/var/run/ceph/{{ceph_cluster_fsid}}/ceph-mon.{{inventory_hostname}}.asok"
{% else %}
SocketPath "/var/run/ceph/ceph-mon.{{inventory_hostname}}.asok"
{% endif %}
</Daemon>
</Plugin>

View File

@ -313,8 +313,11 @@ class CollectdCephStorage(object):
if check_output:
output = subprocess.check_output(command)
else:
stdin, stdout, stderr = os.popen3(' '.join(command))
output = stdout.read()
process = subprocess.Popen(' '.join(command), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode != 0:
raise RuntimeError("Error occurred: {}".format(stderr.decode('utf-8')))
output = stdout.decode('utf-8')
except Exception as exc:
collectd.error(
'collectd-ceph-storage: {} exception: {}'.format(command, exc))