From: Paul Cuzner Date: Wed, 23 Aug 2017 02:54:15 +0000 (+1200) Subject: iscsi: trigger stats only when iscsi is active X-Git-Tag: v1.0~28^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9cd82488fe523b51fbb7e06d901356accf55b0b8;p=cephmetrics.git iscsi: trigger stats only when iscsi is active 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 --- diff --git a/collectors/iscsi.py b/collectors/iscsi.py index 74d29cb..3c85a1e 100644 --- a/collectors/iscsi.py +++ b/collectors/iscsi.py @@ -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')