blob: 14c4336ab1717d263be04c6475e8b5f2a74cc137 [file] [log] [blame]
Keithc8e3c842019-04-23 20:38:33 +02001#!/usr/bin/expect -f
2
3# This expect script can be run as:
4# ./vty bsc
5# ./vty msc
6# ./vty sip ... etc
7# (no need to remember ports)
8#
9# One can edit the script itself to configure the preferred
10# logging configuration for each component.
11#
12# The last command to be issued will be logging filter all 1
13# This allows for easy recall and issuing of
14# 'logging filter all 0' to disable logging.
15# As an alternative one call call this script as
16# ./vty bsc 0 to disable logging on startup via the filter.
17#
18# Requires expect, available on most distributions.
19
20set host localhost
21set vty [lindex $argv 0]
22set lf [lindex $argv 1]
23if { $lf < 0 } { set lf 1 }
24set host localhost
25
26switch $vty {
27 hlr { set port 4258 } ; # Short names
28 bsc { set port 4242 }
29 mgw { set port 4243 }
30 mgw2 {
31 set host 127.0.0.2
32 set port 4243
33 }
34 sg { set port 4245 }
35 msc { set port 4254 }
36 sip { set port 4256 }
37 gg { set port 4260 }
38 ggsn { set port 4260 }
39 hnbgw { set port 4261 }
40
41 osmo-hlr { set port 4258 } ; # Same but with full names of osmo-daemons:
42 osmo-bsc { set port 4242 }
43 osmo-mgw { set port 4243 }
44 osmo-mgw-for-bsc { set port 4243 }
45 osmo-mgw-for-msc {
46 set host 127.0.0.2
47 set port 4243
48 }
49 osmo-sgsn { set port 4245 }
50 osmo-msc { set port 4254 }
51 osmo-sip-connector { set port 4256 }
52 osmo-ggsn { set port 4260 }
53 osmo-hnbgw { set port 4262 }
54 default { set port 4242 } ; # Default to osmo-bsc / osmo-nitb
55}
56
57spawn -noecho telnet localhost $port
58expect ">"
59send "enable\r"
60expect "#"
61send "logging enable\r"
62expect "#"
63send "logging print category 1\r"
64expect "#"
65send "logging print category-hex 0\r"
66expect "#"
67send "logging print level 1\r"
68expect "#"
69send "logging print file basename last\r"
70expect "#"
71send "logging print extended-timestamp 1\r"
72expect "#"
73send "logging level set-all notice\r"
74expect "#"
75
76# Customise logging configuration per daemon here:
77switch $vty {
78 msc {
79 send "logging level mm info\r"
80 expect "#"
81 send "logging level cc info\r"
82 expect "#"
83 }
84}
85send "logging filter all $lf\r"
86expect "#"
87interact