diff --git a/haproxy/avalanche-healthcheck.sh b/haproxy/avalanche-healthcheck.sh new file mode 100644 index 00000000..211d2266 --- /dev/null +++ b/haproxy/avalanche-healthcheck.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# $1 = Virtual Service IP (VIP) +# $2 = Virtual Service Port (VPT) +# $3 = Real Server IP (RIP) +# $4 = Real Server Port (RPT) +# $5 = Check Source IP + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +VIP=$1 +VPT=$2 +RIP=$3 +RPT=$4 +# RPT=8545 + +# Run curl with appropriate options +curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/avalanche 2>/dev/null | jq '.result' -r | grep -q false +exit1=$? + +peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/avalanche 2>/dev/null | jq '.result' -r) + +# If any of the above tests failed, then exit 1. +if [[ "$exit1" -ne 0 ]]; then exit 1; fi +if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi +exit 0 diff --git a/haproxy/erigon-healthcheck.sh b/haproxy/erigon-healthcheck.sh new file mode 100644 index 00000000..22922204 --- /dev/null +++ b/haproxy/erigon-healthcheck.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# $1 = Virtual Service IP (VIP) +# $2 = Virtual Service Port (VPT) +# $3 = Real Server IP (RIP) +# $4 = Real Server Port (RPT) +# $5 = Check Source IP + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +VIP=$1 +VPT=$2 +RIP=$3 +RPT=$4 +# RPT=8545 + +# Run curl with appropriate options +curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/erigon 2>/dev/null | jq '.result' -r | grep -q false +exit1=$? + +peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/erigon 2>/dev/null | jq '.result' -r) + +# If any of the above tests failed, then exit 1. +if [[ "$exit1" -ne 0 ]]; then exit 1; fi +if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi +exit 0 diff --git a/haproxy/eth-healthcheck.sh b/haproxy/geth-healthcheck.sh similarity index 83% rename from haproxy/eth-healthcheck.sh rename to haproxy/geth-healthcheck.sh index e3413d66..08dcb292 100644 --- a/haproxy/eth-healthcheck.sh +++ b/haproxy/geth-healthcheck.sh @@ -14,10 +14,10 @@ RPT=$4 # RPT=8545 # Run curl with appropriate options -curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT 2>/dev/null | jq '.result' -r | grep -q false +curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/geth 2>/dev/null | jq '.result' -r | grep -q false exit1=$? -peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT 2>/dev/null | jq '.result' -r) +peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/geth 2>/dev/null | jq '.result' -r) # If any of the above tests failed, then exit 1. if [[ "$exit1" -ne 0 ]]; then exit 1; fi diff --git a/haproxy/rinkeby-healthcheck.sh b/haproxy/rinkeby-healthcheck.sh new file mode 100644 index 00000000..36154d02 --- /dev/null +++ b/haproxy/rinkeby-healthcheck.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# $1 = Virtual Service IP (VIP) +# $2 = Virtual Service Port (VPT) +# $3 = Real Server IP (RIP) +# $4 = Real Server Port (RPT) +# $5 = Check Source IP + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +VIP=$1 +VPT=$2 +RIP=$3 +RPT=$4 +# RPT=8545 + +# Run curl with appropriate options +curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/rinkeby 2>/dev/null | jq '.result' -r | grep -q false +exit1=$? + +peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/rinkeby 2>/dev/null | jq '.result' -r) + +# If any of the above tests failed, then exit 1. +if [[ "$exit1" -ne 0 ]]; then exit 1; fi +if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi +exit 0 diff --git a/haproxy/ropsten-healthcheck.sh b/haproxy/ropsten-healthcheck.sh new file mode 100644 index 00000000..14f10878 --- /dev/null +++ b/haproxy/ropsten-healthcheck.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# $1 = Virtual Service IP (VIP) +# $2 = Virtual Service Port (VPT) +# $3 = Real Server IP (RIP) +# $4 = Real Server Port (RPT) +# $5 = Check Source IP + +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +VIP=$1 +VPT=$2 +RIP=$3 +RPT=$4 +# RPT=8545 + +# Run curl with appropriate options +curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"eth_syncing","params": [],"id":1}' http://$RIP:$RPT/ropsten 2>/dev/null | jq '.result' -r | grep -q false +exit1=$? + +peers=$(curl -s -X POST -u ${AUTH_HTTP} -H "Content-Type: application/json" -m 2 -d '{"jsonrpc":"2.0","method":"net_peerCount","params": [],"id":1}' http://$RIP:$RPT/ropsten 2>/dev/null | jq '.result' -r) + +# If any of the above tests failed, then exit 1. +if [[ "$exit1" -ne 0 ]]; then exit 1; fi +if [[ `printf "%d" $peers` == "0" || `printf "%d" $peers` == "1" ]]; then exit 1; fi +exit 0