[SR-Users] new keepalive module ?

Guillaume Bour ml+kamailio-users at bour.cc
Mon Mar 27 22:08:07 CEST 2017


Hello,

I submitted the 1st version of my prototype: https://github.com/kamailio/kamailio/pull/1045

I attach here 2 sample configurations to use with

Regards,
Guillaume Bour

On Thu, Mar 16, 2017 at 01:18:47PM +0100, Daniel-Constantin Mierla wrote:
> Hello,
> 
> 
> On 13/03/2017 22:45, Guillaume Bour wrote:
> > Hi Daniel,
> >
> > Thanks for you answer
> >
> > On Tue, Mar 07, 2017 at 11:35:17PM +0100, Daniel-Constantin Mierla wrote:
> >> Hello,
> >>
> >>
> >> On 07/03/2017 21:22, Guillaume Bour wrote:
> >>> Hi all,
> >>>
> >>> I would like to implement destinations keepalive in drouting module (as it is done in dispatcher).
> >>> But instead of duplicating what's implemented in dispatcher, I think it would be more clever to create a new module
> >>> dedicated to pinging destinations, and to plug drouting, dispatcher and other modules to this new one
> >>>
> >>> What's you opinion about that ?
> >>>
> >> could be an interesting module, not able to say at this moment if I
> >> would plug it into dispatcher, as I cannot assert the impact, but at
> >> least for adding to drouting or other modules which don't have this
> >> feature, should worth the try.
> >>
> >> How do you plan to have the relation between the modules? Each of them
> >> will have a copy of the addresses, or the addresses of the destinations
> >> will be in. a single module, and the other will refer to them via some
> >> unique id? Will drouting just build the list of destination based on
> >> priority, then check with the new module to see which are active and
> >> remove the inactive ones?
> > My idea is to expose a set of API functions, allowing other modules
> > to register/unregister addresses to monitor.
> > So yes, destinations adresses would be duplicated in keepalive module memory.
> > Then keepalive module would notify the "source" module when destination
> > status change (available -> unavailable, and vice-versa)
> >
> >> Again, when I would see some sort of prototype/initial version, probably
> >> I can comment more. The questions above just pop up in my mind, but
> >> probably you can just go ahead to write some code as you consider, then
> >> we can start a discussion from there and see what can be improved/better
> >> integrated with existing modules.
> >>
> > I have started working on a POC.
> > It is available at https://github.com/gbour/kamailio/tree/module-keepalive
> OK, thanks for pointing to it.
> 
> Once you get something working, you can make a pull request so we can
> review it using github portal.
> 
> It may be useful to have it working with its own group of destination
> and export to kamailio.cfg some functions to check if a destination is
> active or not, change it state, etc ... It can be used when routing to a
> single pstn gateway or other media servers to reply directly from
> kamailio, not to forward and wait for timeout.
> 
> Cheers,
> Daniel
> >
> >
> >> Cheers,
> >> Daniel
> >>
> >> -- 
> >> Daniel-Constantin Mierla
> >> www.twitter.com/miconda -- www.linkedin.com/in/miconda
> >> Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com
> >> Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com
> >>
> >>
> >> _______________________________________________
> >> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> >> sr-users at lists.sip-router.org
> >> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
> > _______________________________________________
> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> > sr-users at lists.sip-router.org
> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
> 
> -- 
> Daniel-Constantin Mierla
> www.twitter.com/miconda -- www.linkedin.com/in/miconda
> Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com
> Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com
> 
> 
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-------------- next part --------------

####### Global Parameters #########

### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
debug=2
log_stderror=yes

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

children=1

tcp_connection_lifetime=3605
listen=udp:127.0.0.1:5060

mpath="/opt/kamailio-trunk-ka/lib64/kamailio/modules/"
rundir="/tmp"

loadmodule "tm.so"
loadmodule "sl.so"
loadmodule "xlog.so"

# remote commands (kamctl)
loadmodule "xhttp.so"
loadmodule "jsonrpcs.so"
# - 
loadmodule "ctl.so"
loadmodule "keepalive.so"
loadmodule "pv.so"

loadmodule "db_mysql.so"
loadmodule "drouting.so"

loadmodule "avp.so"

# ----- jsonrpcs -----
modparam("jsonrpcs", "fifo_name", "/opt/kamailio-trunk-ka/var/run/kamailio_jsonrpc.fifo")
# ----- ctl -----


# ----- keepalive -----
modparam("keepalive", "ping_interval", 10)

# ----- drouting -----
modparam("drouting", "db_url", "mysql://foo:bar@localhost/kamailio")
modparam("drouting", "enable_keepalive", 1)
modparam("drouting", "ruri_avp", '$avp(dr_ruri)')
modparam("drouting", "attrs_avp", '$avp(dr_attrs)')

####### Routing Logic ########


# Main SIP request routing logic
# - processing of any incoming SIP request starts with this route
# - note: this is the same as route { ... }
request_route {
	if (!do_routing(1)) {
		xlog("L_ERR", "no route found");
	};

	# 1.2.3.4 being one of drouting destinations
	$avp(ds_state) = is_alive("1.2.3.4");
	dump_attrs();
	xlog("L_ERR", "ruri= $ru\n");
	

	sl_send_reply("404", "Not Found");
	# needs 1 instruction at least
	exit;
}

event_route[keepalive:dst-up] {
	xlog("L_ERR", "host is up: $rm $ru ($du)\n");
}

event_route[keepalive:dst-down] {
	xlog("L_ERR", "host is down $rm $ru ($du)\n");
}
-------------- next part --------------

####### Global Parameters #########

### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
debug=2
log_stderror=yes

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

children=1

tcp_connection_lifetime=3605
listen=udp:127.0.0.1:5060

mpath="/opt/kamailio-trunk-ka/lib64/kamailio/modules/"
rundir="/tmp"

loadmodule "tm.so"
loadmodule "sl.so"
loadmodule "xlog.so"

# remote commands (kamctl)
loadmodule "xhttp.so"
loadmodule "jsonrpcs.so"
loadmodule "ctl.so"
loadmodule "keepalive.so"
loadmodule "pv.so"
loadmodule "avp.so"

# ----- jsonrpcs -----
modparam("jsonrpcs", "fifo_name", "/opt/kamailio-trunk-ka/var/run/kamailio_jsonrpc.fifo")
# ----- ctl -----


# ----- keepalive -----
modparam("keepalive", "ping_interval", 10)

modparam("keepalive", "destination", "sip:my.sip.provider.com")
modparam("keepalive", "destination", "192.168.0.10")



####### Routing Logic ########


# Main SIP request routing logic
# - processing of any incoming SIP request starts with this route
# - note: this is the same as route { ... }
request_route {
	$avp(ds_state) = is_alive("192.168.0.10");
	dump_attrs();

	sl_send_reply("404", "Not Found");
	# needs 1 instruction at least
	exit;
}

event_route[keepalive:dst-up] {
	xlog("L_ERR", "host is up: $rm $ru ($du)\n");
}

event_route[keepalive:dst-down] {
	xlog("L_ERR", "host is down $rm $ru ($du)\n");
}


More information about the sr-users mailing list