[SR-Users] OPTION pings with dispatcher to asterisk box

Henning Westerholt hw at skalatan.de
Mon Dec 16 15:23:23 CET 2019

Hi Karsten,

have a look to the docs:

“e.g. "class=2" would accept everything from 200 to 299 as valid response” – so that class 4 is probably everything from 400 – 499.



Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com<https://gilawa.com/>

From: sr-users <sr-users-bounces at lists.kamailio.org> On Behalf Of Karsten Horsmann
Sent: Monday, December 16, 2019 1:01 PM
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Subject: Re: [SR-Users] OPTION pings with dispatcher to asterisk box

Hi Joel, hi List,

okay in asterisk i must add an correct match entry. But i am confused about the dispatcher documentation.

What means the class=4 in the attributes field? AFAIK from now, dispatcher OPTION pings cans be only configured global with modparam settings,
same as you can only global enable or disable OPTION pinging.

Maybe some developers knows that example with "class=4" is meaning here.


For database, each element of a line resides in a different column. Next is a dispatcher.list file example:

Example 1.50. dispatcher list file



# dispatcher destination sets (groups)


# line format

# setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(str,opt)

# proxies

2 sip:;transport=tcp 0 10 class=4;prefix=448;strip=2


Am Sa., 14. Dez. 2019 um 07:45 Uhr schrieb Karsten Horsmann <khorsmann at gmail.com<mailto:khorsmann at gmail.com>>:
Hi Joel,

Ah the wrong seperator typo should be a problem. :)

I would prefer to use class=2 as default and on special cases an additional code=404.

And in dispatcher I wrote the seperator correctly.

Will check that monday.


Joel Serrano <joel at textplus.com<mailto:joel at textplus.com>> schrieb am Sa., 14. Dez. 2019, 03:26:
Hey Karsten,

I'm using that same modparam and it's working as expected. My example:

modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=403;code=488;code=405;class=3")

I believe the problem is that you are using a comma "," as separator, and the correct separator is a semi-colon ";"???

BTW (offtopic), to make Asterisk answer with a 200 OK, you can do the following:

Add to extensions.conf...

exten => s,1,Wait(1)
same => n,Hangup

This will make asterisk respond with a 200OK instead of a 404 Not Found. This "default" is dependent on the context= parameter in sip.conf, if you have changed it, you will have to name the extension accordingly. And lastly, AFAIR you don't need the wait(1) and probably can do the hangup() directly, I needed it for different reasons, give it a try.

This works for OPTIONS sent to a sip:IP:Port address, if you are using a monitoring system or cli tool or similar that sends OPTIONS to sip:something at ip:port, then the following dialplan works (I'll use "nagios" as an example: sip:nagios at X.X.X.X:5060) :

exten => nagios,1,Wait(1)
same => n,Hangup

You can combine both if you have both kinds:

exten => s,1,Wait(1)
same => n,Hangup
exten => nagios,1,Wait(1)
same => n,Hangup


Hope this helps!


On Fri, Dec 13, 2019 at 8:35 AM Karsten Horsmann <khorsmann at gmail.com<mailto:khorsmann at gmail.com>> wrote:
Hello all!

i am using kamailio 5.3.1-4 on CentOS and i am using dispatcher to ping his targets.
Now i have someone with asterisk that answers with 401 or 404 (depends on asterisk version).

So i tried  code=401;code=404 as aditional attrs. Seems not to work.
Also i tired to change the modparam from class=2 to this:
  modparam("dispatcher", "ds_ping_reply_codes", "class=2,code=401,code=404")

Is that a "bug" or a hidden feature, or i missed something?

Btw - Have a nice weekend!

SELECT * FROM dispatcher WHERE id=1 \G
*************************** 1. row ***************************
         id: 1
      setid: 1100
destination: sip:SOMEWHERE;transport=tls
      flags: 0
   priority: 0
      attrs: socket=tls:MY.IP.AD.RR:5061;ping_from=sip:MY.SIP.DOMAIN;code=401;code=404
description: UNTRUSTED

        "SET":  {
          "ID": 1100,
          "TARGETS":  [{
              "DEST": {
                "URI":  "sip:SOMEWHERE;transport=tls",
                "FLAGS":  "IP",
                "PRIORITY": 0,
                "ATTRS":  {
                  "BODY": "socket=tls:MY.IP.AD.RR:5061;ping_from=sip:MY.SIP.DOMAIN;code=401;code=404",
                  "DUID": "",
                  "MAXLOAD":  0,
                  "WEIGHT": 0,
                  "RWEIGHT":  0,
                  "SOCKET": "tls:MY.SIP.DOMAIN:5061"
                "LATENCY":  {
                  "AVG":  48768.816406,
                  "STD":  139490.953125,
                  "EST":  43359.566406,
                  "MAX":  568876,
                  "TIMEOUT":  8

#!ifdef WITH_MYSQL
modparam("dispatcher", "db_url", "DBURL")
modparam("dispatcher", "table_name", "dispatcher")
#!ifndef WITH_MYSQL
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_from", "<sip:ping at FANCY-COMPANY-WEBNAME>")
modparam("dispatcher", "ds_ping_interval", 30)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_probing_threshold", 2)
modparam("dispatcher", "setid_pvname", "$var(setid)")
modparam("dispatcher", "attrs_pvname", "$var(attrs)")
modparam("dispatcher", "ds_ping_reply_codes", "class=2,code=401,code=404")
modparam("dispatcher", "ds_ping_latency_stats", 1)


Dec 13 17:25:46 siptrunk3 /usr/sbin/kamailio[25115]: INFO: <script>: Sending message
'OPTIONS sip:SOMEWHERE;transport=tls SIP/2.0
Via: SIP/2.0/TLS MY.IP.AD.RR:5061;branch=z9hG4bK2527.825671c0000000000000000000000000.0
To: <sip:SOMEWHERE;transport=tls>
From: <sip:MY.SIP.DOMAIN>;tag=f9bf2579cb456ea8d260d4aabc8248ef-9ca844ad
Call-ID: 01cb6e272da7b0dd-25115 at MY.IP.AD.RR<mailto:01cb6e272da7b0dd-25115 at MY.IP.AD.RR>
Max-Forwards: 70
Content-Length: 0
User-Agent: SBC-OS

Dec 13 17:25:46 siptrunk3 /usr/sbin/kamailio[25127]: INFO: <script>: Received message
'SIP/2.0 404 Not Found
Via: SIP/2.0/TLS MY.IP.AD.RR:5061;branch=z9hG4bK2527.825671c0000000000000000000000000.0;received=MY.IP.AD.RR
From: <sip:MY.SIP.DOMAIN>;tag=f9bf2579cb456ea8d260d4aabc8248ef-9ca844ad
To: <sip:SOMEWHERE;transport=tls>;tag=as54adca41
Call-ID: 01cb6e272da7b0dd-25115 at MY.IP.AD.RR<mailto:01cb6e272da7b0dd-25115 at MY.IP.AD.RR>
Server: Asterisk PBX
Supported: replaces, timer
Accept: application/sdp
Content-Length: 0

*Karsten Horsmann*
Kamailio (SER) - Users Mailing List
sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
Kamailio (SER) - Users Mailing List
sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>

Mit freundlichen Grüßen
*Karsten Horsmann*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191216/f53f34d3/attachment.html>

More information about the sr-users mailing list