From 6896f639bd42f33fcc2f3f0b7226a338f32689c4 Mon Sep 17 00:00:00 2001 From: Alec Turner Date: Thu, 11 Apr 2024 11:46:23 -0700 Subject: [PATCH] bugfix to monitor script to correct resource usage queries Two bugs are fixed by this commit. First, a typo in the format string used write resource usage data to the systemlog caused the systemlog to (correctly) reject the string as invalid json. The second fix is to handle a case where a .env file is present, but does not define the APP_CONTAINER variable. In this case the container name is left empty. This is not an immediate issue, but would become problematic in the future if additional containers were to be added. --- .../signalytic/clientapps/streamline/streamline-emr/monitor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/root/var/signalytic/clientapps/streamline/streamline-emr/monitor b/root/var/signalytic/clientapps/streamline/streamline-emr/monitor index 9caf5ace..824a808e 100755 --- a/root/var/signalytic/clientapps/streamline/streamline-emr/monitor +++ b/root/var/signalytic/clientapps/streamline/streamline-emr/monitor @@ -9,7 +9,7 @@ fi # get container info APP_CONTAINER=${APP_CONTAINER:-streamline-emr} -if [ -f ${LOCATION}/.env ]; then +if grep -q "^APP_CONTAINER=" ${LOCATION}/.env > /dev/null 2>&1; then APP_CONTAINER=$(sed -n 's/APP_CONTAINER=//p' ${LOCATION}/.env) fi @@ -29,7 +29,7 @@ pushd $LOCATION > /dev/null done # get resource usage echo "checking streamline-emr resource usage" - status=$(docker stats --no-stream --format '{"name":"{{.Name}}","cpu_p":"{{.CPUPerc}}","mem_p":"{{.MemPerc}}","mem_u":"{{.MemUsage}}","net_io":"{{.NetIO}}"},"block_io":"{{.BlockIO}}"}' ${APP_CONTAINER}) + status=$(docker stats --no-stream --format '{"name":"{{.Name}}","cpu_p":"{{.CPUPerc}}","mem_p":"{{.MemPerc}}","mem_u":"{{.MemUsage}}","net_io":"{{.NetIO}}","block_io":"{{.BlockIO}}"}' ${APP_CONTAINER}) if [ "${status}" ]; then echo $status if [ "$SYSTEMLOG" -eq 1 ]; then