1 # no need for shebang - this file is loaded from charts.d.plugin
3 opensips_opts="fifo get_statistics all"
5 opensips_update_every=5
7 opensips_priority=80000
10 timeout $opensips_timeout "$opensips_cmd" $opensips_opts |\
11 grep "^\(core\|dialog\|net\|registrar\|shmem\|siptrace\|sl\|tm\|uri\|usrloc\):[a-zA-Z0-9_-]\+[[:space:]]*[=:]\+[[:space:]]*[0-9]\+[[:space:]]*$" |\
13 -e "s|[[:space:]]*[=:]\+[[:space:]]*\([0-9]\+\)[[:space:]]*$|=\1|g" \
14 -e "s|[[:space:]:-]\+|_|g" \
18 [ $ret -ne 0 ] && echo "opensips_command_failed=1"
23 # if the user did not provide an opensips_cmd
24 # try to find it in the system
25 if [ -z "$opensips_cmd" ]
27 require_cmd opensipsctl || return 1
30 # check once if the command works
31 local x="$(opensips_get_stats | grep "^opensips_core_")"
32 if [ ! $? -eq 0 -o -z "$x" ]
34 echo >&2 "$PROGRAM_NAME: opensips: cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
44 CHART opensips.dialogs_active '' "OpenSIPS Active Dialogs" "dialogs" dialogs '' area $((opensips_priority + 1)) $opensips_update_every
45 DIMENSION dialog_active_dialogs active absolute 1 1
46 DIMENSION dialog_early_dialogs early absolute -1 1
48 CHART opensips.users '' "OpenSIPS Users" "users" users '' line $((opensips_priority + 2)) $opensips_update_every
49 DIMENSION usrloc_registered_users registered absolute 1 1
50 DIMENSION usrloc_location_users location absolute 1 1
51 DIMENSION usrloc_location_contacts contacts absolute 1 1
52 DIMENSION usrloc_location_expires expires incremental -1 1
54 CHART opensips.registrar '' "OpenSIPS Registrar" "registrations/s" registrar '' line $((opensips_priority + 3)) $opensips_update_every
55 DIMENSION registrar_accepted_regs accepted incremental 1 1
56 DIMENSION registrar_rejected_regs rejected incremental -1 1
58 CHART opensips.transactions '' "OpenSIPS Transactions" "transactions/s" transactions '' line $((opensips_priority + 4)) $opensips_update_every
59 DIMENSION tm_UAS_transactions UAS incremental 1 1
60 DIMENSION tm_UAC_transactions UAC incremental -1 1
62 CHART opensips.core_rcv '' "OpenSIPS Core Receives" "queries/s" core '' line $((opensips_priority + 5)) $opensips_update_every
63 DIMENSION core_rcv_requests requests incremental 1 1
64 DIMENSION core_rcv_replies replies incremental -1 1
66 CHART opensips.core_fwd '' "OpenSIPS Core Forwards" "queries/s" core '' line $((opensips_priority + 6)) $opensips_update_every
67 DIMENSION core_fwd_requests requests incremental 1 1
68 DIMENSION core_fwd_replies replies incremental -1 1
70 CHART opensips.core_drop '' "OpenSIPS Core Drops" "queries/s" core '' line $((opensips_priority + 7)) $opensips_update_every
71 DIMENSION core_drop_requests requests incremental 1 1
72 DIMENSION core_drop_replies replies incremental -1 1
74 CHART opensips.core_err '' "OpenSIPS Core Errors" "queries/s" core '' line $((opensips_priority + 8)) $opensips_update_every
75 DIMENSION core_err_requests requests incremental 1 1
76 DIMENSION core_err_replies replies incremental -1 1
78 CHART opensips.core_bad '' "OpenSIPS Core Bad" "queries/s" core '' line $((opensips_priority + 9)) $opensips_update_every
79 DIMENSION core_bad_URIs_rcvd bad_URIs_rcvd incremental 1 1
80 DIMENSION core_unsupported_methods unsupported_methods incremental 1 1
81 DIMENSION core_bad_msg_hdr bad_msg_hdr incremental 1 1
83 CHART opensips.tm_replies '' "OpenSIPS TM Replies" "replies/s" transactions '' line $((opensips_priority + 10)) $opensips_update_every
84 DIMENSION tm_received_replies received incremental 1 1
85 DIMENSION tm_relayed_replies relayed incremental 1 1
86 DIMENSION tm_local_replies local incremental 1 1
88 CHART opensips.transactions_status '' "OpenSIPS Transactions Status" "transactions/s" transactions '' line $((opensips_priority + 11)) $opensips_update_every
89 DIMENSION tm_2xx_transactions 2xx incremental 1 1
90 DIMENSION tm_3xx_transactions 3xx incremental 1 1
91 DIMENSION tm_4xx_transactions 4xx incremental 1 1
92 DIMENSION tm_5xx_transactions 5xx incremental 1 1
93 DIMENSION tm_6xx_transactions 6xx incremental 1 1
95 CHART opensips.transactions_inuse '' "OpenSIPS InUse Transactions" "transactions" transactions '' line $((opensips_priority + 12)) $opensips_update_every
96 DIMENSION tm_inuse_transactions inuse absolute 1 1
98 CHART opensips.sl_replies '' "OpenSIPS SL Replies" "replies/s" core '' line $((opensips_priority + 13)) $opensips_update_every
99 DIMENSION sl_1xx_replies 1xx incremental 1 1
100 DIMENSION sl_2xx_replies 2xx incremental 1 1
101 DIMENSION sl_3xx_replies 3xx incremental 1 1
102 DIMENSION sl_4xx_replies 4xx incremental 1 1
103 DIMENSION sl_5xx_replies 5xx incremental 1 1
104 DIMENSION sl_6xx_replies 6xx incremental 1 1
105 DIMENSION sl_sent_replies sent incremental 1 1
106 DIMENSION sl_sent_err_replies error incremental 1 1
107 DIMENSION sl_received_ACKs ACKed incremental 1 1
109 CHART opensips.dialogs '' "OpenSIPS Dialogs" "dialogs/s" dialogs '' line $((opensips_priority + 14)) $opensips_update_every
110 DIMENSION dialog_processed_dialogs processed incremental 1 1
111 DIMENSION dialog_expired_dialogs expired incremental 1 1
112 DIMENSION dialog_failed_dialogs failed incremental -1 1
114 CHART opensips.net_waiting '' "OpenSIPS Network Waiting" "kilobytes" net '' line $((opensips_priority + 15)) $opensips_update_every
115 DIMENSION net_waiting_udp UDP absolute 1 1024
116 DIMENSION net_waiting_tcp TCP absolute 1 1024
118 CHART opensips.uri_checks '' "OpenSIPS URI Checks" "checks / sec" uri '' line $((opensips_priority + 16)) $opensips_update_every
119 DIMENSION uri_positive_checks positive incremental 1 1
120 DIMENSION uri_negative_checks negative incremental -1 1
122 CHART opensips.traces '' "OpenSIPS Traces" "traces / sec" traces '' line $((opensips_priority + 17)) $opensips_update_every
123 DIMENSION siptrace_traced_requests requests incremental 1 1
124 DIMENSION siptrace_traced_replies replies incremental -1 1
126 CHART opensips.shmem '' "OpenSIPS Shared Memory" "kilobytes" mem '' line $((opensips_priority + 18)) $opensips_update_every
127 DIMENSION shmem_total_size total absolute 1 1024
128 DIMENSION shmem_used_size used absolute 1 1024
129 DIMENSION shmem_real_used_size real_used absolute 1 1024
130 DIMENSION shmem_max_used_size max_used absolute 1 1024
131 DIMENSION shmem_free_size free absolute 1 1024
133 CHART opensips.shmem_fragments '' "OpenSIPS Shared Memory Fragmentation" "fragments" mem '' line $((opensips_priority + 19)) $opensips_update_every
134 DIMENSION shmem_fragments fragments absolute 1 1
141 # the first argument to this function is the microseconds since last update
142 # pass this parameter to the BEGIN statement (see bellow).
144 # do all the work to collect / calculate the values
147 # 1. get the counters page from opensips
148 # 2. sed to remove spaces; replace . with _; remove spaces around =; prepend each line with: local opensips_
149 # 3. egrep lines starting with:
150 # local opensips_client_http_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
151 # local opensips_server_all_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
152 # 4. then execute this as a script with the eval
153 # be very carefull with eval:
154 # prepare the script and always grep at the end the lines that are usefull, so that
155 # even if something goes wrong, no other code can be executed
158 opensips_dialog_active_dialogs \
159 opensips_dialog_early_dialogs \
160 opensips_usrloc_registered_users \
161 opensips_usrloc_location_users \
162 opensips_usrloc_location_contacts \
163 opensips_usrloc_location_expires \
164 opensips_registrar_accepted_regs \
165 opensips_registrar_rejected_regs \
166 opensips_tm_UAS_transactions \
167 opensips_tm_UAC_transactions \
168 opensips_core_rcv_requests \
169 opensips_core_rcv_replies \
170 opensips_core_fwd_requests \
171 opensips_core_fwd_replies \
172 opensips_core_drop_requests \
173 opensips_core_drop_replies \
174 opensips_core_err_requests \
175 opensips_core_err_replies \
176 opensips_core_bad_URIs_rcvd \
177 opensips_core_unsupported_methods \
178 opensips_core_bad_msg_hdr \
179 opensips_tm_received_replies \
180 opensips_tm_relayed_replies \
181 opensips_tm_local_replies \
182 opensips_tm_2xx_transactions \
183 opensips_tm_3xx_transactions \
184 opensips_tm_4xx_transactions \
185 opensips_tm_5xx_transactions \
186 opensips_tm_6xx_transactions \
187 opensips_tm_inuse_transactions \
188 opensips_sl_1xx_replies \
189 opensips_sl_2xx_replies \
190 opensips_sl_3xx_replies \
191 opensips_sl_4xx_replies \
192 opensips_sl_5xx_replies \
193 opensips_sl_6xx_replies \
194 opensips_sl_sent_replies \
195 opensips_sl_sent_err_replies \
196 opensips_sl_received_ACKs \
197 opensips_dialog_processed_dialogs \
198 opensips_dialog_expired_dialogs \
199 opensips_dialog_failed_dialogs \
200 opensips_net_waiting_udp \
201 opensips_net_waiting_tcp \
202 opensips_uri_positive_checks \
203 opensips_uri_negative_checks \
204 opensips_siptrace_traced_requests \
205 opensips_siptrace_traced_replies \
206 opensips_shmem_total_size \
207 opensips_shmem_used_size \
208 opensips_shmem_real_used_size \
209 opensips_shmem_max_used_size \
210 opensips_shmem_free_size \
211 opensips_shmem_fragments
213 opensips_command_failed=0
214 eval "local $(opensips_get_stats)"
215 [ $? -ne 0 ] && return 1
217 [ $opensips_command_failed -eq 1 ] && echo >&2 "$PROGRAM_NAME: opensips: failed to get values, disabling." && return 1
219 # write the result of the work.
221 BEGIN opensips.dialogs_active $1
222 SET dialog_active_dialogs = $opensips_dialog_active_dialogs
223 SET dialog_early_dialogs = $opensips_dialog_early_dialogs
225 BEGIN opensips.users $1
226 SET usrloc_registered_users = $opensips_usrloc_registered_users
227 SET usrloc_location_users = $opensips_usrloc_location_users
228 SET usrloc_location_contacts = $opensips_usrloc_location_contacts
229 SET usrloc_location_expires = $opensips_usrloc_location_expires
231 BEGIN opensips.registrar $1
232 SET registrar_accepted_regs = $opensips_registrar_accepted_regs
233 SET registrar_rejected_regs = $opensips_registrar_rejected_regs
235 BEGIN opensips.transactions $1
236 SET tm_UAS_transactions = $opensips_tm_UAS_transactions
237 SET tm_UAC_transactions = $opensips_tm_UAC_transactions
239 BEGIN opensips.core_rcv $1
240 SET core_rcv_requests = $opensips_core_rcv_requests
241 SET core_rcv_replies = $opensips_core_rcv_replies
243 BEGIN opensips.core_fwd $1
244 SET core_fwd_requests = $opensips_core_fwd_requests
245 SET core_fwd_replies = $opensips_core_fwd_replies
247 BEGIN opensips.core_drop $1
248 SET core_drop_requests = $opensips_core_drop_requests
249 SET core_drop_replies = $opensips_core_drop_replies
251 BEGIN opensips.core_err $1
252 SET core_err_requests = $opensips_core_err_requests
253 SET core_err_replies = $opensips_core_err_replies
255 BEGIN opensips.core_bad $1
256 SET core_bad_URIs_rcvd = $opensips_core_bad_URIs_rcvd
257 SET core_unsupported_methods = $opensips_core_unsupported_methods
258 SET core_bad_msg_hdr = $opensips_core_bad_msg_hdr
260 BEGIN opensips.tm_replies $1
261 SET tm_received_replies = $opensips_tm_received_replies
262 SET tm_relayed_replies = $opensips_tm_relayed_replies
263 SET tm_local_replies = $opensips_tm_local_replies
265 BEGIN opensips.transactions_status $1
266 SET tm_2xx_transactions = $opensips_tm_2xx_transactions
267 SET tm_3xx_transactions = $opensips_tm_3xx_transactions
268 SET tm_4xx_transactions = $opensips_tm_4xx_transactions
269 SET tm_5xx_transactions = $opensips_tm_5xx_transactions
270 SET tm_6xx_transactions = $opensips_tm_6xx_transactions
272 BEGIN opensips.transactions_inuse $1
273 SET tm_inuse_transactions = $opensips_tm_inuse_transactions
275 BEGIN opensips.sl_replies $1
276 SET sl_1xx_replies = $opensips_sl_1xx_replies
277 SET sl_2xx_replies = $opensips_sl_2xx_replies
278 SET sl_3xx_replies = $opensips_sl_3xx_replies
279 SET sl_4xx_replies = $opensips_sl_4xx_replies
280 SET sl_5xx_replies = $opensips_sl_5xx_replies
281 SET sl_6xx_replies = $opensips_sl_6xx_replies
282 SET sl_sent_replies = $opensips_sl_sent_replies
283 SET sl_sent_err_replies = $opensips_sl_sent_err_replies
284 SET sl_received_ACKs = $opensips_sl_received_ACKs
286 BEGIN opensips.dialogs $1
287 SET dialog_processed_dialogs = $opensips_dialog_processed_dialogs
288 SET dialog_expired_dialogs = $opensips_dialog_expired_dialogs
289 SET dialog_failed_dialogs = $opensips_dialog_failed_dialogs
291 BEGIN opensips.net_waiting $1
292 SET net_waiting_udp = $opensips_net_waiting_udp
293 SET net_waiting_tcp = $opensips_net_waiting_tcp
295 BEGIN opensips.uri_checks $1
296 SET uri_positive_checks = $opensips_uri_positive_checks
297 SET uri_negative_checks = $opensips_uri_negative_checks
299 BEGIN opensips.traces $1
300 SET siptrace_traced_requests = $opensips_siptrace_traced_requests
301 SET siptrace_traced_replies = $opensips_siptrace_traced_replies
303 BEGIN opensips.shmem $1
304 SET shmem_total_size = $opensips_shmem_total_size
305 SET shmem_used_size = $opensips_shmem_used_size
306 SET shmem_real_used_size = $opensips_shmem_real_used_size
307 SET shmem_max_used_size = $opensips_shmem_max_used_size
308 SET shmem_free_size = $opensips_shmem_free_size
310 BEGIN opensips.shmem_fragments $1
311 SET shmem_fragments = $opensips_shmem_fragments