From fc1014ce41a08fca8f6c7e9d8f7d4b5db9b0e546 Mon Sep 17 00:00:00 2001 From: viovanov Date: Thu, 26 Jul 2018 11:30:01 +0300 Subject: [PATCH 1/2] Don't use "monit summary" in container readiness probe On my deployments I see monit using a lot of CPU because of this. Replacing with a curl call that grabs status from the monit daemon using using the HTTP api. --- scripts/dockerfiles/readiness-probe.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/dockerfiles/readiness-probe.sh b/scripts/dockerfiles/readiness-probe.sh index 34415b44..5807a4cf 100644 --- a/scripts/dockerfiles/readiness-probe.sh +++ b/scripts/dockerfiles/readiness-probe.sh @@ -16,12 +16,14 @@ set -o errexit -o nounset +# Grab monit port +monit_port=$(cat /etc/monitrc | grep "httpd port" | awk '{print $4}') + # Check that monit thinks everything is ready -/var/vcap/bosh/bin/monit summary | gawk ' - BEGIN { status = 0 } - $1 == "Process" && $3 != "running" { print ; status = 1 } - $1 == "File" && $3 != "accessible" { print ; status = 1 } - END { exit status } +curl -s -u admin:${MONIT_PASSWORD} http://127.0.0.1:${monit_port}/_status | gawk ' + BEGIN { status = 0 } + $1 == "status" && $2 != "running" && $2 != "accessible" { print ; status = 1 } + END { exit status } ' # Check that any additional readiness checks are ready From 02a7b97aea4b9ee4b5f2bafed9b3921f3484ed66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 27 Jul 2018 10:28:13 +0200 Subject: [PATCH 2/2] Simplify monit port detection --- scripts/dockerfiles/readiness-probe.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dockerfiles/readiness-probe.sh b/scripts/dockerfiles/readiness-probe.sh index 5807a4cf..5d5d0faa 100644 --- a/scripts/dockerfiles/readiness-probe.sh +++ b/scripts/dockerfiles/readiness-probe.sh @@ -17,7 +17,7 @@ set -o errexit -o nounset # Grab monit port -monit_port=$(cat /etc/monitrc | grep "httpd port" | awk '{print $4}') +monit_port=$(awk '/httpd port/ { print $4 }' /etc/monitrc) # Check that monit thinks everything is ready curl -s -u admin:${MONIT_PASSWORD} http://127.0.0.1:${monit_port}/_status | gawk '