tendrl_gluster_brick_disk_stats.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:node-agent 作者: Tendrl 项目源码 文件源码
def get_metrics(self):
        self.initial_io_stats = psutil.disk_io_counters(perdisk=True)
        curr_host_name = socket.gethostbyname(
            self.CONFIG['peer_name']
        )
        time.sleep(self.STAT_INTERVAL_FOR_PER_SEC_COUNTER)
        self.current_io_stats = psutil.disk_io_counters(perdisk=True)
        threads = []
        for volume in self.CLUSTER_TOPOLOGY.get('volumes', []):
            for sub_volume_index, sub_volume_bricks in volume.get(
                'bricks',
                []
            ).iteritems():
                for brick in sub_volume_bricks:
                    brick_hostname = brick['hostname']
                    if (
                        brick_hostname == curr_host_name or
                        brick_hostname == self.CONFIG['peer_name']
                    ):
                        thread = threading.Thread(
                            target=self.populate_disk_details,
                            args=(
                                volume['name'],
                                brick['hostname'],
                                brick['path'],
                            )
                        )
                        thread.start()
                        threads.append(
                            thread
                        )
        for thread in threads:
            thread.join(1)
        for thread in threads:
            del thread
        return self.brick_details
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号