Skip to content

Commit 57689a6

Browse files
authored
Merge pull request #49 from autopilotpattern/48-nginx_connections_unhandled_total-appears-incorrect
cache the curl
2 parents a66829a + a5bf630 commit 57689a6

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# A minimal Nginx container including ContainerPilot
2-
FROM nginx:1.11
2+
FROM nginx:1.13
33

44
# Add some stuff via apt-get
55
RUN apt-get update \
66
&& apt-get install -y --no-install-recommends \
77
bc \
8+
ca-certificates \
89
curl \
910
unzip \
1011
&& rm -rf /var/lib/apt/lists/*
1112

1213
# Install Consul
1314
# Releases at https://releases.hashicorp.com/consul
14-
RUN export CONSUL_VERSION=0.7.3 \
15-
&& export CONSUL_CHECKSUM=901a3796b645c3ce3853d5160080217a10ad8d9bd8356d0b73fcd6bc078b7f82 \
15+
RUN export CONSUL_VERSION=0.7.5 \
16+
&& export CONSUL_CHECKSUM=40ce7175535551882ecdff21fdd276cef6eaab96be8a8260e0599fadb6f1f5b8 \
1617
&& curl --retry 7 --fail -vo /tmp/consul.zip "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip" \
1718
&& echo "${CONSUL_CHECKSUM} /tmp/consul.zip" | sha256sum -c \
1819
&& unzip /tmp/consul -d /usr/local/bin \
@@ -25,18 +26,19 @@ RUN mkdir -p /etc/consul \
2526

2627
# Install Consul template
2728
# Releases at https://releases.hashicorp.com/consul-template/
28-
RUN export CONSUL_TEMPLATE_VERSION=0.18.0 \
29-
&& export CONSUL_TEMPLATE_CHECKSUM=f7adf1f879389e7f4e881d63ef3b84bce5bc6e073eb7a64940785d32c997bc4b \
29+
RUN export CONSUL_TEMPLATE_VERSION=0.18.3 \
30+
&& export CONSUL_TEMPLATE_CHECKSUM=caf6018d7489d97d6cc2a1ac5f1cbd574c6db4cd61ed04b22b8db7b4bde64542 \
3031
&& curl --retry 7 --fail -Lso /tmp/consul-template.zip "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip" \
3132
&& echo "${CONSUL_TEMPLATE_CHECKSUM} /tmp/consul-template.zip" | sha256sum -c \
3233
&& unzip /tmp/consul-template.zip -d /usr/local/bin \
3334
&& rm /tmp/consul-template.zip
3435

3536
# Add Containerpilot and set its configuration
36-
ENV CONTAINERPILOT_VER 2.7.2
37+
# Releases at https://github.com/joyent/containerpilot/releases
38+
ENV CONTAINERPILOT_VER 2.7.3
3739
ENV CONTAINERPILOT file:///etc/containerpilot.json
3840

39-
RUN export CONTAINERPILOT_CHECKSUM=e886899467ced6d7c76027d58c7f7554c2fb2bcc \
41+
RUN export CONTAINERPILOT_CHECKSUM=2511fdfed9c6826481a9048e8d34158e1d7728bf \
4042
&& curl -Lso /tmp/containerpilot.tar.gz \
4143
"https://github.com/joyent/containerpilot/releases/download/${CONTAINERPILOT_VER}/containerpilot-${CONTAINERPILOT_VER}.tar.gz" \
4244
&& echo "${CONTAINERPILOT_CHECKSUM} /tmp/containerpilot.tar.gz" | sha1sum -c \

bin/sensor

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ help() {
77
echo 'http://nginx.org/en/docs/http/ngx_http_stub_status_module.html'
88
}
99

10-
# Cummulative number of dropped connections
10+
# Cumulative number of dropped connections
1111
unhandled() {
12-
local accepts=$(curl -s --fail localhost/nginx-health | awk 'FNR == 3 {print $1}')
13-
local handled=$(curl -s --fail localhost/nginx-health | awk 'FNR == 3 {print $2}')
12+
local scraped=$(curl -s --fail localhost/nginx-health)
13+
local accepts=$(echo "${scraped}" | awk 'FNR == 3 {print $1}')
14+
local handled=$(echo "${scraped}" | awk 'FNR == 3 {print $2}')
1415
echo $(expr ${accepts} - ${handled})
1516
}
1617

1718
# ratio of connections-in-use to available workers
1819
connections_load() {
1920
local scraped=$(curl -s --fail localhost/nginx-health)
20-
local active=$(echo ${scraped} | awk '/Active connections/{print $3}')
21-
local waiting=$(echo ${scraped} | awk '/Reading/{print $6}')
21+
local active=$(echo "${scraped}" | awk '/Active connections/{print $3}')
22+
local waiting=$(echo "${scraped}" | awk '/Reading/{print $6}')
2223
local workers=$(echo $(cat /etc/nginx/nginx.conf | perl -n -e'/worker_connections *(\d+)/ && print $1')
2324
)
2425
echo $(echo "scale=4; (${active} - ${waiting}) / ${workers}" | bc)

0 commit comments

Comments
 (0)