From: Paul Cuzner Date: Mon, 7 Aug 2017 00:20:10 +0000 (+1200) Subject: cephmetrics.py: updated to detect and collect stats for iSCSI gateways X-Git-Tag: v1.0~34^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3f3c7417a3dff607509f1c749dd8ef22140db36;p=cephmetrics.git cephmetrics.py: updated to detect and collect stats for iSCSI gateways The probe method now looks for the sysfs kernel entries that denote an iscsi gateway is running on the node. When this dir is found an instance of the iscsi collector (ISCSIGateway) is created and polled during every read callback. --- diff --git a/cephmetrics.py b/cephmetrics.py index bcd3737..1409100 100644 --- a/cephmetrics.py +++ b/cephmetrics.py @@ -7,6 +7,7 @@ import collectd from collectors.mon import Mon from collectors.rgw import RGW from collectors.osd import OSDs +from collectors.iscsi import ISCSIGateway from collectors.common import flatten_dict, get_hostname, freadlines __author__ = 'Paul Cuzner' @@ -25,6 +26,7 @@ class Ceph(object): self.mon = None self.rgw = None self.osd = None + self.iscsi = None def probe(self): """ @@ -55,11 +57,16 @@ class Ceph(object): if osd_socket_list or osds_mounted: self.osd = OSDs(self.cluster_name) - collectd.info("{}: Roles detected - mon:{} " - "osd:{} rgw:{}".format(__name__, - isinstance(self.mon, Mon), - isinstance(self.osd, OSDs), - isinstance(self.rgw, RGW))) + if os.path.exists('/sys/kernel/config/target/iscsi'): + self.iscsi = ISCSIGateway(self.cluster_name) + + collectd.info("{}: Roles detected - " + "mon:{} osd:{} rgw:{} " + "iscsi:{}".format(__name__, + isinstance(self.mon, Mon), + isinstance(self.osd, OSDs), + isinstance(self.rgw, RGW), + isinstance(self.iscsi, ISCSIGateway))) def write_stats(role_metrics, stats): @@ -144,11 +151,16 @@ def read_callback(): osd_node_stats = CEPH.osd.get_stats() write_stats(OSDs.all_metrics, osd_node_stats) + if CEPH.iscsi: + iscsi_stats = CEPH.iscsi.get_stats() + write_stats(ISCSIGateway.metrics, iscsi_stats) + + if __name__ == '__main__': # run interactively or maybe test the code - collectd.info("In main for some reason !") + pass else: