diff --git a/splunk/common-files/checkstate.sh b/splunk/common-files/checkstate.sh index 977e3bed..0cc2c01d 100755 --- a/splunk/common-files/checkstate.sh +++ b/splunk/common-files/checkstate.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright 2018 Splunk +# Copyright 2023 Splunk # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,20 +15,25 @@ # limitations under the License. # -#This script is used to retrieve and report the state of the container -#Although not actively in the container, it can be used to check the health -#of the splunk instance -#NOTE: If you plan on running the splunk container while keeping Splunk +# This script is used to retrieve and report the state of the container +# Although not actively in the container, it can be used to check the health +# of the splunk instance +# NOTE: If you plan on running the splunk container while keeping Splunk # inactive for long periods of time, this script may give misleading # health results -if [[ "" == "$NO_HEALTHCHECK" ]]; then - if [[ "false" == "$SPLUNKD_SSL_ENABLE" || "false" == "$(/opt/splunk/bin/splunk btool server list | grep enableSplunkdSSL | cut -d\ -f 3)" ]]; then +# It is possible to disable the healthcheck utlizing one of the following methods: +# Set the NO_HEALTHCHECK variable +# Create the file "/tmp/healthcheck-disabled" + +if [[ "" == "$NO_HEALTHCHECK" ]] && [[ ! -f /tmp/healthcheck-disabled ]]; then + + if [[ "false" == "$SPLUNKD_SSL_ENABLE" || "false" == "$(/opt/splunk/bin/splunk btool server list | grep enableSplunkdSSL | cut -d\ -f 3)" ]]; then SCHEME="http" else SCHEME="https" fi - #If NO_HEALTHCHECK is NOT defined, then we want the healthcheck + state="$(< $CONTAINER_ARTIFACT_DIR/splunk-container.state)" case "$state" in @@ -40,6 +45,5 @@ if [[ "" == "$NO_HEALTHCHECK" ]]; then exit 1 esac else - #If NO_HEALTHCHECK is defined, ignore the healthcheck exit 0 fi