@@ -100,6 +100,8 @@ def health_status_to_number(status: str) -> int:
100100RBD_MIRROR_METADATA = ('ceph_daemon' , 'id' , 'instance_id' , 'hostname' ,
101101 'ceph_version' )
102102
103+ RBD_IMAGE_METADATA = ('pool_id' , 'image_name' )
104+
103105DISK_OCCUPATION = ('ceph_daemon' , 'device' , 'db_device' ,
104106 'wal_device' , 'instance' , 'devices' , 'device_ids' )
105107
@@ -743,6 +745,13 @@ def _setup_static_metrics(self) -> Dict[str, Metric]:
743745 RBD_MIRROR_METADATA
744746 )
745747
748+ metrics ['rbd_image_metadata' ] = Metric (
749+ 'untyped' ,
750+ 'rbd_image_metadata' ,
751+ 'RBD Image Metadata' ,
752+ RBD_IMAGE_METADATA
753+ )
754+
746755 metrics ['pg_total' ] = Metric (
747756 'gauge' ,
748757 'pg_total' ,
@@ -1335,6 +1344,20 @@ def _get_pool_info(pool: Dict[str, Any]) -> Tuple[str, str]:
13351344 self .metrics ['rbd_mirror_metadata' ].set (
13361345 1 , rbd_mirror_metadata
13371346 )
1347+ try :
1348+ rbd = RBD ()
1349+ for pool in osd_map ['pools' ]:
1350+ pool_id = pool ['pool' ]
1351+ pool_name = pool ['pool_name' ]
1352+ if 'rbd' in pool .get ('application_metadata' , {}):
1353+ with self .rados .open_ioctx (pool_name ) as ioctx :
1354+ for image_meta in rbd .list2 (ioctx ):
1355+ image_name = image_meta ['name' ]
1356+ self .metrics ['rbd_image_metadata' ].set (
1357+ 1 , (str (pool_id ), image_name )
1358+ )
1359+ except Exception as e :
1360+ self .log .error (f"Failed to collect RBD image metadata: { e } " )
13381361
13391362 @profile_method ()
13401363 def get_num_objects (self ) -> None :
0 commit comments