]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
iscsi: trigger stats only when iscsi is active
authorPaul Cuzner <pcuzner@redhat.com>
Wed, 23 Aug 2017 02:54:15 +0000 (14:54 +1200)
committerPaul Cuzner <pcuzner@redhat.com>
Wed, 23 Aug 2017 02:54:15 +0000 (14:54 +1200)
look for the iscsi dir in sysfs to determine when to
send the iscsi stats. If the iscsi base dir is not there
the collector will just send the version of gwcli

collectors/iscsi.py

index 74d29cb61020045cd713305c509b2e8d26a0e52b..3c85a1e7b5a1f25b17aac8a8f85ea705b202d647 100644 (file)
@@ -104,7 +104,7 @@ class ISCSIGateway(BaseCollector):
         if 'rtslib_fb.root' not in sys.modules.keys():
 
             try:
-                import rtslib_fb.root as RTSRoot
+                from rtslib_fb.root import RTSRoot
             except ImportError:
                 raise
 
@@ -242,19 +242,28 @@ class ISCSIGateway(BaseCollector):
         start = time.time()
 
         # populate gateway instance with the latest configuration from rtslib
-        self.refresh()
-
-        # Overtime they'll be churn in client and disks so we need to drop
-        # any entries from prior runs that are no longer seen in the iscsi
-        # configuration with the prune method
-        self.prune()
+        stats = {}
+        if os.path.exists('/sys/kernel/config/target/iscsi'):
+            self.refresh()
+
+            # Overtime they'll be churn in client and disks so we need to drop
+            # any entries from prior runs that are no longer seen in the iscsi
+            # configuration with the prune method
+            self.prune()
+            stats = self.dump()
+        else:
+            msg = "iSCSI Gateway is not active on this host"
+            self.logger.warning(msg)
+            self.error = True
+            self.error_msgs = [msg]
+            stats = {"iscsi": {
+                               "ceph_version": self.version
+                              }
+                     }
 
         end = time.time()
 
         self.logger.info("LIO stats took {}s".format(end - start))
 
-        return self.dump()
+        return stats
 
-    @classmethod
-    def probe(cls):
-        return os.path.exists('/sys/kernel/config/target/iscsi')