Keith | c8e3c84 | 2019-04-23 20:38:33 +0200 | [diff] [blame] | 1 | #!/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 | |
| 20 | set host localhost |
| 21 | set vty [lindex $argv 0] |
| 22 | set lf [lindex $argv 1] |
| 23 | if { $lf < 0 } { set lf 1 } |
| 24 | set host localhost |
| 25 | |
| 26 | switch $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 | |
| 57 | spawn -noecho telnet localhost $port |
| 58 | expect ">" |
| 59 | send "enable\r" |
| 60 | expect "#" |
| 61 | send "logging enable\r" |
| 62 | expect "#" |
| 63 | send "logging print category 1\r" |
| 64 | expect "#" |
| 65 | send "logging print category-hex 0\r" |
| 66 | expect "#" |
| 67 | send "logging print level 1\r" |
| 68 | expect "#" |
| 69 | send "logging print file basename last\r" |
| 70 | expect "#" |
| 71 | send "logging print extended-timestamp 1\r" |
| 72 | expect "#" |
| 73 | send "logging level set-all notice\r" |
| 74 | expect "#" |
| 75 | |
| 76 | # Customise logging configuration per daemon here: |
| 77 | switch $vty { |
| 78 | msc { |
| 79 | send "logging level mm info\r" |
| 80 | expect "#" |
| 81 | send "logging level cc info\r" |
| 82 | expect "#" |
| 83 | } |
| 84 | } |
| 85 | send "logging filter all $lf\r" |
| 86 | expect "#" |
| 87 | interact |