Exemplo n.º 1
0
async def collect_blockchain_metrics(manager: ManagerAPI, boot_info: BootInfo,
                                     event_bus: EndpointAPI,
                                     registry: HostMetricsRegistry,
                                     frequency_seconds: int) -> None:
    blockchain_head_gauge = registry.gauge(
        'trinity.blockchain/head/block.gauge')
    header_db_completeness = registry.gauge(
        'trinity.blockchain/completeness/header_db.gauge')
    block_db_completeness = registry.gauge(
        'trinity.blockchain/completeness/block_db.gauge')

    async for _ in trio_utils.every(frequency_seconds):
        current = read_blockchain_stats(boot_info, event_bus)
        blockchain_head_gauge.set_value(current.latest_block)
        header_db_completeness.set_value(current.header_db_completeness)
        block_db_completeness.set_value(current.block_db_completeness)
Exemplo n.º 2
0
async def collect_process_metrics(manager: ManagerAPI,
                                  registry: HostMetricsRegistry,
                                  frequency_seconds: int) -> None:

    previous: SystemStats = None

    cpu_sysload_gauge = registry.gauge('trinity.system/cpu/sysload.gauge')
    cpu_syswait_gauge = registry.gauge('trinity.system/cpu/syswait.gauge')

    disk_readdata_meter = registry.meter('trinity.system/disk/readdata.meter')
    disk_writedata_meter = registry.meter(
        'trinity.system/disk/writedata.meter')

    network_in_packets_meter = registry.meter(
        'trinity.network/in/packets/total.meter')
    network_out_packets_meter = registry.meter(
        'trinity.network/out/packets/total.meter')

    async for _ in trio_utils.every(frequency_seconds):
        current = SystemStats(
            cpu_stats=read_cpu_stats(),
            disk_stats=read_disk_stats(),
            network_stats=read_network_stats(),
        )

        if previous is not None:

            global_time = current.cpu_stats.global_time - previous.cpu_stats.global_time
            cpu_sysload_gauge.set_value(global_time / frequency_seconds)
            global_wait = current.cpu_stats.global_wait_io - previous.cpu_stats.global_wait_io
            cpu_syswait_gauge.set_value(global_wait / frequency_seconds)

            read_bytes = current.disk_stats.read_bytes - previous.disk_stats.read_bytes
            disk_readdata_meter.mark(read_bytes)

            write_bytes = current.disk_stats.write_bytes - previous.disk_stats.write_bytes
            disk_writedata_meter.mark(write_bytes)

            in_packets = current.network_stats.in_packets - previous.network_stats.in_packets
            network_in_packets_meter.mark(in_packets)
            out_packets = current.network_stats.out_packets - previous.network_stats.out_packets
            network_out_packets_meter.mark(out_packets)

        previous = current
Exemplo n.º 3
0
 def __init__(self, influx_server: str, influx_user: str,
              influx_password: str, influx_database: str, host: str,
              port: int, protocol: str, reporting_frequency: int):
     self._unreported_error: Exception = None
     self._last_time_reported: float = 0.0
     self._influx_server = influx_server
     self._reporting_frequency = reporting_frequency
     self._registry = HostMetricsRegistry(host)
     self._reporter = InfluxReporter(registry=self._registry,
                                     database=influx_database,
                                     username=influx_user,
                                     password=influx_password,
                                     protocol=protocol,
                                     port=port,
                                     server=influx_server)
Exemplo n.º 4
0
Arquivo: base.py Projeto: onyb/trinity
 def __init__(self,
              influx_server: str,
              influx_user: str,
              influx_password: str,
              influx_database: str,
              host: str,
              reporting_frequency: int = 10):
     self._influx_server = influx_server
     self._reporting_frequency = reporting_frequency
     self._registry = HostMetricsRegistry(host)
     self._reporter = InfluxReporter(registry=self._registry,
                                     protocol='https',
                                     port=443,
                                     database=influx_database,
                                     username=influx_user,
                                     password=influx_password,
                                     server=influx_server)