def diff_record_or_warning(local_block_num, remote_block_num, other_api): diff = remote_block_num - local_block_num msg = ("local:%s,remote(%s):%s,diff:%s" % (local_block_num, other_api, remote_block_num, diff)) logger.info('%s, %s', hostname, msg) Metric.metric(Metric.height_diff, diff, version=local_server_version) if abs(diff) >= max_height_diff: log_and_notify(hostname, msg)
def extract_incoming_block(self, message): pattern = '.*?#(?P<block_header_num>\d+)\s+@\s+(?P<timestamp>{})\s+?signed by\s+?(?P<producer_name>.+?)\s.*' \ '\[trxs: (?P<trx_count>\d+), lib: (?P<last_irreversible_block_num>\d+), conf: (?P<confirm_count>\d+), latency: (?P<latency>.*) ms\]' \ .format(timestamp_pattern) if not re.match(pattern, message): return msg_dict = self.extract_dict(pattern, message) if msg_dict is None: return producer_name = msg_dict['producer_name'] trx_count = msg_dict['trx_count'] confirm_count = msg_dict['confirm_count'] latency = msg_dict['latency'] logger.info('%s %s %s %s', producer_name, trx_count, confirm_count, latency) Metric.metric(Metric.latency, latency, producer_name) Metric.metric(Metric.trxs, trx_count, producer_name)
def get_bp_account_info(): get_global_info() get_account_info() get_issue_token() get_rewards_info() Metric.metric(Metric.rank, rank) bp = 'bp: %s' % bp_name votes = 'votes: %s' % votes2eos(bp_vote_weight) rank_info = 'rank: %s' % rank vote_rate = 'rate: %s' % (bp_vote_weight / total_vote_weight) vote_weight = 'weight: %s' % int(bp_vote_weight) all_reward = vote_pay + block_pay reward_info = 'reward: %s' % (all_reward) claim_info = 'claim: %s' % last_claim_time_str un_pay = 'unpay: %s' % un_claim_pay if just_get_rewards is None: notify(bp, votes, rank_info, vote_rate, vote_weight, reward_info, claim_info, un_pay) else: print(all_reward)
def metric_collect(self, key, value): logger.info("%s %s %s" % (self.pid, key, value)) Metric.metric(key, value)