From 27aa63cb05a657b67ced40f13d39fa2a4618b2a0 Mon Sep 17 00:00:00 2001 From: Yadnesh Kulkarni Date: Tue, 3 Dec 2024 07:32:41 -0500 Subject: [PATCH] Healthcheck for Kepler Since Kepler container image doesn't have either "ss" or "netstat" commands, check it's health by making curl requests to port 8888. --- .../files/healthchecks/exporter/healthcheck | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/roles/edpm_telemetry_power_monitoring/files/healthchecks/exporter/healthcheck b/roles/edpm_telemetry_power_monitoring/files/healthchecks/exporter/healthcheck index aaddff8ff..26bf07579 100644 --- a/roles/edpm_telemetry_power_monitoring/files/healthchecks/exporter/healthcheck +++ b/roles/edpm_telemetry_power_monitoring/files/healthchecks/exporter/healthcheck @@ -15,4 +15,16 @@ # License for the specific language governing permissions and limitations # under the License. -ss -lnp | grep $1 || netstat -plnt | grep -i listen | grep $1 +URL="http://0.0.0.0:8888" + +# Get the HTTP status code using curl +HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" $URL) + +# If the HTTP status code is not 200, exit with a non-zero code +if [ "$HTTP_CODE" -ne 200 ]; then + echo "Health check failed: HTTP status code $HTTP_CODE" + exit 1 +fi + +echo "Health check passed: HTTP status code $HTTP_CODE" +exit 0