Fix Ceph plugins to suppport containerized collectd

- Install ceph-common package
- In collectd container mount
  1) /etc/ceph to /etc/ceph
  2) /var/run/ceph/ to /var/run/ceph/
- Fix collect_ceph_storage.py
Change-Id: Ifaf4537b86e7ad46da291920bba2933b04396ba9

Change-Id: I7f0bdd0446d1271bc2e10431a2974e0532612ea8
This commit is contained in:
Asma Syed Hameed 2021-11-16 11:02:27 +05:30
parent 65543d7fdc
commit 2170a2e31e
2 changed files with 16 additions and 2 deletions

View File

@ -60,6 +60,15 @@
version: master version: master
when: not (directory_exists.stat.isdir is defined and directory_exists.stat.isdir) when: not (directory_exists.stat.isdir is defined and directory_exists.stat.isdir)
# CephStorage OSD monitoring
# Only Monitors a single OSD on each CephStorage Node
- name: Get 1st OSD socket
shell: ls /var/run/ceph/ceph-osd.*.asok | head -n 1 | egrep -o '[0-9]+'
register: cephstorage_osd_socket
become: true
when: "('CephStorage' in group_names and ceph_storage_collectd_plugin)"
# End CephStorage OSD monitoring
- name: Create configuration directory - name: Create configuration directory
file: file:
path: "{{ browbeat_containers_path }}/collectd-openstack/config" path: "{{ browbeat_containers_path }}/collectd-openstack/config"
@ -153,6 +162,11 @@
-v /home/{{ host_remote_user }}/collectd_pipe:/collectd_pipe \ -v /home/{{ host_remote_user }}/collectd_pipe:/collectd_pipe \
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if config_type == 'controller' or config_type == 'cephstorage' %}
{% if ceph_controller_collectd_plugin or ceph_storage_collectd_plugin %}
-v /etc/ceph/:/etc/ceph/ -v /var/run/ceph/:/var/run/ceph/ \
{% endif %}
{% endif %}
collectd-openstack collectd-openstack
become: yes become: yes

View File

@ -203,7 +203,7 @@ class CollectdCephStorage(object):
json_data = json.loads(output) json_data = json.loads(output)
pgs = {} pgs = {}
for pg in json_data['pg_stats']: for pg in json_data['pg_map']['pg_stats']:
for state in pg['state'].split('+'): for state in pg['state'].split('+'):
if state not in pgs: if state not in pgs:
pgs[state] = 0 pgs[state] = 0
@ -213,7 +213,7 @@ class CollectdCephStorage(object):
self.dispatch_value( self.dispatch_value(
'pg', state, pgs[state], self.ceph_pg_stats_interval) 'pg', state, pgs[state], self.ceph_pg_stats_interval)
for osd in json_data['osd_stats']: for osd in json_data['pg_map']['osd_stats']:
osd_id = 'osd-{}'.format(osd['osd']) osd_id = 'osd-{}'.format(osd['osd'])
self.dispatch_value( self.dispatch_value(
osd_id, 'kb_used', osd['kb_used'], osd_id, 'kb_used', osd['kb_used'],