strictier checking
Costa Tsaousis (ktsaou) committed
May 21, 2014 at 00:54 UTC
8806d465ca5d4b143cd890d40633d0acda6de8bb
2 files changed
+133
-1
charts.d/crsproxy.chart.sh
new
+129
@@ -0,0 +1,129 @@
1
+#!/bin/sh
2
+
3
+crsproxy_url="http://127.0.0.1:7999/counters?"
4
+crsproxy_cmds=""
5
+
6
+crsproxy_check() {
7
+ # check once if the url works
8
+ wget 2>/dev/null -O /dev/null "$crsproxy_url"
9
+ if [ ! $? -eq 0 ]
10
+ then
11
+ echo >&2 "crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
12
+ return 1
13
+ fi
14
+
15
+ if [ -z "$crsproxy_cmds" ]
16
+ then
17
+ 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`"
18
+ echo
19
+ fi
20
+ if [ -z "$crsproxy_cmds" ]
21
+ then
22
+ echo >&2 "crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
23
+ return 1
24
+ fi
25
+ return 0
26
+}
27
+
28
+crsproxy_create() {
29
+ # create the charts
30
+ cat <<EOF
31
+CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $update_every
32
+DIMENSION web '' absolute-no-interpolation 1 1
33
+DIMENSION native '' absolute-no-interpolation 1 1
34
+DIMENSION virtual '' absolute-no-interpolation 1 1
35
+CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests/s" crsproxy '' area 20001 $update_every
36
+DIMENSION web '' incremental-no-interpolation 1 1
37
+DIMENSION native '' incremental-no-interpolation -1 1
38
+CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients/s" crsproxy '' area 20010 $update_every
39
+DIMENSION web '' incremental-no-interpolation 1 1
40
+DIMENSION native '' incremental-no-interpolation -1 1
41
+DIMENSION virtual '' incremental-no-interpolation 1 1
42
+CHART crsproxy.replies '' "CRS Replies Rate" "replies/s" crsproxy '' area 20020 $update_every
43
+DIMENSION ok '' incremental-no-interpolation 1 1
44
+DIMENSION failed '' incremental-no-interpolation -1 1
45
+CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections/s" crsproxy '' area 20030 $update_every
46
+DIMENSION ok '' incremental-no-interpolation 1 1
47
+DIMENSION failed '' incremental-no-interpolation -1 1
48
+EOF
49
+
50
+ local x=
51
+ echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests/s' crsproxy '' stacked 20100 $update_every"
52
+ for x in $crsproxy_cmds
53
+ do
54
+ echo "DIMENSION $x '' incremental-no-interpolation 1 1"
55
+ done
56
+
57
+ echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies/s' crsproxy '' stacked 20110 $update_every"
58
+ for x in $crsproxy_cmds
59
+ do
60
+ echo "DIMENSION $x '' incremental-no-interpolation 1 1"
61
+ done
62
+
63
+ return 0
64
+}
65
+
66
+
67
+crsproxy_update() {
68
+ # the first argument to this function is the microseconds since last update
69
+ # pass this parameter to the BEGIN statement (see bellow).
70
+
71
+ # do all the work to collect / calculate the values
72
+ # for each dimension
73
+ # remember: KEEP IT SIMPLE AND SHORT
74
+
75
+ # get the values from crsproxy
76
+ eval "`wget 2>/dev/null -O - "$crsproxy_url" |\
77
+ sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/ = /=/g" -e "s/^/crsproxy_/g" |\
78
+ egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"`"
79
+
80
+
81
+ # write the result of the work.
82
+ cat <<VALUESEOF
83
+BEGIN crsproxy.connected $1
84
+SET web = $((crsproxy_web_clients_opened - crsproxy_web_clients_closed))
85
+SET native = $((crsproxy_crs_clients_opened - crsproxy_crs_clients_closed))
86
+SET virtual = $((crsproxy_virtual_clients_opened - crsproxy_virtual_clients_closed))
87
+END
88
+BEGIN crsproxy.requests $1
89
+SET web = $crsproxy_web_requests
90
+SET native = $crsproxy_native_requests
91
+END
92
+BEGIN crsproxy.clients $1
93
+SET web = $crsproxy_web_clients_opened
94
+SET native = $crsproxy_crs_clients_opened
95
+SET virtual = $crsproxy_virtual_clients_opened
96
+END
97
+BEGIN crsproxy.replies $1
98
+SET ok = $crsproxy_replies_success
99
+SET failed = $crsproxy_replies_error
100
+END
101
+BEGIN crsproxy.bconnections $1
102
+SET ok = $crsproxy_connections_nonblocking_established
103
+SET failed = $crsproxy_connections_nonblocking_failed
104
+END
105
+VALUESEOF
106
+
107
+ local native_requests="_native_requests"
108
+ local web_requests="_web_requests"
109
+ local replies_error="_replies_error"
110
+ local x=
111
+
112
+ echo "BEGIN crsproxy.commands $1"
113
+ for x in $crsproxy_cmds
114
+ do
115
+ eval "v=\$(( crsproxy_cmd_$x$native_requests + crsproxy_cmd_$x$web_requests ))"
116
+ echo "SET $x = $v"
117
+ done
118
+ echo "END"
119
+
120
+ echo "BEGIN crsproxy.commands_failed $1"
121
+ for x in $crsproxy_cmds
122
+ do
123
+ eval "v=\$crsproxy_cmd_$x$replies_error"
124
+ echo "SET $x = $v"
125
+ done
126
+ echo "END"
127
+
128
+ return 0
129
+}
charts.d/example.chart.sh
+4
-1
@@ -21,6 +21,9 @@ EOF
21
}
22
23
example_update() {
24
+ # the first argument to this function is the microseconds since last update
25
+ # pass this parameter to the BEGIN statement (see bellow).
26
+
27
# do all the work to collect / calculate the values
28
# for each dimension
29
# remember: KEEP IT SIMPLE AND SHORT
@@ -31,7 +34,7 @@ example_update() {
34
35
# write the result of the work.
36
cat <<VALUESEOF
34
-BEGIN example.random
37
+BEGIN example.random $1
38
SET random1 = $value1
39
SET random2 = $value2
40
SET random3 = $value3