]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/nginx.chart.sh
prevent a cat command on each iteration
[netdata.git] / charts.d / nginx.chart.sh
index d180aab5e1853355d40760e6028f86a16710bfb1..9b75c2c5e68ae67ecf663b167e401ef470df22a2 100755 (executable)
@@ -1,13 +1,15 @@
-#!/bin/sh
+#!/bin/bash
 
 # if this chart is called X.chart.sh, then all functions and global variables
 # must start with X_
 
 nginx_url="http://127.0.0.1:80/stub_status"
+nginx_curl_opts=""
 
 # _update_every is a special variable - it holds the number of seconds
 # between the calls of the _update() function
 nginx_update_every=
+nginx_priority=60000
 
 declare -a nginx_response=()
 nginx_active_connections=0
@@ -18,7 +20,7 @@ nginx_reading=0
 nginx_writing=0
 nginx_waiting=0
 nginx_get() {
-       nginx_response=($(curl -s "${nginx_url}"))
+       nginx_response=($(curl -Ss ${nginx_curl_opts} "${nginx_url}"))
        [ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1
 
        if [ "${nginx_response[0]}" != "Active" \
@@ -80,18 +82,18 @@ nginx_check() {
 # _create is called once, to create the charts
 nginx_create() {
        cat <<EOF
-CHART nginx.connections '' "nginx Active Connections" "connections" nginx nginx line 16000 $nginx_update_every
+CHART nginx.connections '' "nginx Active Connections" "connections" nginx nginx.connections line $((nginx_priority + 1)) $nginx_update_every
 DIMENSION active '' absolute 1 1
 
-CHART nginx.requests '' "nginx Requests" "requests/s" nginx nginx line 16001 $nginx_update_every
+CHART nginx.requests '' "nginx Requests" "requests/s" nginx nginx.requests line $((nginx_priority + 2)) $nginx_update_every
 DIMENSION requests '' incremental 1 1
 
-CHART nginx.connections_status '' "nginx Active Connections by Status" "connections" nginx nginx line 16002 $nginx_update_every
+CHART nginx.connections_status '' "nginx Active Connections by Status" "connections" nginx nginx.connections.status line $((nginx_priority + 3)) $nginx_update_every
 DIMENSION reading '' absolute 1 1
 DIMENSION writing '' absolute 1 1
 DIMENSION waiting idle absolute 1 1
 
-CHART nginx.connect_rate '' "nginx Connections Rate" "connections/s" nginx nginx line 16003 $nginx_update_every
+CHART nginx.connect_rate '' "nginx Connections Rate" "connections/s" nginx nginx.connections.rate line $((nginx_priority + 4)) $nginx_update_every
 DIMENSION accepts accepted incremental 1 1
 DIMENSION handled '' incremental 1 1
 EOF
@@ -113,19 +115,19 @@ nginx_update() {
        # write the result of the work.
        cat <<VALUESEOF
 BEGIN nginx.connections $1
-SET active = $[nginx_active_connections]
+SET active = $((nginx_active_connections))
 END
 BEGIN nginx.requests $1
-SET requests = $[nginx_requests]
+SET requests = $((nginx_requests))
 END
 BEGIN nginx.connections_status $1
-SET reading = $[nginx_reading]
-SET writing = $[nginx_writing]
-SET waiting = $[nginx_waiting]
+SET reading = $((nginx_reading))
+SET writing = $((nginx_writing))
+SET waiting = $((nginx_waiting))
 END
 BEGIN nginx.connect_rate $1
-SET accepts = $[nginx_accepts]
-SET handled = $[nginx_handled]
+SET accepts = $((nginx_accepts))
+SET handled = $((nginx_handled))
 END
 VALUESEOF