[SR-Users] LCR Commands Kamctl

Alberto Sagredo alberto.sagredo at avanzada7.com
Sun Feb 28 21:16:53 CET 2016


I have just edited kamctl in order to make lcr commands work. Hope that
helps someone.

Using Kamailio 4.3.0

Please find kamctl attached also

### LCR management

#

lcr() *{*

        *case* $1 *in*

                show_gws)

#                       merr "command disabled"

#                       exit 1

                        require_dbengine

                        mecho "lcr gateways"

                        QUERY="select * FROM lcr_gw ORDER BY id; "

                        $DBROCMD "$QUERY"

                        ;;

                show_routes)

#                       merr "command disabled"

#                       exit 1

                        require_dbengine

                        mecho "lcr routes"

                        QUERY="select * FROM lcr_rule ORDER BY id;"

                        $DBROCMD "$QUERY"

                        ;;

                reload)

#                       merr "command disabled"

#                       exit 1

                        kamcmd lcr.reload

                        ;;

                dump_gws)

#                       merr "command disabled"

#                       exit 1

                        kamcmd lcr.dump_gws

                        ;;

                dump_routes)

#                       merr "command disabled"

#                       exit 1

                        kamcmd lcr.dump_rules

                        *exit* 1

                        ;;

                eval_weights)

                        *shift*

                       $AWK 'BEGIN {

                                if (ARGC < 2) {

                                        printf("Usage: lcr eval_weights
<list of weights (integers 1-254)>\n");

                                        exit;

                                }

                                iters = 100000;

                                for (i = 1; i < ARGC; i++) { counts[i] = 0;
}

                                for (i = 1; i <= iters; i++) {

                                        for (j = 1; j < ARGC; j++) {

                                                elem[j] = ARGV[j] *
rshift(int(2147483647 * rand()), 8);

                                        }

                                        at = 1;

                                        max = elem[at];

                                        for (j = 2; j < ARGC; j++) {

                                                if (elem[j] > max) {

                                                        max = elem[j];

                                                        at = j;

                                                }

                                        }

                                        counts[at] = counts[at] + 1;

                                }

                                for (i = 1; i < ARGC; i++) {

                                        printf("weight %d probability
%.4f\n", ARGV[i], counts[i]/iters);

                                }

                        }' $@

                        ;;

                *)

                        usage_lcr

                        *exit* 1

        *esac*

*}*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160228/55f015be/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kamctl
Type: application/octet-stream
Size: 58815 bytes
Desc: not available
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20160228/55f015be/attachment.obj>


More information about the sr-users mailing list