]> arthur.barton.de Git - netdata.git/commitdiff
strictier checking
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 20 May 2014 21:54:55 +0000 (00:54 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 20 May 2014 21:54:55 +0000 (00:54 +0300)
charts.d/crsproxy.chart.sh [new file with mode: 0755]
charts.d/example.chart.sh

diff --git a/charts.d/crsproxy.chart.sh b/charts.d/crsproxy.chart.sh
new file mode 100755 (executable)
index 0000000..6aa306a
--- /dev/null
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+crsproxy_url="http://127.0.0.1:7999/counters?"
+crsproxy_cmds=""
+
+crsproxy_check() {
+       # check once if the url works
+       wget 2>/dev/null -O /dev/null "$crsproxy_url"
+       if [ ! $? -eq 0 ]
+       then
+               echo >&2 "crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
+               return 1
+       fi
+
+       if [ -z "$crsproxy_cmds" ]
+       then
+               crsproxy_cmds="`wget 2>/dev/null -O - "$crsproxy_url" | egrep "^cmd_[a-zA-Z][a-zA-Z0-9]_[a-z_]+ *= *[0-9]+$" | cut -d '_' -f 2 | sort -u`"
+               echo
+       fi
+       if [ -z "$crsproxy_cmds" ]
+       then
+               echo >&2 "crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
+               return 1
+       fi
+       return 0
+}
+
+crsproxy_create() {
+       # create the charts
+       cat <<EOF
+CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $update_every
+DIMENSION web '' absolute-no-interpolation 1 1
+DIMENSION native '' absolute-no-interpolation 1 1
+DIMENSION virtual '' absolute-no-interpolation 1 1
+CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests/s" crsproxy '' area 20001 $update_every
+DIMENSION web '' incremental-no-interpolation 1 1
+DIMENSION native '' incremental-no-interpolation -1 1
+CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients/s" crsproxy '' area 20010 $update_every
+DIMENSION web '' incremental-no-interpolation 1 1
+DIMENSION native '' incremental-no-interpolation -1 1
+DIMENSION virtual '' incremental-no-interpolation 1 1
+CHART crsproxy.replies '' "CRS Replies Rate" "replies/s" crsproxy '' area 20020 $update_every
+DIMENSION ok '' incremental-no-interpolation 1 1
+DIMENSION failed '' incremental-no-interpolation -1 1
+CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections/s" crsproxy '' area 20030 $update_every
+DIMENSION ok '' incremental-no-interpolation 1 1
+DIMENSION failed '' incremental-no-interpolation -1 1
+EOF
+
+       local x=
+       echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests/s' crsproxy '' stacked 20100 $update_every"
+       for x in $crsproxy_cmds
+       do
+               echo "DIMENSION $x '' incremental-no-interpolation 1 1"
+       done
+
+       echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies/s' crsproxy '' stacked 20110 $update_every"
+       for x in $crsproxy_cmds
+       do
+               echo "DIMENSION $x '' incremental-no-interpolation 1 1"
+       done
+
+       return 0
+}
+
+
+crsproxy_update() {
+       # the first argument to this function is the microseconds since last update
+       # pass this parameter to the BEGIN statement (see bellow).
+
+       # do all the work to collect / calculate the values
+       # for each dimension
+       # remember: KEEP IT SIMPLE AND SHORT
+
+       # get the values from crsproxy
+       eval "`wget 2>/dev/null -O - "$crsproxy_url" |\
+               sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/ = /=/g" -e "s/^/crsproxy_/g" |\
+               egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"`"
+
+
+       # write the result of the work.
+       cat <<VALUESEOF
+BEGIN crsproxy.connected $1
+SET web = $((crsproxy_web_clients_opened - crsproxy_web_clients_closed))
+SET native = $((crsproxy_crs_clients_opened - crsproxy_crs_clients_closed))
+SET virtual = $((crsproxy_virtual_clients_opened - crsproxy_virtual_clients_closed))
+END
+BEGIN crsproxy.requests $1
+SET web = $crsproxy_web_requests
+SET native = $crsproxy_native_requests
+END
+BEGIN crsproxy.clients $1
+SET web = $crsproxy_web_clients_opened
+SET native = $crsproxy_crs_clients_opened
+SET virtual = $crsproxy_virtual_clients_opened
+END
+BEGIN crsproxy.replies $1
+SET ok = $crsproxy_replies_success
+SET failed = $crsproxy_replies_error
+END
+BEGIN crsproxy.bconnections $1
+SET ok = $crsproxy_connections_nonblocking_established
+SET failed = $crsproxy_connections_nonblocking_failed
+END
+VALUESEOF
+
+       local native_requests="_native_requests"
+       local web_requests="_web_requests"
+       local replies_error="_replies_error"
+       local x=
+
+       echo "BEGIN crsproxy.commands $1"
+       for x in $crsproxy_cmds
+       do
+               eval "v=\$(( crsproxy_cmd_$x$native_requests + crsproxy_cmd_$x$web_requests ))"
+               echo "SET $x = $v"
+       done
+       echo "END"
+
+       echo "BEGIN crsproxy.commands_failed $1"
+       for x in $crsproxy_cmds
+       do
+               eval "v=\$crsproxy_cmd_$x$replies_error"
+               echo "SET $x = $v"
+       done
+       echo "END"
+
+       return 0
+}
index cc0fee1128bea3c27ce780ea53748826995cbf99..369769c11dc5b86d0812ad913fa42f71a8bd20ad 100755 (executable)
@@ -21,6 +21,9 @@ EOF
 }
 
 example_update() {
+       # the first argument to this function is the microseconds since last update
+       # pass this parameter to the BEGIN statement (see bellow).
+
        # do all the work to collect / calculate the values
        # for each dimension
        # remember: KEEP IT SIMPLE AND SHORT
@@ -31,7 +34,7 @@ example_update() {
 
        # write the result of the work.
        cat <<VALUESEOF
-BEGIN example.random
+BEGIN example.random $1
 SET random1 = $value1
 SET random2 = $value2
 SET random3 = $value3