import threading
from collections import defaultdict, namedtuple
import rados
+import re
import time
PG_STATES = [
return ''
+ def _perfpath_to_path_labels(self, daemon, path):
+ label_names = ("ceph_daemon",)
+ labels = (daemon,)
+
+ if daemon.startswith('rbd-mirror.'):
+ match = re.match(
+ r'^rbd_mirror_([^/]+)/(?:(?:([^/]+)/)?)(.*)\.(replay(?:_bytes|_latency)?)$',
+ path
+ )
+ if match:
+ path = 'rbd_mirror_' + match.group(4)
+ pool = match.group(1)
+ namespace = match.group(2) or ''
+ image = match.group(3)
+ label_names += ('pool', 'namespace', 'image')
+ labels += (pool, namespace, image)
+
+ return path, label_names, labels,
+
def _perfvalue_to_value(self, stattype, value):
if stattype & self.PERFCOUNTER_TIME:
# Convert from ns to seconds
self.log.debug('ignoring %s, type %s' % (path, stattype))
continue
+ path, label_names, labels = self._perfpath_to_path_labels(
+ daemon, path)
+
# Get the value of the counter
value = self._perfvalue_to_value(
counter_info['type'], counter_info['value'])
stattype,
_path,
counter_info['description'] + ' Total',
- ("ceph_daemon",),
+ label_names,
)
- self.metrics[_path].set(value, (daemon,))
+ self.metrics[_path].set(value, labels)
_path = path + '_count'
if _path not in self.metrics:
'counter',
_path,
counter_info['description'] + ' Count',
- ("ceph_daemon",),
+ label_names,
)
- self.metrics[_path].set(counter_info['count'], (daemon,))
+ self.metrics[_path].set(counter_info['count'], labels,)
else:
if path not in self.metrics:
self.metrics[path] = Metric(
stattype,
path,
counter_info['description'],
- ("ceph_daemon",),
+ label_names,
)
- self.metrics[path].set(value, (daemon,))
+ self.metrics[path].set(value, labels)
self.get_rbd_stats()