peers.py 文件源码

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

项目:ntpmon 作者: paulgear 项目源码 文件源码
def getmetrics(self, peers=None):
        """
        Return a set of metrics based on the data in peers.
        If peers is None, use self.peers.
        """
        if peers is None:
            peers = self.peers
        metrics = {}
        for t in NTPPeers.peertypes:
            # number of peers of this type
            metrics[t] = len(peers[t]['address'])

            # offset of peers of this type
            metrics[t + '-offset-mean'] = NTPPeers.getmean(peers[t]['offset'])
            metrics[t + '-offset-stdev'] = NTPPeers.getstdev(peers[t]['offset'], metrics[t + '-offset-mean'])
            metrics[t + '-offset-rms'] = NTPPeers.rms(peers[t]['offset'])

            # reachability of peers of this type
            metrics[t + '-reach-mean'] = NTPPeers.getmean(peers[t]['reach'])
            metrics[t + '-reach-stdev'] = NTPPeers.getstdev(peers[t]['reach'], metrics[t + '-reach-mean'])
            # The rms of reachability is not very useful, because it's always positive
            # (so it should be very close to the mean), but we include it for completeness.
            metrics[t + '-reach-rms'] = NTPPeers.rms(peers[t]['reach'])

        return metrics
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号