diff --git a/README.md b/README.md index cc2908d..80cf2ae 100644 --- a/README.md +++ b/README.md @@ -167,12 +167,12 @@ This script verifies connectivity to a Zeebe Gateway instance using HTTP/2 and g ##### Usage: ```bash -Usage: ./checks/zeebe/connectivity.sh [-h] [-H ZEEBE_HOST] [-p ZEEBE_VERSION] [-f PROTO_FILE] [-k] [-r CACERT] [-j CLIENTCERT] +Usage: ./checks/zeebe/connectivity.sh [-h] [-H ZEEBE_ADDRESS] [-p ZEEBE_VERSION] [-f PROTO_FILE] [-k] [-r CACERT] [-j CLIENTCERT] [-a ZEEBE_AUTHORIZATION_SERVER_URL] [-i ZEEBE_CLIENT_ID] [-s ZEEBE_CLIENT_SECRET] [-u ZEEBE_TOKEN_AUDIENCE] [-q API_PROTOCOL] Options: -h Display this help message - -H ZEEBE_HOST Specify the Zeebe host with the port (e.g., zeebe.c8.camunda.example.com:443) + -H ZEEBE_ADDRESS Specify the Zeebe address and optional port (e.g., zeebe.c8.camunda.example.com:443) -p ZEEBE_VERSION Specify the Zeebe version (default is the latest version: 8.6.5) -f PROTO_FILE Specify the path to the gateway.proto file or leave empty to download it (default behavior is to download the proto file) -k Skip TLS verification (insecure mode) diff --git a/checks/zeebe/connectivity.sh b/checks/zeebe/connectivity.sh index fa356fb..a657dd4 100755 --- a/checks/zeebe/connectivity.sh +++ b/checks/zeebe/connectivity.sh @@ -8,7 +8,6 @@ DIR_NAME=$(dirname "$0") LVL_1_SCRIPT_NAME="$DIR_NAME/$SCRIPT_NAME" # Define default variables -ZEEBE_HOST="${ZEEBE_HOST:-""}" PROTO_FILE="${PROTO_FILE:-""}" SKIP_TLS_VERIFICATION="" EXTRA_FLAGS_CURL="" @@ -24,18 +23,20 @@ ZEEBE_TOKEN_AUDIENCE="${ZEEBE_TOKEN_AUDIENCE:-""}" ZEEBE_TOKEN_SCOPE="${ZEEBE_TOKEN_SCOPE:-"camunda-identity"}" API_PROTOCOL="${API_PROTOCOL:-"grpc"}" +ZEEBE_ADDRESS="${ZEEBE_ADDRESS:-""}" + # renovate: datasource=github-releases depName=camunda/zeebe ZEEBE_DEFAULT_VERSION="8.6.6" ZEEBE_VERSION="${ZEEBE_VERSION:-$ZEEBE_DEFAULT_VERSION}" # Function to display script usage usage() { - echo "Usage: $0 [-h] [-H ZEEBE_HOST] [-p ZEEBE_VERSION] [-f PROTO_FILE] [-k] [-r CACERT] [-j CLIENTCERT]" + echo "Usage: $0 [-h] [-H ZEEBE_ADDRESS] [-p ZEEBE_VERSION] [-f PROTO_FILE] [-k] [-r CACERT] [-j CLIENTCERT]" echo " [-a ZEEBE_AUTHORIZATION_SERVER_URL] [-i ZEEBE_CLIENT_ID] [-s ZEEBE_CLIENT_SECRET]" echo " [-u ZEEBE_TOKEN_AUDIENCE] [-q API_PROTOCOL]" echo "Options:" echo " -h Display this help message" - echo " -H ZEEBE_HOST Specify the Zeebe host with the port (e.g., zeebe.c8.camunda.example.com:443)" + echo " -H ZEEBE_ADDRESS Specify the Zeebe address and optional port (e.g., zeebe.c8.camunda.example.com:443)" echo " -p ZEEBE_VERSION Specify the Zeebe version (default is the latest version: $ZEEBE_VERSION)" echo " -f PROTO_FILE Specify the path to the gateway.proto file or leave empty to download it (default behavior is to download the proto file)" echo " -k Skip TLS verification (insecure mode)" @@ -56,7 +57,7 @@ while getopts ":hH:f:kr:j:a:i:s:u:p:q:" opt; do usage ;; H) - ZEEBE_HOST=$OPTARG + ZEEBE_ADDRESS=$OPTARG ;; f) PROTO_FILE=$OPTARG @@ -92,27 +93,16 @@ while getopts ":hH:f:kr:j:a:i:s:u:p:q:" opt; do echo "Invalid option: $OPTARG" 1>&2 usage ;; - :) - echo "Option -$OPTARG requires an argument." 1>&2 - usage - ;; esac done - SCRIPT_STATUS_OUTPUT=0 # Check if all required options are provided -if [ -z "$ZEEBE_HOST" ]; then - echo "Error: Missing one of the required options (list of all required options: ZEEBE_HOST)." 1>&2 +if [ -z "$ZEEBE_ADDRESS" ]; then + echo "Error: Missing one of the required options (list of all required options: ZEEBE_ADDRESS)." 1>&2 usage fi -# Extract host and port from ZEEBE_HOST -if ! [[ $ZEEBE_HOST =~ ^[^:]+:[0-9]+$ ]]; then - echo "Error: Invalid format ZEEBE_HOST=$ZEEBE_HOST. Please provide host and port. Aborting." >&2 - exit 1 -fi - # pre-check requirements command -v curl >/dev/null 2>&1 || { echo >&2 "Error: curl is required but not installed. Please install it. Aborting."; exit 1; } @@ -164,8 +154,8 @@ fi if [ "$API_PROTOCOL" = "http" ]; then check_rest(){ - echo "[INFO] Checking REST API connectivity to $ZEEBE_HOST" - curl_command="curl -so /dev/null -L ${EXTRA_FLAGS_CURL} \"$ZEEBE_HOST/v2/topology\"" + echo "[INFO] Checking REST API connectivity to $ZEEBE_ADDRESS:" + curl_command="curl -so /dev/null -L ${EXTRA_FLAGS_CURL} \"$ZEEBE_ADDRESS:/v2/topology\"" echo "[INFO] Running command: ${curl_command}" if eval "${curl_command}"; then @@ -181,8 +171,8 @@ fi if [ "$API_PROTOCOL" = "grpc" ]; then # Check HTTP/2 connectivity check_http2(){ - echo "[INFO] Checking HTTP/2 connectivity to $ZEEBE_HOST" - curl_command="curl -so /dev/null --http2 ${EXTRA_FLAGS_CURL} \"https://$ZEEBE_HOST\"" + echo "[INFO] Checking HTTP/2 connectivity to ${ZEEBE_ADDRESS}" + curl_command="curl -so /dev/null --http2 ${EXTRA_FLAGS_CURL} \"https://${ZEEBE_ADDRESS}\"" echo "[INFO] Running command: ${curl_command}" if eval "${curl_command}"; then @@ -216,10 +206,10 @@ if [ "$API_PROTOCOL" = "grpc" ]; then # Check gRPC connectivity using grpcurl check_grpc(){ - echo "[INFO] Checking gRPC connectivity to $ZEEBE_HOST" + echo "[INFO] Checking gRPC connectivity to ${ZEEBE_ADDRESS}" local grcp_curl_command - grcp_curl_command="grpcurl ${EXTRA_FLAGS_GRPCURL} -proto \"${PROTO_FILE}\" \"${ZEEBE_HOST}\" gateway_protocol.Gateway/Topology" + grcp_curl_command="grpcurl ${EXTRA_FLAGS_GRPCURL} -proto \"${PROTO_FILE}\" \"${ZEEBE_ADDRESS}\" gateway_protocol.Gateway/Topology" echo "[INFO] Running command: ${grcp_curl_command}" @@ -234,10 +224,10 @@ if [ "$API_PROTOCOL" = "grpc" ]; then # Check zbctl status check_zbctl() { - echo "[INFO] Checking zbctl status to $ZEEBE_HOST..." + echo "[INFO] Checking zbctl status to $ZEEBE_ADDRESS..." local zbctl_command - zbctl_command="ZEEBE_TOKEN_SCOPE=${ZEEBE_TOKEN_SCOPE} zbctl status --address \"${ZEEBE_HOST}\" --authzUrl \"${ZEEBE_AUTHORIZATION_SERVER_URL}\" --clientId \"${ZEEBE_CLIENT_ID}\" --clientSecret \"${ZEEBE_CLIENT_SECRET}\" --audience \"${ZEEBE_TOKEN_AUDIENCE}\" ${EXTRA_FLAGS_ZBCTL}" + zbctl_command="ZEEBE_TOKEN_SCOPE=${ZEEBE_TOKEN_SCOPE} ZEEBE_ADDRESS=${ZEEBE_ADDRESS} ZEEBE_HOST="" ZEEBE_PORT="" zbctl status --authzUrl \"${ZEEBE_AUTHORIZATION_SERVER_URL}\" --clientId \"${ZEEBE_CLIENT_ID}\" --clientSecret \"${ZEEBE_CLIENT_SECRET}\" --audience \"${ZEEBE_TOKEN_AUDIENCE}\" ${EXTRA_FLAGS_ZBCTL}" echo "[INFO] Running command: ${zbctl_command}"