Browse code

initial commit of example demonstrating load distribution

Jiri Kuthan authored on 17/08/2003 17:57:52
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+#
2
+# $Id$
3
+#
4
+# Example for distributing load accross multiple devices
5
+#
6
+fork=no
7
+log_stderror=yes
8
+listen=192.168.2.16
9
+# ----------- global configuration parameters ------------------------
10
+
11
+loadmodule "modules/exec/exec.so"
12
+loadmodule "modules/sl/sl.so"
13
+loadmodule "modules/tm/tm.so"
14
+
15
+# ----------------- setting module-specific parameters ---------------
16
+
17
+route{
18
+	# uri for my domain ?
19
+	if (!(uri==myself)) {
20
+		sl_send_reply("500", "example serves only my domain");
21
+		break;
22
+	};
23
+	if (method=="REGISTER") {
24
+		sl_send_reply("200", "silly example -- pretend registrar");
25
+		break;
26
+	};
27
+   	exec_dset('
28
+# calculate a characteristic value for this call
29
+CHAR=`echo $SIP_HF_CALLID | sum  | awk " { print \\\$1 } "`
30
+# normalize the value
31
+NC=`expr $CHAR % 100`
32
+
33
+# distribute now
34
+
35
+# gateway 192.168.2.35 @ 10 %
36
+if [ "$NC" -lt 10 ] ; then
37
+	printf "sip:00$SIP_USER@192.168.2.35"
38
+	exit
39
+fi
40
+
41
+# anything else at 90 %
42
+printf "sip:11$SIP_USER@192.168.2.34"  
43
+exit
44
+
45
+# SER adds command-line parameters -- trash them here
46
+echo > dev/null
47
+');
48
+
49
+	t_relay();
50
+}