Esempio n. 1
0
def check_nodes(environment, nodes_to_monitor):
    if len(nodes_to_monitor) == 0:
        return []
    try:
        environment_conf = json.load(
            open("default_configs/env_" + environment + ".json", 'r'))
        processed_ping_results = []
        processed_status_results = []
        if conf["check_ping"]:
            ping_result = ping_servers(nodes_to_monitor)
            processed_ping_results = process_ping_data(ping_result)
        if environment.startswith("lisk"):
            status_result = check_lisk_status(environment_conf,
                                              nodes_to_monitor, conf)
            processed_status_results = check_lisk_status_nodes(status_result)
        elif environment.startswith("qredit") or environment.startswith(
                "ark") or environment.startswith("compendia"):
            status_result = check_arkv2_status(environment_conf,
                                               nodes_to_monitor, conf)
            processed_status_results = check_arkv2_status_nodes(status_result)
        elif conf["check_block_height"] or conf["check_version"]:
            status_result = check_status(environment_conf, nodes_to_monitor,
                                         conf)
            processed_status_results = check_status_nodes(status_result)
        messages = []
        messages.extend(processed_ping_results)
        messages.extend(processed_status_results)
        return messages
    except Exception as e:
        __print('Unable to check nodes.')
        print(e)
Esempio n. 2
0
def get_data():
    hostnames = [
        '8.8.8.8',  # google dns 1
        'cn.pool.ntp.org',  # china ntp server
    ]
    timestamp = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
    results = ping.ping_servers(hostnames)
    return json.dump({
            'timestamp': timestamp,
            'results': results})
def run():
    hostnames = [
        '8.8.8.8',  # google dns 1
        'cn.pool.ntp.org',  # china ntp server
    ]
    timestamp = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
    results = ping.ping_servers(hostnames)
    with open('data/{}.json'.format(timestamp), 'w') as fd:
        json.dump({
            'timestamp': timestamp,
            'results': results,
        }, fd)