/
dispatcher_admin.xml
1486 lines (1426 loc) · 45.2 KB
/
dispatcher_admin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section id="overview" xreflabel="Overview">
<title>Overview</title>
<para>
This modules implements a dispatcher for destination addresses. It
computes hashes over various parts of the request and selects an
address from a destination set. The selected address may then either
overwrite the R-URI of a SIP request or be used as an outbound proxy.
</para>
<para>
The module can be used as a stateless load balancer, having no
guarantee of fair distribution.
</para>
<para>
For the distribution algorithm, the module allows the definition of
weights for the destination. This is useful in order to get a different
ratio of traffic between destinations.
</para>
<para>
Starting with version 2.1, the dispatcher module keeps its destination sets
into different partitions. Each partition is described by its own
"db_url", "table_name", "dst_avp", "grp_avp", "cnt_avp", "sock_avp",
"attr_avp" and "blacklists" set of attributes. Setting any of these
module parameters will only alter the "default" partition's properties.
</para>
<para>
In order to create a new partition, the <xref linkend="param_partition"/>
parameter can be used. If none of the 8 partition specific parameters
are defined for the "default" partition, then this partition will not
be created. Once the "default" partition is created, any undefined
parameter from other partitions will inherit the value of the
corresponding parameter of the "default" partition. If there is no
"default" partition, the default value specified in the parameter's
description will be used. Finally, note that each dispatcher table
specified using the "table_name" partition attribute requires a
corresponding "version" table record within the partition's database,
specified through "db_url".
</para>
<para>
Since version 2.1, the "flags" parameter has been moved to
ds_select_dst() and ds_select_domain() along with "force_dst" and
"use_default" flags.
</para>
</section>
<section id="dependencies" xreflabel="Dependencies">
<title>Dependencies</title>
<section>
<title>&osips; modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>TM - only if active recovery of failed hosts is required</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis>clusterer</emphasis> - only if "cluster_id"
option is enabled.
</para>
</listitem>
<listitem>
<para>
<emphasis>database</emphasis> - one of the DB SQL modules
</para>
</listitem>
<listitem>
<para>
<emphasis>freeswitch - only if "fetch_freeswitch_stats" is enabled.</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External libraries or applications</title>
<para>
The following libraries or applications must be installed before
running &osips; with this module:
<itemizedlist>
<listitem>
<para>
<emphasis>none</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section id="exported_parameters" xreflabel="Exported Parameters">
<title>Exported Parameters</title>
<section id="param_db_url" xreflabel="db_url">
<title><varname>db_url</varname> (string)</title>
<para>
Database where to load the destinations from.
Setting this parameter will only change the default partition's
db_url. Use the partition parameter to create and alter
other partitions.
</para>
<para>
NOTE: if you intend to use the default partition you have to explicity
set this default db_url, otherwise OpenSIPS will not start (he value
of global default db_url is not inherited here! ).
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>. At least one db_url should
be defined for the dispatcher module to work.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's<quote>db_url</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "db_url", "mysql://user:passwb@localhost/database")
...
</programlisting>
</example>
</section>
<section id="param_attrs_avp" xreflabel="attrs_avp">
<title><varname>attrs_avp</varname> (str)</title>
<para>
The name of the avp to contain the attributes string of the current
destination. When a destination is selected, automatically, this AVP
will provide the attributes string - this is an opaque string (from
OpenSIPS point of view) : it is loaded from destination definition (
via DB) and blindly provided in the script.
Setting this parameter will only change the default partition's
attrs_avp. Use the partition parameter to create and alter
other partitions.
</para>
<note>
</note>
<para>
<emphasis>
Default value is <quote>null</quote> - don't provide ATTRIBUTEs.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>attrs_avp</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "attrs_avp", "$avp(272)")
...
</programlisting>
</example>
</section>
<section id="param_hash_pvar" xreflabel="hash_pvar">
<title><varname>hash_pvar</varname> (str)</title>
<para>
String with PVs used for the hashing algorithm 7.
</para>
<note>
<para>
You must set this parameter if you want do hashing over custom message
parts.
</para>
</note>
<para>
<emphasis>
Default value is <quote>null</quote> - disabled.
</emphasis>
</para>
<example>
<title>Use $avp(273) for hashing:</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "hash_pvar", "$avp(273)")
...
</programlisting>
</example>
<example>
<title>Use combination of PVs for hashing:</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "hash_pvar", "hash the $fU@$ci")
...
</programlisting>
</example>
</section>
<section id="param_setid_pvar" xreflabel="setid_pvar">
<title><varname>setid_pvar</varname> (str)</title>
<para>
The name of the PV where to store the set ID (group ID) when calling
ds_is_in_list() without group parameter (third parameter).
</para>
<para>
<emphasis>
Default value is <quote>null</quote> - don't set PV.
</emphasis>
</para>
<example>
<title>Set the <quote>setid_pvar</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "setid_pvar", "$var(setid)")
...
</programlisting>
</example>
</section>
<section id="param_ds_ping_method" xreflabel="ds_ping_method">
<title><varname>ds_ping_method</varname> (string)</title>
<para>
With this Method you can define, with which method you want to probe
the failed gateways. This method is only available, if compiled with
the probing of failed gateways enabled.
</para>
<para>
<emphasis>
Default value is <quote>OPTIONS</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_ping_method</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_ping_method", "INFO")
...
</programlisting>
</example>
</section>
<section id="param_ds_ping_from" xreflabel="ds_ping_from">
<title><varname>ds_ping_from</varname> (string)</title>
<para>
With this Method you can define the "From:"-Line for the request,
sent to the failed gateways. This method is only available, if
compiled with the probing of failed gateways enabled.
</para>
<para>
<emphasis>
Default value is <quote>sip:dispatcher@localhost</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_ping_from</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_ping_from", "sip:proxy@sip.somehost.com")
...
</programlisting>
</example>
</section>
<section id="param_ds_ping_interval" xreflabel="ds_ping_interval">
<title><varname>ds_ping_interval</varname> (int)</title>
<para>
With this Method you can define the interval for sending a request to
a failed gateway. This parameter is only used, when the TM-Module is
loaded. If set to <quote>0</quote>, the pinging of failed requests
is disabled.
</para>
<para>
<emphasis>
Default value is <quote>0</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set the <quote>ds_ping_interval</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_ping_interval", 30)
...
</programlisting>
</example>
</section>
<section id="param_ds_ping_maxfwd" xreflabel="ds_ping_maxfwd">
<title><varname>ds_ping_maxfwd</varname> (int)</title>
<para>
This parameter allows you to enforce a specific Max-Forward value
for the SIP pinging requests generated by the Dispatcher modules.
If not explicitly set, no value will be enforced and it let the
Transaction Layer (TM module) to set a default Max-Forward value.
</para>
<para>
The accepted values are any positive integer values, including the
<quote>0</quote> value.
</para>
<example>
<title>Set the <quote>ds_ping_maxfwd</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_ping_maxfwd", 2)
...
</programlisting>
</example>
</section>
<section id="param_ds_probing_sock" xreflabel="ds_probing_sock">
<title><varname>ds_probing_sock</varname> (str)</title>
<para>
A socket description [proto:]host[:port] of the local socket (which
is used by OpenSIPS for SIP traffic) to be used (if multiple) for
sending the probing messages from.
</para>
<para>
<emphasis>
Default value is <quote>NULL(none)</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_probing_sock</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_probing_sock", "udp:192.168.1.100:5077")
...
</programlisting>
</example>
</section>
<section id="param_ds_probing_threshold" xreflabel="ds_probing_threshold">
<title><varname>ds_probing_threshold</varname> (int)</title>
<para>
If you want to set a gateway into probing mode, you will need a
specific number of requests until it will change from "active" to
probing. The number of attempts can be set with this parameter.
</para>
<para>
<emphasis>
Default value is <quote>3</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_probing_threshold</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_probing_threshold", 10)
...
</programlisting>
</example>
</section>
<section id="param_ds_probing_mode" xreflabel="ds_probing_mode">
<title><varname>ds_probing_mode</varname> (int)</title>
<para>
Controls what gateways are tested to see if they are reachable. If set
to 0, only the gateways with state PROBING are tested, if set to 1, all
gateways are tested. If set to 1 and the response is 408 (timeout),
an active gateway is set to PROBING state.
</para>
<para>
<emphasis>
Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_probing_mode</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_probing_mode", 1)
...
</programlisting>
</example>
</section>
<section id="param_ds_probing_list" xreflabel="ds_probing_list">
<title><varname>ds_probing_list</varname> (str)</title>
<para>
Defines a list of one or more setids that limits which
destinations are probed if probing is active. This is useful
when multiple proxies share the same dispatcher table, but you
want to limit which ones are responsible for probing specific
destinations.
</para>
<para>
<emphasis>
Default value is <quote>NULL(none)</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>ds_probing_list</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_probing_list", "1,2,3")
...
</programlisting>
</example>
</section>
<section id="param_ds_define_blacklist" xreflabel="ds_define_blacklist">
<title><varname>ds_define_blacklist</varname> (str)</title>
<para>
Defines a blacklist based on a dispatching setid from the 'default'
partition.
This list will contain the IPs (no port, all protocols) of the
destinations matching the given setid.
Use the 'partition' parameter if you want to define blacklists
based on other partitions' sets.
</para>
<para>
Multiple instances of this param are allowed.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>ds_define_blacklist</quote>
parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "ds_define_blacklist", "list= 1,4,3")
modparam("dispatcher", "ds_define_blacklist", "blist2= 2,10,6")
...
</programlisting>
</example>
</section>
<section id="param_options_reply_codes" xreflabel="options_reply_codes">
<title><varname>options_reply_codes</varname> (str)</title>
<para>
This parameter must contain a list of SIP reply codes separated by
comma. The codes defined here will be considered as valid reply codes
for OPTIONS messages used for pinging, apart for 200.
</para>
<para>
<emphasis>
Default value is <quote>NULL</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>options_reply_codes</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "options_reply_codes", "501, 403")
...
</programlisting>
</example>
</section>
<section id="param_dst_avp" xreflabel="dst_avp">
<title><varname>dst_avp</varname> (str)</title>
<para>
This is mainly for internal usage and represents the name of the avp
which will hold the list with addresses, in the order
they have been selected by the chosen algorithm. If use_default is 1,
the value of last dst_avp_id is the last address in destination set. The
first dst_avp_id is the selected destinations. All the other addresses
from the destination set will be added in the avp list to be able to
implement serial forking.
Setting this parameter will only change the default partition's
dst_avp. Use the partition parameter to create and alter
other partitions.
</para>
<para>
<emphasis>
For the 'default' partition the default value
is <quote>$avp(ds_dst_failover)</quote>. For any other partition,
the default value is <quote>$avp(ds_dst_failover_partitionname)</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>dst_avp</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "dst_avp", "$avp(271)")
...
</programlisting>
</example>
</section>
<section id="param_grp_avp" xreflabel="grp_avp">
<title><varname>grp_avp</varname> (str)</title>
<para>
This is mainly for internal usage and represents the name of the avp
storing the group id of the destination set. Good
to have it for later usage or checks.
Setting this parameter will only change the default partition's
grp_avp. Use the partition parameter to create and alter
other partitions.
</para>
<para>
<emphasis>
For the 'default' partition the default value
is <quote>$avp(ds_grp_failover)</quote>. For any other partition,
the default value is <quote>$avp(ds_grp_failover_partitionname)</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>grp_avp</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "grp_avp", "$avp(273)")
...
</programlisting>
</example>
</section>
<section id="param_cnt_avp" xreflabel="cnt_avp">
<title><varname>cnt_avp</varname> (str)</title>
<para>
This is mainly for internal usage and represents the name of the avp
storing the number of destination addresses kept in dst_avp avps.
Setting this parameter will only change the default partition's
cnt_avp. Use the partition parameter to create and alter
other partitions.
</para>
<para>
<emphasis>
For the 'default' partition the default value
is <quote>$avp(ds_cnt_failover)</quote>. For any other partition,
the default value is <quote>$avp(ds_cnt_failover_partitionname)</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>cnt_avp</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "cnt_avp", "$avp(274)")
...
</programlisting>
</example>
</section>
<section id="param_sock_avp" xreflabel="sock_avp">
<title><varname>sock_avp</varname> (str)</title>
<para>
This is mainly for internal usage and represents the name of the avp
storing the sockets to be used for the destination addresses kept in
dst_avp avps.
Setting this parameter will only change the default partition's
sock_avp. Use the partition parameter to create and alter
other partitions.
</para>
<para>
<emphasis>
For the 'default' partition the default value
is <quote>$avp(ds_sock_failover)</quote>. For any other partition,
the default value is <quote>$avp(ds_sock_failover_partitionname)</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>sock_avp</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "sock_avp", "$avp(275)")
...
</programlisting>
</example>
</section>
<section id="param_pvar_algo_pattern" xreflabel="pvar_algo_pattern">
<title><varname>pvar_algo_pattern</varname> (str)</title>
<para>
This parameter is used by the PVAR(9) algorithm to specify the
pseudovariable pattern used to detect the load of each destination. The
name of the pseudovariable should contain the string <quote>%u</quote>,
which will be internally replaced by the module with the uri of the
destination.
</para>
<para>
</para>
<para>
<emphasis>
Default value is <quote>none</quote>.
</emphasis>
</para>
<example>
<title>Set the <quote>pvar_algo_pattern</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "pvar_algo_pattern", "$stat(load_%u)")
...
</programlisting>
</example>
</section>
<section id="param_persistent_state" xreflabel="persistent_state">
<title><varname>persistent_state</varname> (int)</title>
<para>
Specifies whether the <emphasis>state</emphasis> column
should be loaded at startup and flushed during runtime or not.
</para>
<para>
<emphasis>Default value is <quote>1</quote> (enabled).
</emphasis>
</para>
<example>
<title>Set the <varname>persistent_state</varname> parameter</title>
<programlisting format="linespecific">
...
# disable all DB operations with the state of a destination
modparam("dispatcher", "persistent_state", 0)
...
</programlisting>
</example>
</section>
<section id="param_cluster_id" xreflabel="cluster_id">
<title><varname>cluster_id</varname> (integer)</title>
<para>
The ID of the cluster the module is part of. The clustering support is
used in dispatcher module for two purposes: for sharing the status
of the destinations and for controlling the pinging to destinations.
</para>
<para>
If clustering enbled, the module will automatically share changes
over the status of the destinations with the other
OpenSIPS instances that are part of a cluster. Whenever such a status
changes (following an MI command, a probing result, a script command),
the module will replicate this status change to all the nodes in this
given cluster.
</para>
<para>
The clustering with sharing tag support may be used to control which
node in the cluster will perform the pinging/probing to
destinations. See the
<xref linkend="param_cluster_sharing_tag"/> option.
</para>
<para>
For more info on how to define and populate a cluster (with OpenSIPS
nodes) see the "clusterer" module.
</para>
<para>
<emphasis>
Default value is <quote>0 (none)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cluster_id</varname> parameter</title>
<programlisting format="linespecific">
...
# replicate destination status with all OpenSIPS in cluster ID 9
modparam("dispatcher", "cluster_id", 9)
...
</programlisting>
</example>
</section>
<section id="param_cluster_sharing_tag" xreflabel="cluster_sharing_tag">
<title><varname>cluster_sharing_tag</varname> (string)</title>
<para>
The name of the sharing tag (as defined per clusterer modules) to
control which node is responsible for perform the self-triggered
actions in the module. Such actions may be the destination probing or
sharing the changes in the destination status.
If defined, only the node with active status of this tag will
perform the actions (pinging and sharing status).
</para>
<para>
The <xref linkend="param_cluster_id"/> must be defined for this option
to work.
</para>
<para>
This is an optional parameter. If not set, all the nodes in the cluster
will individually do the probing and share the status changes.
</para>
<para>
<emphasis>
Default value is <quote>empty (none)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>cluster_sharing_tag</varname> parameter</title>
<programlisting format="linespecific">
...
# only the node with the active "vip" sharing tag will perform pinging
# and broadcast the status changes
modparam("dispatcher", "cluster_id", 9)
modparam("dispatcher", "cluster_sharing_tag", "vip")
...
</programlisting>
</example>
</section>
<section id="param_partition" xreflabel="partition">
<title><varname>partition</varname> (string)</title>
<para>
Using this parameter the partition specific parameters (db_url, table_name, dst_avp,
grp_avp, cnt_avp, sock_avp, attrs_avp, ds_define_blacklist) can be defined.
</para>
<para>
The syntax is: "partition_name: param1 = value1; param2 = value2; param3 = value3".
Each value format is the same as the one used to define a specific parameter using modparam.
</para>
<para>
Whenever a new partition_name is provided, a new partition will be automatically created.
The 'default' partition can also be defined using this parameter.
</para>
<example>
<title> Create a new partition called 'part2' </title>
<programlisting format="linespecific">
...
modparam("dispatcher", "partition",
"part2:
db_url = mysql://user:passwd@localhost/database;
table_name = ds_table;
attrs_avp = $avp(ds_attr_part2);
ds_define_blacklist = list2 = 4,6;")
...
</programlisting>
</example>
</section>
<section id="param_table_name" xreflabel="table_name">
<title><varname>table_name</varname> (string)</title>
<para>
If you want to load the sets of gateways from the database you must set
this parameter as the database name.
Setting this parameter will only change the default partition's
table_name. Use the partition parameter to create and alter
other partitions.
</para>
<para>
<emphasis>
For every partition the default value is <quote>dispatcher</quote>.
</emphasis>
</para>
<example>
<title>Set the 'default' partition's <quote>table_name</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "table_name", "my_dispatcher")
...
</programlisting>
</example>
</section>
<section id="param_setid_col" xreflabel="setid_col">
<title><varname>setid_col</varname> (string)</title>
<para>
The column's name in the database storing the gateway's group id.
</para>
<para>
<emphasis>
Default value is <quote>setid</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>setid_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "setid_col", "groupid")
...
</programlisting>
</example>
</section>
<section id="param_destination_col" xreflabel="destination_col">
<title><varname>destination_col</varname> (string)</title>
<para>
The column's name in the database storing the destination's
sip uri.
</para>
<para>
<emphasis>
Default value is <quote>destination</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>destination_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "destination_col", "uri")
...
</programlisting>
</example>
</section>
<section id="param_state_col" xreflabel="state_col">
<title><varname>state_col</varname> (string)</title>
<para>
The column's name in the database storing the state of the
destination uri.
</para>
<para>
<emphasis>
Default value is <quote>state</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>state_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "state_col", "dststate")
...
</programlisting>
</example>
</section>
<section id="param_weight_col" xreflabel="weight_col">
<title><varname>weight_col</varname> (string)</title>
<para>
The column's name in the database storing the weight for
destination uri.
</para>
<para>
<emphasis>
Default value is <quote>weight</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>weight_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "weight_col", "dstweight")
...
</programlisting>
</example>
</section>
<section id="param_priority_col" xreflabel="priority_col">
<title><varname>priority_col</varname> (string)</title>
<para>
The column's name in the database storing the priority for
destination uri.
</para>
<para>
<emphasis>
Default value is <quote>priority</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>priority_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "priority_col", "dstprio")
...
</programlisting>
</example>
</section>
<section id="param_attrs_col" xreflabel="attrs_col">
<title><varname>attrs_col</varname> (string)</title>
<para>
The column's name in the database storing the attributes (opaque
string) for destination uri.
</para>
<para>
<emphasis>
Default value is <quote>attrs</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>attrs_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "attrs_col", "dstattrs")
...
</programlisting>
</example>
</section>
<section id="param_socket_col" xreflabel="socket_col">
<title><varname>socket_col</varname> (string)</title>
<para>
The column's name in the database storing the socket (as
string) for destination uri.
</para>
<para>
<emphasis>
Default value is <quote>socket</quote>.
</emphasis>
</para>
<example>
<title>Set <quote>socket_col</quote> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "socket_col", "my_sock")
...
</programlisting>
</example>
</section>
<section id="param_fetch_freeswitch_stats" xreflabel="fetch_freeswitch_stats">
<title><varname>fetch_freeswitch_stats</varname> (integer)</title>
<para>
If enabled, FreeSWITCH destinations may have dynamic dispatching weights,
refreshed at runtime, using the FreeSWITCH Event Socket Layer.
For these destinations, an Event Socket Layer URL must be provisioned
into the "weight" column, instead of an integer string. Some example values:
<emphasis>"fs://:password@freeswitch.example.com"</emphasis>
or <emphasis>"fs://user:password@127.0.0.1:8021"</emphasis>.
The default ESL port is 8021.
</para>
<para>
OpenSIPS will establish a connection with the given socket and
periodically calculate/update the weights of these destinations
using statistics pushed by the FreeSWITCH box.
</para>
<para>
The value for an automatically calculated weight ranges between
<emphasis role='bold'>0 - 100</emphasis>.
This is helpful when grouping normal destinations with
FreeSWITCH ones.
</para>
<para>
The dynamic weights are recalculated every
<emphasis>event_heartbeat_interval</emphasis> seconds (see the
"freeswitch" OpenSIPS module for more details regarding this setting),
as the stats from FreeSWITCH are expected to arrive. The update formula
is shown below (FreeSWITCH stats are highlighted in bold):
</para>
<para>
<emphasis>weight = 100 * (<emphasis role='bold'>Idle-CPU</emphasis> / 100) * (1 - <emphasis role='bold'>Session-Count</emphasis> / <emphasis role='bold'>Max-Sessions</emphasis>)</emphasis>
</para>
<para>
<emphasis>
Default value is <emphasis role='bold'>0</emphasis> (disabled).
</emphasis>
</para>
<example>
<title>Set the <varname>fetch_freeswitch_load</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "fetch_freeswitch_stats", 1)
...
</programlisting>
</example>
</section>
<section id="param_max_freeswitch_weight" xreflabel="max_freeswitch_weight">
<title><varname>max_freeswitch_weight</varname> (integer)</title>
<para>
The maximum weight of a FreeSWITCH ESL-enabled destination. This value
is also used during startup/reload, when no stats from FreeSWITCH are
available yet.
</para>
<para>
Important: When mixing normal destinations with FreeSWITCH-enabled ones in
the same dispatching set, OpenSIPS will truncate any weight values that
are larger than <emphasis role='bold'>max_freeswitch_weight</emphasis>
to the value of this parameter!
</para>
<para>
NOTE: OpenSIPS internally rounds weights to nearest integer, so larger
max weight values will more accurately represent the current load on the
FreeSWITCH boxes! For example, if you set this parameter to 1, the box
will receive no traffic whenever either its CPU or session usage goes
past 50%!
</para>
<para>
<emphasis>
Default value is <emphasis role='bold'>100</emphasis>.
</emphasis>
</para>
<example>
<title>Set the <varname>max_freeswitch_weight</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("dispatcher", "max_freeswitch_weight", 1000)
...
</programlisting>
</example>
</section>
</section>
<section id="exported_functions" xreflabel="exported_functions">
<title>Exported Functions</title>
<section id="func_ds_select_dst" xreflabel="ds_select_dst()">
<title>
<function moreinfo="none">ds_select_dst(set, alg, [flags], [partition], [max_res])</function>
</title>
<para>
The method selects a destination from the given set of addresses. It will
overwrite the destination URI (<emphasis>$du</emphasis>) of a SIP request.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para>
<emphasis>set (int)</emphasis> - a set identifier from which to select destinations
</para>
</listitem>
<listitem>
<para>
<emphasis>alg (int)</emphasis> - the algorithm used to select the
destination address
</para>
<itemizedlist>
<listitem>
<para>
<quote>0</quote> - hash over callid
</para>
</listitem>
<listitem>
<para>
<quote>1</quote> - hash over from uri.
</para>
</listitem>
<listitem>
<para>
<quote>2</quote> - hash over to uri.