3 crsproxy_url="http://127.0.0.1:7999/counters?"
5 crsproxy_update_every=15
8 # check once if the url works
9 wget 2>/dev/null -O /dev/null "$crsproxy_url"
12 echo >&2 "crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
16 if [ -z "$crsproxy_cmds" ]
18 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`"
21 if [ -z "$crsproxy_cmds" ]
23 echo >&2 "crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
32 CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $crsproxy_update_every
33 DIMENSION web '' absolute 1 1
34 DIMENSION native '' absolute 1 1
35 DIMENSION virtual '' absolute 1 1
36 CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests / $crsproxy_update_every sec" crsproxy '' area 20001 $crsproxy_update_every
37 DIMENSION web '' incremental 1 1
38 DIMENSION native '' incremental -1 1
39 CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients / $crsproxy_update_every sec" crsproxy '' area 20010 $crsproxy_update_every
40 DIMENSION web '' incremental 1 1
41 DIMENSION native '' incremental -1 1
42 DIMENSION virtual '' incremental 1 1
43 CHART crsproxy.replies '' "CRS Replies Rate" "replies / $crsproxy_update_every sec" crsproxy '' area 20020 $crsproxy_update_every
44 DIMENSION ok '' incremental 1 1
45 DIMENSION failed '' incremental -1 1
46 CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections / $crsproxy_update_every sec" crsproxy '' area 20030 $crsproxy_update_every
47 DIMENSION ok '' incremental 1 1
48 DIMENSION failed '' incremental -1 1
52 echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests / $crsproxy_update_every sec' crsproxy '' stacked 20100 $crsproxy_update_every"
53 for x in $crsproxy_cmds
55 echo "DIMENSION $x '' incremental 1 1"
58 echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies / $crsproxy_update_every sec' crsproxy '' stacked 20110 $crsproxy_update_every"
59 for x in $crsproxy_cmds
61 echo "DIMENSION $x '' incremental 1 1"
69 # the first argument to this function is the microseconds since last update
70 # pass this parameter to the BEGIN statement (see bellow).
72 # do all the work to collect / calculate the values
74 # remember: KEEP IT SIMPLE AND SHORT
76 # get the values from crsproxy
77 eval "`wget 2>/dev/null -O - "$crsproxy_url" |\
78 sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/ = /=/g" -e "s/^/crsproxy_/g" |\
79 egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"`"
82 # write the result of the work.
84 BEGIN crsproxy.connected $1
85 SET web = $((crsproxy_web_clients_opened - crsproxy_web_clients_closed))
86 SET native = $((crsproxy_crs_clients_opened - crsproxy_crs_clients_closed))
87 SET virtual = $((crsproxy_virtual_clients_opened - crsproxy_virtual_clients_closed))
89 BEGIN crsproxy.requests $1
90 SET web = $crsproxy_web_requests
91 SET native = $crsproxy_native_requests
93 BEGIN crsproxy.clients $1
94 SET web = $crsproxy_web_clients_opened
95 SET native = $crsproxy_crs_clients_opened
96 SET virtual = $crsproxy_virtual_clients_opened
98 BEGIN crsproxy.replies $1
99 SET ok = $crsproxy_replies_success
100 SET failed = $crsproxy_replies_error
102 BEGIN crsproxy.bconnections $1
103 SET ok = $crsproxy_connections_nonblocking_established
104 SET failed = $crsproxy_connections_nonblocking_failed
108 local native_requests="_native_requests"
109 local web_requests="_web_requests"
110 local replies_error="_replies_error"
113 echo "BEGIN crsproxy.commands $1"
114 for x in $crsproxy_cmds
116 eval "v=\$(( crsproxy_cmd_$x$native_requests + crsproxy_cmd_$x$web_requests ))"
121 echo "BEGIN crsproxy.commands_failed $1"
122 for x in $crsproxy_cmds
124 eval "v=\$crsproxy_cmd_$x$replies_error"