Skip to content

Instantly share code, notes, and snippets.

@exalted
Last active February 18, 2021 09:05
Show Gist options
  • Select an option

  • Save exalted/149cddbfef3c08c9cc5fd9c0e9cac6c5 to your computer and use it in GitHub Desktop.

Select an option

Save exalted/149cddbfef3c08c9cc5fd9c0e9cac6c5 to your computer and use it in GitHub Desktop.

Revisions

  1. exalted revised this gist Feb 18, 2021. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions healthcheck.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #
    # USAGE: `healthcheck <URL>`
    # USAGE: `healthcheck <name> <URL>`
    #

    # Minify using http://bash-minifier.appspot.com
    @@ -12,7 +12,7 @@ healthcheck() {
    while [[ true ]]; do
    started_at="$(date +"%Y-%m-%dT%H:%M:%SZ") (Local time)"
    SECONDS=0
    output=$(curl --fail --silent --show-error --stderr - $1)
    output=$(curl --fail --silent --show-error --stderr - $2)
    result=$?

    if [[ $result -ne 0 ]]; then
    @@ -26,8 +26,9 @@ healthcheck() {
    fi

    if [[ $result -eq 0 ]] && [[ $SECONDS -le 1 ]]; then
    echo "$started_at: $output"
    echo "$started_at: $1: $output"
    else
    echo "Name : $1"
    echo "Started at : $started_at"
    echo "Took : $SECONDS seconds"
    echo "Output : $output"
    @@ -39,4 +40,4 @@ healthcheck() {
    sleep 1;
    fi
    done
    }
    }
  2. exalted revised this gist Jan 8, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions healthcheck.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ healthcheck() {
    YELLOW='\033[0;33m'
    RED='\033[0;31m'
    COLOR_RESET='\033[0m'

    while [[ true ]]; do
    started_at="$(date +"%Y-%m-%dT%H:%M:%SZ") (Local time)"
    SECONDS=0
  3. exalted revised this gist Jan 8, 2021. 1 changed file with 17 additions and 8 deletions.
    25 changes: 17 additions & 8 deletions healthcheck.sh
    Original file line number Diff line number Diff line change
    @@ -9,24 +9,33 @@ healthcheck() {
    RED='\033[0;31m'
    COLOR_RESET='\033[0m'
    while [[ true ]]; do
    then="$(date +"%Y-%m-%dT%H:%M:%SZ") (Local time)"
    started_at="$(date +"%Y-%m-%dT%H:%M:%SZ") (Local time)"
    SECONDS=0
    output=$(curl --silent $1)
    output=$(curl --fail --silent --show-error --stderr - $1)
    result=$?

    if [[ $SECONDS -le 1 ]]; then
    if [[ $result -ne 0 ]]; then
    echo -e $RED
    elif [[ $SECONDS -le 1 ]]; then
    echo -e $GREEN
    echo "$then: $output"
    continue
    elif [[ $SECONDS -le 2 ]]; then
    echo -e $YELLOW
    else
    echo -e $RED
    fi

    echo "Started at : $then"
    echo "Took : $SECONDS seconds"
    echo "Output : $output"
    if [[ $result -eq 0 ]] && [[ $SECONDS -le 1 ]]; then
    echo "$started_at: $output"
    else
    echo "Started at : $started_at"
    echo "Took : $SECONDS seconds"
    echo "Output : $output"
    fi

    echo -e $COLOR_RESET

    if [[ $SECONDS -eq 0 ]]; then
    sleep 1;
    fi
    done
    }
  4. exalted created this gist Jan 8, 2021.
    32 changes: 32 additions & 0 deletions healthcheck.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #
    # USAGE: `healthcheck <URL>`
    #

    # Minify using http://bash-minifier.appspot.com
    healthcheck() {
    GREEN='\033[0;32m'
    YELLOW='\033[0;33m'
    RED='\033[0;31m'
    COLOR_RESET='\033[0m'
    while [[ true ]]; do
    then="$(date +"%Y-%m-%dT%H:%M:%SZ") (Local time)"
    SECONDS=0
    output=$(curl --silent $1)

    if [[ $SECONDS -le 1 ]]; then
    echo -e $GREEN
    echo "$then: $output"
    continue
    elif [[ $SECONDS -le 2 ]]; then
    echo -e $YELLOW
    else
    echo -e $RED
    fi

    echo "Started at : $then"
    echo "Took : $SECONDS seconds"
    echo "Output : $output"

    echo -e $COLOR_RESET
    done
    }