Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated checkstate to support healthcheck disabling via file #579

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions splunk/common-files/checkstate.sh
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -40,6 +45,5 @@ if [[ "" == "$NO_HEALTHCHECK" ]]; then
exit 1
esac
else
#If NO_HEALTHCHECK is defined, ignore the healthcheck
exit 0
fi