Skip to content

Commit a5bf630

Browse files
committed
handle multi-line var
1 parent 5169086 commit a5bf630

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bin/sensor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +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() {
1212
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}')
13+
local accepts=$(echo "${scraped}" | awk 'FNR == 3 {print $1}')
14+
local handled=$(echo "${scraped}" | awk 'FNR == 3 {print $2}')
1515
echo $(expr ${accepts} - ${handled})
1616
}
1717

1818
# ratio of connections-in-use to available workers
1919
connections_load() {
2020
local scraped=$(curl -s --fail localhost/nginx-health)
21-
local active=$(echo ${scraped} | awk '/Active connections/{print $3}')
22-
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}')
2323
local workers=$(echo $(cat /etc/nginx/nginx.conf | perl -n -e'/worker_connections *(\d+)/ && print $1')
2424
)
2525
echo $(echo "scale=4; (${active} - ${waiting}) / ${workers}" | bc)

0 commit comments

Comments
 (0)