@cryptotaxi247 / netdata-1 / commits / 471ddd680

added opensips.chart.sh

Costa Tsaousis (ktsaou) committed Nov 4, 2015 at 18:54 UTC 471ddd68074c546156a01216fe2b99a3a7e64a04
1 file changed +269
charts.d/opensips.chart.sh new
+269
@@ -0,0 +1,269 @@
1 +#!/bin/sh
2 +
3 +opensips_opts="fifo get_statistics all"
4 +opensips_cmd="opensipsctl"
5 +opensips_update_every=5
6 +
7 +opensips_get_stats() {
8 + "$opensips_cmd" $opensips_opts |\
9 + grep "^\(core\|dialog\|net\|registrar\|shmem\|siptrace\|sl\|tm\|uri\|usrloc\):[a-zA-Z0-9_ -]\+[[:space:]]*=[[:space:]]*[0-9]\+[[:space:]]*$" |\
10 + sed -e "s|-|_|g" \
11 + -e "s|:|_|g" \
12 + -e "s|[[:space:]]\+=[[:space:]]\+|=|g" \
13 + -e "s|[[:space:]]\+$||" \
14 + -e "s|^[[:space:]]\+||" \
15 + -e "s|[[:space:]]\+|_|"
16 +}
17 +
18 +opensips_check() {
19 + # check once if the url works
20 + local x="$(opensips_get_stats | grep "^core_")"
21 + if [ ! $? -eq 0 -o -z "$x" ]
22 + then
23 + echo >&2 "opensips: cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
24 + return 1
25 + fi
26 +
27 + return 0
28 +}
29 +
30 +opensips_create() {
31 + # create the charts
32 + cat <<EOF
33 +CHART opensips.dialogs_active '' "OpenSIPS Active Dialogs" "dialogs" opensips '' area 20001 $opensips_update_every
34 +DIMENSION dialog_active_dialogs active absolute 1 1
35 +DIMENSION dialog_early_dialogs early absolute -1 1
36 +
37 +CHART opensips.users '' "OpenSIPS Users" "users" opensips '' line 20002 $opensips_update_every
38 +DIMENSION usrloc_registered_users registered absolute 1 1
39 +DIMENSION usrloc_location_users location absolute 1 1
40 +DIMENSION usrloc_location_contacts contacts absolute 1 1
41 +DIMENSION usrloc_location_expires expires incremental -1 $((1 * opensips_update_every))
42 +
43 +CHART opensips.registrar '' "OpenSIPS Registrar" "registrations / sec" opensips '' line 20003 $opensips_update_every
44 +DIMENSION registrar_accepted_regs accepted incremental 1 $((1 * opensips_update_every))
45 +DIMENSION registrar_rejected_regs rejected incremental -1 $((1 * opensips_update_every))
46 +
47 +CHART opensips.transactions '' "OpenSIPS Transactions" "transactions / sec" opensips '' line 20004 $opensips_update_every
48 +DIMENSION tm_UAS_transactions UAS incremental 1 $((1 * opensips_update_every))
49 +DIMENSION tm_UAC_transactions UAC incremental -1 $((1 * opensips_update_every))
50 +
51 +CHART opensips.core_rcv '' "OpenSIPS Core Receives" "queries / sec" opensips '' line 20005 $opensips_update_every
52 +DIMENSION core_rcv_requests requests incremental 1 $((1 * opensips_update_every))
53 +DIMENSION core_rcv_replies replies incremental -1 $((1 * opensips_update_every))
54 +
55 +CHART opensips.core_fwd '' "OpenSIPS Core Forwards" "queries / sec" opensips '' line 20006 $opensips_update_every
56 +DIMENSION core_fwd_requests requests incremental 1 $((1 * opensips_update_every))
57 +DIMENSION core_fwd_replies replies incremental -1 $((1 * opensips_update_every))
58 +
59 +CHART opensips.core_drop '' "OpenSIPS Core Drops" "queries / sec" opensips '' line 20007 $opensips_update_every
60 +DIMENSION core_drop_requests requests incremental 1 $((1 * opensips_update_every))
61 +DIMENSION core_drop_replies replies incremental -1 $((1 * opensips_update_every))
62 +
63 +CHART opensips.core_err '' "OpenSIPS Core Errors" "queries / sec" opensips '' line 20008 $opensips_update_every
64 +DIMENSION core_err_requests requests incremental 1 $((1 * opensips_update_every))
65 +DIMENSION core_err_replies replies incremental -1 $((1 * opensips_update_every))
66 +
67 +CHART opensips.core_bad '' "OpenSIPS Core Bad" "queries / sec" opensips '' line 20009 $opensips_update_every
68 +DIMENSION core_bad_URIs_rcvd bad_URIs_rcvd incremental 1 $((1 * opensips_update_every))
69 +DIMENSION core_unsupported_methods unsupported_methods incremental 1 $((1 * opensips_update_every))
70 +DIMENSION core_bad_msg_hdr bad_msg_hdr incremental 1 $((1 * opensips_update_every))
71 +
72 +CHART opensips.tm_replies '' "OpenSIPS TM Replies" "replies / sec" opensips '' line 20010 $opensips_update_every
73 +DIMENSION tm_received_replies received incremental 1 $((1 * opensips_update_every))
74 +DIMENSION tm_relayed_replies relayed incremental 1 $((1 * opensips_update_every))
75 +DIMENSION tm_local_replies local incremental 1 $((1 * opensips_update_every))
76 +
77 +CHART opensips.transactions_status '' "OpenSIPS Transactions Status" "transactions / sec" opensips '' line 20011 $opensips_update_every
78 +DIMENSION tm_2xx_transactions 2xx incremental 1 $((1 * opensips_update_every))
79 +DIMENSION tm_3xx_transactions 3xx incremental 1 $((1 * opensips_update_every))
80 +DIMENSION tm_4xx_transactions 4xx incremental 1 $((1 * opensips_update_every))
81 +DIMENSION tm_5xx_transactions 5xx incremental 1 $((1 * opensips_update_every))
82 +DIMENSION tm_6xx_transactions 6xx incremental 1 $((1 * opensips_update_every))
83 +
84 +CHART opensips.transactions_inuse '' "OpenSIPS InUse Transactions" "transactions" opensips '' line 20012 $opensips_update_every
85 +DIMENSION tm_inuse_transactions inuse absolute 1 1
86 +
87 +CHART opensips.sl_replies '' "OpenSIPS SL Replies" "replies / sec" opensips '' line 20013 $opensips_update_every
88 +DIMENSION sl_1xx_replies 1xx incremental 1 $((1 * opensips_update_every))
89 +DIMENSION sl_2xx_replies 2xx incremental 1 $((1 * opensips_update_every))
90 +DIMENSION sl_3xx_replies 3xx incremental 1 $((1 * opensips_update_every))
91 +DIMENSION sl_4xx_replies 4xx incremental 1 $((1 * opensips_update_every))
92 +DIMENSION sl_5xx_replies 5xx incremental 1 $((1 * opensips_update_every))
93 +DIMENSION sl_6xx_replies 6xx incremental 1 $((1 * opensips_update_every))
94 +DIMENSION sl_sent_replies sent incremental 1 $((1 * opensips_update_every))
95 +DIMENSION sl_sent_err_replies error incremental 1 $((1 * opensips_update_every))
96 +DIMENSION sl_received_ACKs ACKed incremental 1 $((1 * opensips_update_every))
97 +
98 +CHART opensips.dialogs '' "OpenSIPS Dialogs" "dialogs / sec" opensips '' line 20014 $opensips_update_every
99 +DIMENSION dialog_processed_dialogs processed incremental 1 $((1 * opensips_update_every))
100 +DIMENSION dialog_expired_dialogs expired incremental 1 $((1 * opensips_update_every))
101 +DIMENSION dialog_failed_dialogs failed incremental -1 $((1 * opensips_update_every))
102 +
103 +CHART opensips.net_waiting '' "OpenSIPS Network Waiting" "kilobytes" opensips '' line 20015 $opensips_update_every
104 +DIMENSION net_waiting_udp UDP absolute 1 1024
105 +DIMENSION net_waiting_tcp TCP absolute 1 1024
106 +
107 +CHART opensips.uri_checks '' "OpenSIPS URI Checks" "checks / sec" opensips '' line 20016 $opensips_update_every
108 +DIMENSION uri_positive_checks positive incremental 1 $((1 * opensips_update_every))
109 +DIMENSION uri_negative_checks negative incremental -1 $((1 * opensips_update_every))
110 +
111 +CHART opensips.traces '' "OpenSIPS Traces" "traces / sec" opensips '' line 20017 $opensips_update_every
112 +DIMENSION siptrace_traced_requests requests incremental 1 $((1 * opensips_update_every))
113 +DIMENSION siptrace_traced_replies replies incremental -1 $((1 * opensips_update_every))
114 +
115 +CHART opensips.shmem '' "OpenSIPS Shared Memory" "kilobytes" opensips '' line 20018 $opensips_update_every
116 +DIMENSION shmem_total_size total absolute 1 1024
117 +DIMENSION shmem_used_size used absolute 1 1024
118 +DIMENSION shmem_real_used_size real_used absolute 1 1024
119 +DIMENSION shmem_max_used_size max_used absolute 1 1024
120 +DIMENSION shmem_free_size free absolute 1 1024
121 +
122 +CHART opensips.shmem_fragments '' "OpenSIPS Shared Memory Fragmentation" "fragments" opensips '' line 20019 $opensips_update_every
123 +DIMENSION shmem_fragments fragments absolute 1 1
124 +EOF
125 +
126 + return 0
127 +}
128 +
129 +
130 +opensips_update() {
131 + # the first argument to this function is the microseconds since last update
132 + # pass this parameter to the BEGIN statement (see bellow).
133 +
134 + # do all the work to collect / calculate the values
135 + # for each dimension
136 + # remember: KEEP IT SIMPLE AND SHORT
137 +
138 + # 1. get the counters page from opensips
139 + # 2. sed to remove spaces; replace . with _; remove spaces around =; prepend each line with: local opensips_
140 + # 3. egrep lines starting with:
141 + # local opensips_client_http_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
142 + # local opensips_server_all_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
143 + # 4. then execute this as a script with the eval
144 + #
145 + # be very carefull with eval:
146 + # prepare the script and always grep at the end the lines that are usefull, so that
147 + # even if something goes wrong, no other code can be executed
148 +
149 + eval "local $(opensips_get_stats)"
150 + [ $? -ne 0 ] && continue
151 +
152 + # write the result of the work.
153 + cat <<VALUESEOF
154 +
155 +BEGIN opensips.dialogs_active $1
156 +SET dialog_active_dialogs = $dialog_active_dialogs
157 +SET dialog_early_dialogs = $dialog_early_dialogs
158 +END
159 +
160 +BEGIN opensips.users $1
161 +SET usrloc_registered_users = $usrloc_registered_users
162 +SET usrloc_location_users = $usrloc_location_users
163 +SET usrloc_location_contacts = $usrloc_location_contacts
164 +SET usrloc_location_expires = $usrloc_location_expires
165 +END
166 +
167 +BEGIN opensips.registrar $1
168 +SET registrar_accepted_regs = $registrar_accepted_regs
169 +SET registrar_rejected_regs = $registrar_rejected_regs
170 +END
171 +
172 +BEGIN opensips.transactions $1
173 +SET tm_UAS_transactions = $tm_UAS_transactions
174 +SET tm_UAC_transactions = $tm_UAC_transactions
175 +END
176 +
177 +BEGIN opensips.core_rcv $1
178 +SET core_rcv_requests = $core_rcv_requests
179 +SET core_rcv_replies = $core_rcv_replies
180 +END
181 +
182 +BEGIN opensips.core_fwd $1
183 +SET core_fwd_requests = $core_fwd_requests
184 +SET core_fwd_replies = $core_fwd_replies
185 +END
186 +
187 +BEGIN opensips.core_drop $1
188 +SET core_drop_requests = $core_drop_requests
189 +SET core_drop_replies = $core_drop_replies
190 +END
191 +
192 +BEGIN opensips.core_err $1
193 +SET core_err_requests = $core_err_requests
194 +SET core_err_replies = $core_err_replies
195 +END
196 +
197 +BEGIN opensips.core_bad $1
198 +SET core_bad_URIs_rcvd = $core_bad_URIs_rcvd
199 +SET core_unsupported_methods = $core_unsupported_methods
200 +SET core_bad_msg_hdr = $core_bad_msg_hdr
201 +END
202 +
203 +BEGIN opensips.tm_replies $1
204 +SET tm_received_replies = $tm_received_replies
205 +SET tm_relayed_replies = $tm_relayed_replies
206 +SET tm_local_replies = $tm_local_replies
207 +END
208 +
209 +BEGIN opensips.transactions_status $1
210 +SET tm_2xx_transactions = $tm_2xx_transactions
211 +SET tm_3xx_transactions = $tm_3xx_transactions
212 +SET tm_4xx_transactions = $tm_4xx_transactions
213 +SET tm_5xx_transactions = $tm_5xx_transactions
214 +SET tm_6xx_transactions = $tm_6xx_transactions
215 +END
216 +
217 +BEGIN opensips.transactions_inuse $1
218 +SET tm_inuse_transactions = $tm_inuse_transactions
219 +END
220 +
221 +BEGIN opensips.sl_replies $1
222 +SET sl_1xx_replies = $sl_1xx_replies
223 +SET sl_2xx_replies = $sl_2xx_replies
224 +SET sl_3xx_replies = $sl_3xx_replies
225 +SET sl_4xx_replies = $sl_4xx_replies
226 +SET sl_5xx_replies = $sl_5xx_replies
227 +SET sl_6xx_replies = $sl_6xx_replies
228 +SET sl_sent_replies = $sl_sent_replies
229 +SET sl_sent_err_replies = $sl_sent_err_replies
230 +SET sl_received_ACKs = $sl_received_ACKs
231 +END
232 +
233 +BEGIN opensips.dialogs $1
234 +SET dialog_processed_dialogs = $dialog_processed_dialogs
235 +SET dialog_expired_dialogs = $dialog_expired_dialogs
236 +SET dialog_failed_dialogs = $dialog_failed_dialogs
237 +END
238 +
239 +BEGIN opensips.net_waiting $1
240 +SET net_waiting_udp = $net_waiting_udp
241 +SET net_waiting_tcp = $net_waiting_tcp
242 +END
243 +
244 +BEGIN opensips.uri_checks $1
245 +SET uri_positive_checks = $uri_positive_checks
246 +SET uri_negative_checks = $uri_negative_checks
247 +END
248 +
249 +BEGIN opensips.traces $1
250 +SET siptrace_traced_requests = $siptrace_traced_requests
251 +SET siptrace_traced_replies = $siptrace_traced_replies
252 +END
253 +
254 +BEGIN opensips.shmem $1
255 +SET shmem_total_size = $shmem_total_size
256 +SET shmem_used_size = $shmem_used_size
257 +SET shmem_real_used_size = $shmem_real_used_size
258 +SET shmem_max_used_size = $shmem_max_used_size
259 +SET shmem_free_size = $shmem_free_size
260 +END
261 +
262 +BEGIN opensips.shmem_fragments $1
263 +SET shmem_fragments = $shmem_fragments
264 +END
265 +VALUESEOF
266 +
267 + return 0
268 +}
269 +