]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: include A/O start relative timestamp for iSCSI
authorJason Dillaman <dillaman@redhat.com>
Tue, 31 Oct 2017 14:41:36 +0000 (10:41 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 31 Oct 2017 15:11:30 +0000 (11:11 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/pybind/mgr/dashboard/rbd_iscsi.html
src/pybind/mgr/dashboard/rbd_iscsi.py

index b8e47fdb23488b4316c41c1debc982a857de5ac2..d49796cff79d5f06fa982eea8cfcf6df4c2d9a4e 100644 (file)
 
             console.log(content_data);
 
+            rivets.formatters.relative_date = function(date_str) {
+                if (!date_str) {
+                    return "unknown";
+                }
+                return moment(date_str * 1000).fromNow();
+            }
+
             rivets.bind($("div#content"), content_data);
             setTimeout(refresh, 30000);
 
@@ -85,6 +92,7 @@
                     <th>Image</th>
                     <th>Active/Optimized</th>
                     <th>Active/Non-Optimized</th>
+                    <th>A/O Since</th>
                 </tr>
                 </thead>
                 <tbody>
                         <td>{image.name}</td>
                         <td>{image.optimized_paths}</td>
                         <td>{image.non_optimized_paths}</td>
+                        <td>{image.optimized_since | relative_date}</td>
                     </tr>
                 </tbody>
             </table>
index d0de918dab1130f11404b6dd209054dd69994b83..007abd110442dd9576b54a5277def287b151e43d 100644 (file)
@@ -27,20 +27,33 @@ class DaemonsAndImages(RemoteViewCache):
                         }
                         daemons[server['hostname']] = daemon
 
-                    image_id = service['id'].split(':')[-1]
-                    image = images.get(image_id)
+                    service_id = service['id']
+                    device_id = service_id.split(':')[-1]
+                    image = images.get(device_id)
                     if image is None:
                         image = {
-                            'id': image_id,
+                            'device_id': device_id,
                             'pool_name': metadata['pool_name'],
                             'name': metadata['image_name'],
+                            'id': metadata.get('image_id', None),
                             'optimized_paths': [],
                             'non_optimized_paths': []
                         }
-                        images[image_id] = image
+                        images[device_id] = image
                     if status.get('lock_owner', 'false') == 'true':
                         daemon['optimized_paths'] += 1
                         image['optimized_paths'].append(server['hostname'])
+
+                        perf_key_prefix = "librbd-{id}-{pool}-{name}.".format(
+                            id=metadata.get('image_id', ''),
+                            pool=metadata['pool_name'],
+                            name=metadata['image_name'])
+                        perf_key = "{}lock_acquired_time".format(perf_key_prefix)
+                        lock_acquired_time = (self._module.get_counter(
+                          'tcmu-runner', service_id, perf_key)[perf_key] or
+                            [[0,0]])[-1][1] / 1000000000
+                        if lock_acquired_time > image.get('optimized_since', None):
+                            image['optimized_since'] = lock_acquired_time
                     else:
                         daemon['non_optimized_paths'] += 1
                         image['non_optimized_paths'].append(server['hostname'])