Permalink
Browse files

Fix #282 use modern arithmetic expansion in shell

Use $((.*)) instead of $[.*]
The later one is old syntax
  • Loading branch information...
1 parent 444aab6 commit ec28e63c30962818dab315d64ee4da10005e47fd @simonnagl simonnagl committed Apr 28, 2016
View
@@ -54,25 +54,25 @@ ap_create() {
# create the chart with 3 dimensions
cat <<EOF
-CHART ap_clients.${dev} '' "Connected clients to ${ssid} on ${dev}" "clients" ${dev} ap.clients line $[ap_priority + 1] $ap_update_every
+CHART ap_clients.${dev} '' "Connected clients to ${ssid} on ${dev}" "clients" ${dev} ap.clients line $((ap_priority + 1)) $ap_update_every
DIMENSION clients '' absolute 1 1
-CHART ap_bandwidth.${dev} '' "Bandwidth for ${ssid} on ${dev}" "kilobits/s" ${dev} ap.net area $[ap_priority + 2] $ap_update_every
+CHART ap_bandwidth.${dev} '' "Bandwidth for ${ssid} on ${dev}" "kilobits/s" ${dev} ap.net area $((ap_priority + 2)) $ap_update_every
DIMENSION received '' incremental 8 1024
DIMENSION sent '' incremental -8 1024
-CHART ap_packets.${dev} '' "Packets for ${ssid} on ${dev}" "packets/s" ${dev} ap.packets line $[ap_priority + 3] $ap_update_every
+CHART ap_packets.${dev} '' "Packets for ${ssid} on ${dev}" "packets/s" ${dev} ap.packets line $((ap_priority + 3)) $ap_update_every
DIMENSION received '' incremental 1 1
DIMENSION sent '' incremental -1 1
-CHART ap_issues.${dev} '' "Transmit Issues for ${ssid} on ${dev}" "issues/s" ${dev} ap.issues line $[ap_priority + 4] $ap_update_every
+CHART ap_issues.${dev} '' "Transmit Issues for ${ssid} on ${dev}" "issues/s" ${dev} ap.issues line $((ap_priority + 4)) $ap_update_every
DIMENSION retries 'tx retries' incremental 1 1
DIMENSION failures 'tx failures' incremental -1 1
-CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ap.signal line $[ap_priority + 5] $ap_update_every
+CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ap.signal line $((ap_priority + 5)) $ap_update_every
DIMENSION signal 'average signal' absolute 1 1
-CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ap.bitrate line $[ap_priority + 6] $ap_update_every
+CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ap.bitrate line $((ap_priority + 6)) $ap_update_every
DIMENSION receive '' absolute 1 1000
DIMENSION transmit '' absolute -1 1000
DIMENSION expected 'expected throughput' absolute 1 1000
@@ -47,21 +47,21 @@ apache_detect() {
for x in "${@}"
do
case "${x}" in
- 'Total Accesses') apache_key_accesses=$[i + 1] ;;
- 'Total kBytes') apache_key_kbytes=$[i + 1] ;;
- 'ReqPerSec') apache_key_reqpersec=$[i + 1] ;;
- 'BytesPerSec') apache_key_bytespersec=$[i + 1] ;;
- 'BytesPerReq') apache_key_bytesperreq=$[i + 1] ;;
- 'BusyWorkers') apache_key_busyworkers=$[i + 1] ;;
- 'IdleWorkers') apache_key_idleworkers=$[i + 1];;
- 'ConnsTotal') apache_key_connstotal=$[i + 1] ;;
- 'ConnsAsyncWriting') apache_key_connsasyncwriting=$[i + 1] ;;
- 'ConnsAsyncKeepAlive') apache_key_connsasynckeepalive=$[i + 1] ;;
- 'ConnsAsyncClosing') apache_key_connsasyncclosing=$[i + 1] ;;
- 'Scoreboard') apache_key_scoreboard=$[i] ;;
+ 'Total Accesses') apache_key_accesses=$((i + 1)) ;;
+ 'Total kBytes') apache_key_kbytes=$((i + 1)) ;;
+ 'ReqPerSec') apache_key_reqpersec=$((i + 1)) ;;
+ 'BytesPerSec') apache_key_bytespersec=$((i + 1)) ;;
+ 'BytesPerReq') apache_key_bytesperreq=$((i + 1)) ;;
+ 'BusyWorkers') apache_key_busyworkers=$((i + 1)) ;;
+ 'IdleWorkers') apache_key_idleworkers=$((i + 1));;
+ 'ConnsTotal') apache_key_connstotal=$((i + 1)) ;;
+ 'ConnsAsyncWriting') apache_key_connsasyncwriting=$((i + 1)) ;;
+ 'ConnsAsyncKeepAlive') apache_key_connsasynckeepalive=$((i + 1)) ;;
+ 'ConnsAsyncClosing') apache_key_connsasyncclosing=$((i + 1)) ;;
+ 'Scoreboard') apache_key_scoreboard=$((i)) ;;
esac
- i=$[i + 1]
+ i=$((i + 1))
done
# we will not check of the Conns*
@@ -167,27 +167,27 @@ apache_check() {
# _create is called once, to create the charts
apache_create() {
cat <<EOF
-CHART apache.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" statistics apache.bytesperreq area $[apache_priority + 8] $apache_update_every
+CHART apache.bytesperreq '' "apache Lifetime Avg. Response Size" "bytes/request" statistics apache.bytesperreq area $((apache_priority + 8)) $apache_update_every
DIMENSION size '' absolute 1 ${apache_decimal_detail}
-CHART apache.workers '' "apache Workers" "workers" workers apache.workers stacked $[apache_priority + 5] $apache_update_every
+CHART apache.workers '' "apache Workers" "workers" workers apache.workers stacked $((apache_priority + 5)) $apache_update_every
DIMENSION idle '' absolute 1 1
DIMENSION busy '' absolute 1 1
-CHART apache.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" statistics apache.reqpersec line $[apache_priority + 6] $apache_update_every
+CHART apache.reqpersec '' "apache Lifetime Avg. Requests/s" "requests/s" statistics apache.reqpersec line $((apache_priority + 6)) $apache_update_every
DIMENSION requests '' absolute 1 ${apache_decimal_detail}
-CHART apache.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" statistics apache.bytespersec area $[apache_priority + 7] $apache_update_every
-DIMENSION sent '' absolute 8 $[apache_decimal_detail * 1000]
-CHART apache.requests '' "apache Requests" "requests/s" requests apache.requests line $[apache_priority + 1] $apache_update_every
+CHART apache.bytespersec '' "apache Lifetime Avg. Bandwidth/s" "kilobits/s" statistics apache.bytespersec area $((apache_priority + 7)) $apache_update_every
+DIMENSION sent '' absolute 8 $((apache_decimal_detail * 1000))
+CHART apache.requests '' "apache Requests" "requests/s" requests apache.requests line $((apache_priority + 1)) $apache_update_every
DIMENSION requests '' incremental 1 1
-CHART apache.net '' "apache Bandwidth" "kilobits/s" bandwidth apache.net area $[apache_priority + 3] $apache_update_every
+CHART apache.net '' "apache Bandwidth" "kilobits/s" bandwidth apache.net area $((apache_priority + 3)) $apache_update_every
DIMENSION sent '' incremental 8 1
EOF
if [ ${apache_has_conns} -eq 1 ]
then
cat <<EOF2
-CHART apache.connections '' "apache Connections" "connections" connections apache.connections line $[apache_priority + 2] $apache_update_every
+CHART apache.connections '' "apache Connections" "connections" connections apache.connections line $((apache_priority + 2)) $apache_update_every
DIMENSION connections '' absolute 1 1
-CHART apache.conns_async '' "apache Async Connections" "connections" connections apache.conns_async stacked $[apache_priority + 4] $apache_update_every
+CHART apache.conns_async '' "apache Async Connections" "connections" connections apache.conns_async stacked $((apache_priority + 4)) $apache_update_every
DIMENSION keepalive '' absolute 1 1
DIMENSION closing '' absolute 1 1
DIMENSION writing '' absolute 1 1
@@ -212,36 +212,36 @@ apache_update() {
# write the result of the work.
cat <<VALUESEOF
BEGIN apache.requests $1
-SET requests = $[apache_accesses]
+SET requests = $((apache_accesses))
END
BEGIN apache.net $1
-SET sent = $[apache_kbytes]
+SET sent = $((apache_kbytes))
END
BEGIN apache.reqpersec $1
-SET requests = $[apache_reqpersec]
+SET requests = $((apache_reqpersec))
END
BEGIN apache.bytespersec $1
-SET sent = $[apache_bytespersec]
+SET sent = $((apache_bytespersec))
END
BEGIN apache.bytesperreq $1
-SET size = $[apache_bytesperreq]
+SET size = $((apache_bytesperreq))
END
BEGIN apache.workers $1
-SET idle = $[apache_idleworkers]
-SET busy = $[apache_busyworkers]
+SET idle = $((apache_idleworkers))
+SET busy = $((apache_busyworkers))
END
VALUESEOF
if [ ${apache_has_conns} -eq 1 ]
then
cat <<VALUESEOF2
BEGIN apache.connections $1
-SET connections = $[apache_connstotal]
+SET connections = $((apache_connstotal))
END
BEGIN apache.conns_async $1
-SET keepalive = $[apache_connsasynckeepalive]
-SET closing = $[apache_connsasyncwriting]
-SET writing = $[apache_connsasyncwriting]
+SET keepalive = $((apache_connsasynckeepalive))
+SET closing = $((apache_connsasyncwriting))
+SET writing = $((apache_connsasyncwriting))
END
VALUESEOF2
fi
@@ -36,7 +36,7 @@ cpufreq_create() {
# - the highest speed we can achieve -
[ $cpufreq_source_update -eq 1 ] && echo >$TMP_DIR/cpufreq.sh "cpufreq_update() {"
- echo "CHART cpu.cpufreq '' 'CPU Clock' 'MHz' 'cpufreq' '' line $[cpufreq_priority + 1] $cpufreq_update_every"
+ echo "CHART cpu.cpufreq '' 'CPU Clock' 'MHz' 'cpufreq' '' line $((cpufreq_priority + 1)) $cpufreq_update_every"
echo >>$TMP_DIR/cpufreq.sh "echo \"BEGIN cpu.cpufreq \$1\""
i=0
@@ -22,11 +22,11 @@ example_check() {
example_create() {
# create the chart with 3 dimensions
cat <<EOF
-CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked $[example_priority] $example_update_every
+CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked $((example_priority)) $example_update_every
DIMENSION random1 '' percentage-of-absolute-row 1 1
DIMENSION random2 '' percentage-of-absolute-row 1 1
DIMENSION random3 '' percentage-of-absolute-row 1 1
-CHART example.random2 '' "A random number" "random number" random random area $[example_priority + 1] $example_update_every
+CHART example.random2 '' "A random number" "random number" random random area $((example_priority + 1)) $example_update_every
DIMENSION random '' absolute 1 1
EOF
@@ -49,19 +49,19 @@ example_update() {
value1=$RANDOM
value2=$RANDOM
value3=$RANDOM
- value4=$[8192 + (RANDOM * 16383 / 32767) ]
+ value4=$((8192 + (RANDOM * 16383 / 32767) ))
if [ $example_count -gt 0 ]
then
- example_count=$[example_count - 1]
+ example_count=$((example_count - 1))
- [ $example_last -gt 16383 ] && value4=$[example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)]
- [ $example_last -le 16383 ] && value4=$[example_last - (RANDOM * (example_last / 2) / 32767)]
+ [ $example_last -gt 16383 ] && value4=$((example_last + (RANDOM * ( (32767 - example_last) / 2) / 32767)))
+ [ $example_last -le 16383 ] && value4=$((example_last - (RANDOM * (example_last / 2) / 32767)))
else
- example_count=$[1 + (RANDOM * 5 / 32767) ]
+ example_count=$((1 + (RANDOM * 5 / 32767) ))
- [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$[value4 - 16383]
- [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$[value4 + 16383]
+ [ $example_last -gt 16383 -a $value4 -gt 16383 ] && value4=$((value4 - 16383))
+ [ $example_last -le 16383 -a $value4 -lt 16383 ] && value4=$((value4 + 16383))
fi
example_last=$value4
@@ -28,7 +28,7 @@ load_average_check() {
load_average_create() {
# create a chart with 3 dimensions
cat <<EOF
-CHART system.load '' "System Load Average" "load" load system.load line $[load_priority + 1] $load_average_update_every
+CHART system.load '' "System Load Average" "load" load system.load line $((load_priority + 1)) $load_average_update_every
DIMENSION load1 '1 min' absolute 1 100
DIMENSION load5 '5 mins' absolute 1 100
DIMENSION load15 '15 mins' absolute 1 100
Oops, something went wrong.

0 comments on commit ec28e63

Please sign in to comment.