def __init__(self): self.cp = ConsolePrint() self.ss = SystemStats() self.ps = PlatformStats() self.psis = PlatformIntervalStats() self.ps.psis = self.psis self.previous_net_bytes_recv = 0 self.previous_net_bytes_sent = 0 self.clients = [] self.known_endpoint_urls = [] self.known_endpoint_names = [] self.stats_loop_count = 0 self.tm = TopologyManager(self.clients) self.spm = StatsPrintManager( self.ss, self.ps, self.tm.topology_stats, self.clients) self.sscm = SummaryStatsCsvManager(self.ss, self.ps) self.vscm = ValidatorStatsCsvManager(self.clients)
def __init__(self, endpointmanager): self.epm = endpointmanager self.cp = ConsolePrint() self.ss = SystemStats() self.ps = PlatformStats() self.psis = PlatformIntervalStats() self.ps.psis = self.psis self.previous_net_bytes_recv = 0 self.previous_net_bytes_sent = 0 self.clients = [] self.known_endpoint_names = [] self.endpoints = {} self.stats_loop_count = 0 self.tm = TopologyManager(self.clients) self.bm = BranchManager(self.epm, Agent(reactor)) stats_providers = [ self.ss, self.ps, self.tm.topology_stats, self.bm, self.clients ] self.spm = StatsPrintManager(*stats_providers) self.ssw = StatsSnapshotWriter(*stats_providers) self.sscm = SummaryStatsCsvManager(self.ss, self.ps) self.vscm = ValidatorStatsCsvManager(self.clients)
class ValidatorStatsManager(object): def __init__(self): self.vstats = ValidatorStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) self.val_name = None self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.val_stats = None self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats() def update_stats(self, json_stats, active, starttime, endtime): if active: self.val_stats = json_stats try: bytes_received_total, bytes_received_average = \ json_stats["packet"]["BytesReceived"] bytes_sent_total, bytes_sent_average = \ json_stats["packet"]["BytesSent"] self.vstats = ValStats( json_stats["ledger"]["BlocksClaimed"], json_stats["ledger"]["CommittedBlockCount"], json_stats["ledger"]["PendingBlockCount"], json_stats["ledger"].get("LocalMeanTime", 0.0), json_stats["ledger"].get("ExpectedExpirationTime", 0.0), json_stats["ledger"].get( "PreviousBlockID", 'broken'), json_stats["ledger"].get( "CommittedTxnCount", 0), json_stats["ledger"].get( "PendingTxnCount", 0), json_stats["packet"]["DroppedPackets"], json_stats["packet"]["DuplicatePackets"], json_stats["packet"]["AcksReceived"], json_stats["packet"]["MessagesHandled"], json_stats["packet"]["MessagesAcked"], bytes_received_total, bytes_received_average, bytes_sent_total, bytes_sent_average) except KeyError as ke: print "invalid key in vsm.update_stats()", ke self.active = True self.request_time = starttime self.response_time = endtime - starttime self.psis.calculate_interval_stats(self.val_stats) else: self.active = False self.request_time = starttime self.response_time = endtime - starttime self.txn_rate.calculate_txn_rate(self.vstats.blocks_committed, self.vstats.txns_committed)
def __init__(self): self.calculated_stats = named_tuple_init(ValStats, 0) self.val_stats = None # self.val_name = None # self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats()
def __init__(self): self.vstats = ValidatorStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) self.val_name = None self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.val_stats = None self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats()
class ValidatorStatsManager(object): def __init__(self): self.calculated_stats = named_tuple_init(ValStats, 0) self.val_stats = None # self.val_name = None # self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats() def update_stats(self, json_stats, active, starttime, endtime): if active: self.val_stats = json_stats.copy() # unpack stats that are delivered as lists of unnamed values bytes_received_total, bytes_received_average = \ json_stats["packet"]["BytesReceived"] bytes_sent_total, bytes_sent_average = \ json_stats["packet"]["BytesSent"] self.txn_rate.calculate_txn_rate( self.val_stats["journal"]["CommittedBlockCount"], self.val_stats["journal"].get("CommittedTxnCount", 0) ) self.calculated_stats = ValStats( bytes_received_total, bytes_received_average, bytes_sent_total, bytes_sent_average, self.txn_rate.avg_txn_rate, self.txn_rate.avg_block_time ) self.active = True self.request_time = starttime self.response_time = endtime - starttime self.psis.calculate_interval_stats(self.val_stats) else: self.active = False self.request_time = starttime self.response_time = endtime - starttime
def __init__(self, endpointmanager): self.epm = endpointmanager self.cp = ConsolePrint() self.ss = SystemStats() self.ps = PlatformStats() self.psis = PlatformIntervalStats() self.ps.psis = self.psis self.previous_net_bytes_recv = 0 self.previous_net_bytes_sent = 0 self.clients = [] self.known_endpoint_names = [] self.endpoints = {} self.stats_loop_count = 0 self.tm = TopologyManager(self.clients) self.bm = BranchManager(self.epm, Agent(reactor)) stats_providers = [self.ss, self.ps, self.tm.topology_stats, self.bm, self.clients] self.spm = StatsPrintManager(*stats_providers) self.ssw = StatsSnapshotWriter(*stats_providers) self.sscm = SummaryStatsCsvManager(self.ss, self.ps) self.vscm = ValidatorStatsCsvManager(self.clients)
class ValidatorStatsManager(object): def __init__(self): self.calculated_stats = named_tuple_init(ValStats, 0) self.val_stats = None # self.val_name = None # self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats() def update_stats(self, json_stats, active, starttime, endtime): if active: self.val_stats = json_stats.copy() # unpack stats that are delivered as lists of unnamed values bytes_received_total, bytes_received_average = \ json_stats["packet"]["BytesReceived"] bytes_sent_total, bytes_sent_average = \ json_stats["packet"]["BytesSent"] self.txn_rate.calculate_txn_rate( self.val_stats["journal"]["CommittedBlockCount"], self.val_stats["journal"].get("CommittedTxnCount", 0)) self.calculated_stats = ValStats(bytes_received_total, bytes_received_average, bytes_sent_total, bytes_sent_average, self.txn_rate.avg_txn_rate, self.txn_rate.avg_block_time) self.active = True self.request_time = starttime self.response_time = endtime - starttime self.psis.calculate_interval_stats(self.val_stats) else: self.active = False self.request_time = starttime self.response_time = endtime - starttime
class StatsManager(object): def __init__(self): self.cp = ConsolePrint() self.ss = SystemStats() self.ps = PlatformStats() self.psis = PlatformIntervalStats() self.ps.psis = self.psis self.previous_net_bytes_recv = 0 self.previous_net_bytes_sent = 0 self.clients = [] self.known_endpoint_urls = [] self.known_endpoint_names = [] self.stats_loop_count = 0 self.tm = TopologyManager(self.clients) self.spm = StatsPrintManager( self.ss, self.ps, self.tm.topology_stats, self.clients) self.sscm = SummaryStatsCsvManager(self.ss, self.ps) self.vscm = ValidatorStatsCsvManager(self.clients) def initialize_client_list(self, endpoints): # add validator stats client for each endpoint for val_num, endpoint in enumerate(endpoints.values()): url = 'http://{0}:{1}'.format( endpoint["Host"], endpoint["HttpPort"]) try: c = StatsClient(val_num, url) c.name = endpoint["Name"] self.known_endpoint_names.append(endpoint["Name"]) except: e = sys.exc_info()[0] print ("error creating stats clients: ", e) self.clients.append(c) def update_client_list(self, endpoints): # add validator stats client for each endpoint name for val_num, endpoint in enumerate(endpoints.values()): if endpoint["Name"] not in self.known_endpoint_names: val_num = len(self.known_endpoint_names) url = 'http://{0}:{1}'.format( endpoint["Host"], endpoint["HttpPort"]) c = StatsClient(val_num, url) c.name = endpoint["Name"] self.clients.append(c) self.known_endpoint_names.append(endpoint["Name"]) def stats_loop(self): self.process_stats(self.clients) self.print_stats() self.csv_write() for c in self.clients: c.stats_request() self.stats_loop_count += 1 return def stats_loop_done(self, result): reactor.stop() def stats_loop_error(self, failure): self.cp.cpstop() print failure reactor.stop() def process_stats(self, statsclients): self.ss.known_validators = len(statsclients) self.ss.active_validators = 0 self.ss.collect_stats(statsclients) self.ss.calculate_stats() self.ps.get_stats() psr = {"platform": self.ps.get_data_as_dict()} self.psis.calculate_interval_stats(psr) self.tm.update_topology() def print_stats(self): self.spm.print_stats() def csv_init(self, enable_summary, enable_validator): if enable_summary is True: self.sscm.initialize() if enable_validator is True: self.vscm.initialize() def csv_write(self): self.sscm.write_stats() self.vscm.write_stats() def csv_stop(self): self.sscm.stop() self.vscm.stop() def stats_stop(self): print "StatsManager is stopping" self.cp.cpstop() self.csv_stop()
class StatsManager(object): def __init__(self): self.cp = ConsolePrint() self.ss = SystemStats() self.ps = PlatformStats() self.psis = PlatformIntervalStats() self.ps.psis = self.psis self.previous_net_bytes_recv = 0 self.previous_net_bytes_sent = 0 self.clients = [] self.known_endpoint_urls = [] self.known_endpoint_names = [] self.stats_loop_count = 0 self.spm = StatsPrintManager(self.ss, self.ps, self.clients) self.sscm = SummaryStatsCsvManager(self.ss, self.ps) self.vscm = ValidatorStatsCsvManager(self.clients) def initialize_client_list(self, endpoints): # add validator stats client for each endpoint for val_num, endpoint in enumerate(endpoints.values()): url = 'http://{0}:{1}'.format( endpoint["Host"], endpoint["HttpPort"]) try: c = StatsClient(val_num, url) c.name = endpoint["Name"] self.known_endpoint_names.append(endpoint["Name"]) except: e = sys.exc_info()[0] print ("error creating stats clients: ", e) self.clients.append(c) def update_client_list(self, endpoints): # add validator stats client for each endpoint name for val_num, endpoint in enumerate(endpoints.values()): if endpoint["Name"] not in self.known_endpoint_names: val_num = len(self.known_endpoint_names) url = 'http://{0}:{1}'.format( endpoint["Host"], endpoint["HttpPort"]) c = StatsClient(val_num, url) c.name = endpoint["Name"] self.clients.append(c) self.known_endpoint_names.append(endpoint["Name"]) def stats_loop(self): self.process_stats(self.clients) self.print_stats() self.csv_write() for c in self.clients: c.stats_request() self.stats_loop_count += 1 return def stats_loop_done(self, result): reactor.stop() def stats_loop_failed(self, failure): print failure.getBriefTraceback() reactor.stop() def process_stats(self, statsclients): self.ss.known_validators = len(statsclients) self.ss.active_validators = 0 self.ss.collect_stats(statsclients) self.ss.calculate_stats() self.ps.get_stats() psr = {"platform": self.ps.get_data_as_dict()} self.psis.calculate_interval_stats(psr) def print_stats(self): self.spm.print_stats() def csv_init(self, enable_summary, enable_validator): if enable_summary is True: self.sscm.initialize() if enable_validator is True: self.vscm.initialize() def csv_write(self): self.sscm.write_stats() self.vscm.write_stats() def csv_stop(self): self.sscm.stop() self.vscm.stop() def stats_stop(self): print "StatsManager is stopping" self.cp.cpstop() self.csv_stop()
class ValidatorStatsManager(object): def __init__(self): self.vstats = ValidatorStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) self.val_name = None self.val_url = None self.active = False self.request_time = 0.0 self.response_time = 0.0 self.val_stats = None self.txn_rate = TransactionRate() self.psis = PlatformIntervalStats() def update_stats(self, json_stats, active, starttime, endtime): if active: self.val_stats = json_stats try: bytes_received_total, bytes_received_average = \ json_stats["packet"]["BytesReceived"] bytes_sent_total, bytes_sent_average = \ json_stats["packet"]["BytesSent"] self.vstats = ValStats( json_stats["ledger"]["BlocksClaimed"], json_stats["ledger"]["CommittedBlockCount"], json_stats["ledger"]["PendingBlockCount"], json_stats["ledger"].get("LocalMeanTime", 0.0), json_stats["ledger"].get("ExpectedExpirationTime", 0.0), json_stats["ledger"].get("PreviousBlockID", 'broken'), json_stats["ledger"].get("CommittedTxnCount", 0), json_stats["ledger"].get("PendingTxnCount", 0), json_stats["packet"]["DroppedPackets"], json_stats["packet"]["DuplicatePackets"], json_stats["packet"]["AcksReceived"], json_stats["packet"]["MessagesHandled"], json_stats["packet"]["MessagesAcked"], bytes_received_total, bytes_received_average, bytes_sent_total, bytes_sent_average ) except KeyError as ke: print "invalid key in vsm.update_stats()", ke self.active = True self.request_time = starttime self.response_time = endtime - starttime self.psis.calculate_interval_stats(self.val_stats) else: self.active = False self.request_time = starttime self.response_time = endtime - starttime self.txn_rate.calculate_txn_rate( self.vstats.blocks_committed, self.vstats.txns_committed )