]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/nginx.chart.sh
rename chart fields to avoid conflicts with backends; fixes #1962
[netdata.git] / charts.d / nginx.chart.sh
old mode 100755 (executable)
new mode 100644 (file)
index 9b75c2c..0ae7d63
@@ -1,4 +1,10 @@
-#!/bin/bash
+# no need for shebang - this file is loaded from charts.d.plugin
+
+# netdata
+# real-time performance and health monitoring, done right!
+# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
+# GPL v3+
+#
 
 # if this chart is called X.chart.sh, then all functions and global variables
 # must start with X_
@@ -20,7 +26,7 @@ nginx_reading=0
 nginx_writing=0
 nginx_waiting=0
 nginx_get() {
-       nginx_response=($(curl -Ss ${nginx_curl_opts} "${nginx_url}"))
+       nginx_response=($(run curl -Ss ${nginx_curl_opts} "${nginx_url}"))
        [ $? -ne 0 -o "${#nginx_response[@]}" -eq 0 ] && return 1
 
        if [ "${nginx_response[0]}" != "Active" \
@@ -34,7 +40,7 @@ nginx_get() {
                 -o "${nginx_response[14]}" != "Waiting:" \
           ]
                then
-               echo >&2 "nginx: Invalid response from nginx server: ${nginx_response[*]}"
+               error "Invalid response from nginx server: ${nginx_response[*]}"
                return 1
        fi
 
@@ -55,7 +61,7 @@ nginx_get() {
                -o -z "${nginx_waiting}" \
                ]
                then
-               echo >&2 "nginx: empty values got from nginx server: ${nginx_response[*]}"
+               error "empty values got from nginx server: ${nginx_response[*]}"
                return 1
        fi
 
@@ -68,7 +74,7 @@ nginx_check() {
        nginx_get
        if [ $? -ne 0 ]
                then
-               echo >&2 "nginx: cannot find stub_status on URL '${nginx_url}'. Please set nginx_url='http://nginx.server/stub_status' in $confd/nginx.conf"
+               error "cannot find stub_status on URL '${nginx_url}'. Please set nginx_url='http://nginx.server/stub_status' in $confd/nginx.conf"
                return 1
        fi
 
@@ -82,18 +88,18 @@ nginx_check() {
 # _create is called once, to create the charts
 nginx_create() {
        cat <<EOF
-CHART nginx.connections '' "nginx Active Connections" "connections" nginx nginx.connections line $((nginx_priority + 1)) $nginx_update_every
+CHART nginx_local.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.requests line $((nginx_priority + 2)) $nginx_update_every
+CHART nginx_local.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.connections.status line $((nginx_priority + 3)) $nginx_update_every
+CHART nginx_local.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.connections.rate line $((nginx_priority + 4)) $nginx_update_every
+CHART nginx_local.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
@@ -114,18 +120,18 @@ nginx_update() {
 
        # write the result of the work.
        cat <<VALUESEOF
-BEGIN nginx.connections $1
+BEGIN nginx_local.connections $1
 SET active = $((nginx_active_connections))
 END
-BEGIN nginx.requests $1
+BEGIN nginx_local.requests $1
 SET requests = $((nginx_requests))
 END
-BEGIN nginx.connections_status $1
+BEGIN nginx_local.connections_status $1
 SET reading = $((nginx_reading))
 SET writing = $((nginx_writing))
 SET waiting = $((nginx_waiting))
 END
-BEGIN nginx.connect_rate $1
+BEGIN nginx_local.connect_rate $1
 SET accepts = $((nginx_accepts))
 SET handled = $((nginx_handled))
 END