def notify_exchange_error(exchange, exception):
    try:
        send_slack_notification(
            message="Something wrong or mismatching in {}'s response -> {}".
            format(exchange, exception))
    except Exception:
        pass
def notify_explorer_error(identifier, exception_string):
    send_slack_notification(
        message="Exception occured in {} in blockchain_explorers_health_check.py file. Exception in {}".format(identifier, exception_string))
            zcha_block["bits"],
            zcha_block["chainWork"],
            zcha_block["prevHash"],
            zcha_transaction_hashes
            )
        if zcha_block_fields == zcashd_block_fields and zcha_block_height_not_correct == False:
            set_state = '1'
        else:
            set_state = '0'
        ZCHA_LAST_BLOCK_CHECK_PORT.state(set_state)

    except:
        ZCHA_BLOCK_HEIGHT_PORT.state('0')
        ZCHA_LAST_BLOCK_CHECK_PORT.state('0')
        if(zcha_block_response == None):
            send_slack_notification(message="zcha_block_response is empty")
        else:
            exception_string = print_exception()
            notify_explorer_error("ZCHA", str(exception_string))
    
    #ZCASHNETWORKINFO
    zcashnetworkinfo_block_height_not_correct = False
    zcashnetworkinfo_block_response = zcashnetworkinfo_block = None
    try:
        zcashnetworkinfo_block_response = requests.get(url=ZCASHNETWORKINFO_BLOCK_URL + zcashd_block_fields[0], timeout=30)
        if zcashnetworkinfo_block_response.status_code != 200:
            time.sleep(5)
            zcashnetworkinfo_block_response = requests.get(url=ZCASHNETWORKINFO_BLOCK_URL+ zcashd_block_fields[0], timeout=15)
        zcashnetworkinfo_block = zcashnetworkinfo_block_response.json()
        if zcashd_height == zcashnetworkinfo_block["height"]:
            set_state = '1'
コード例 #4
0
def notify_metric_error(identifier, exception_string):
    send_slack_notification(
        message="Exception occured in {} in metrics.py Exception in {}".format(
            identifier, exception_string))
コード例 #5
0
            universal_newlines=True,
            stderr=subprocess.PIPE)
    except:
        exception_string = print_exception()
        notify_metric_error("ZCASHD", str(exception_string))
        pass

    try:
        zcashd_blockchain_info_data = json.loads(
            (zcashd_blockchain_info.stdout).strip())
        if zcashd_blockchain_info_data["valuePools"][0]["monitored"] == True:
            sprout_value_pool = float(
                zcashd_blockchain_info_data["valuePools"][0]["chainValue"])
            SPROUT_VALUE_POOL_GAUGE.set(sprout_value_pool)
        else:
            send_slack_notification("zcashd node reindex required")
        if zcashd_blockchain_info_data["valuePools"][1]["monitored"] == True:
            sapling_value_pool = float(
                zcashd_blockchain_info_data["valuePools"][1]["chainValue"])
            SAPLING_VALUE_POOL_GAUGE.set(sapling_value_pool)
        else:
            send_slack_notification("zcashd node reindex required")
    except:
        exception_string = print_exception()
        notify_metric_error("value pool metric", str(exception_string))

    try:
        zcash_difficulty = float(zcashd_blockchain_info_data["difficulty"])
        ZCASH_DIFFICULTY_GAUGE.set(zcash_difficulty)
    except:
        exception_string = print_exception()
def notify_driver_health_check_issue(exception):
    try:
        send_slack_notification(message="Some issue in driver_health_check!")
        send_slack_notification(message=str(exception))
    except Exception:
        pass
        else:
            set_state = '1'
        EXMO_TRANSACTION_VOLUME_BTC_PORT.state(set_state)
        if exmo_usd_spot_price == 0:
            set_state = '0'
        else:
            set_state = '1'
        EXMO_SPOT_PRICE_USD_PORT.state(set_state)
        if exmo_btc_spot_price == 0:
            set_state = '0'
        else:
            set_state = '1'
        EXMO_SPOT_PRICE_BTC_PORT.state(set_state)
    except Exception as e:
        if exmo_response is None:
            send_slack_notification(message="Exmo response is None!")
        else:
            notify_exchange_error("Exmo", str(e))

    # Bittrex
    try:
        bittrex_spot_price_zec_btc_data = bittrex_spot_price_zec_btc_response.json(
        )
        bittrex_btc_spot_price = float(
            bittrex_spot_price_zec_btc_data['result']['Last'])
        bittrex_spot_price_zec_usd_data = bittrex_spot_price_zec_usd_response.json(
        )
        bittrex_usd_spot_price = float(
            bittrex_spot_price_zec_usd_data['result']['Last'])
        bittrex_transaction_volume_data = bittrex_transaction_volume_response.json(
        )