Add/Improve utility shell functions

This commit is contained in:
Keith Whyte 2022-07-03 22:04:17 +02:00
parent 5e653ffac7
commit 0f2a6cf49e

View file

@ -8,6 +8,14 @@ OSMO_HLR="<%= @hlr_db %>"
OSMO_SMS="<%= @sms_db %>"
DID="<%= @voip_did %>"
_get_vty_ctrl_ip() {
if [ "$1" == "" ]; then
echo "127.0.0.1"
else
echo "127.0.0.$(($1+1))"
fi
}
waitfor0calls () {
while (( $((`fs_cli -x "show calls count" | awk '$1{print $1}'`)) > 0 ))
do
@ -141,6 +149,34 @@ ns () {
expect -c 'spawn -noecho telnet 0 4245; expect >; send enable\r; expect #; send "show ns\r"; expect #' | grep NSEI | grep ALIVE;
}
mgwc () {
echo -n "VI: "
expect -c 'spawn -noecho telnet 0 4243; expect >; send enable\r; expect #; send "show mgcp active\r"; expect #' | egrep 'Virtual.*endpoint ' | wc -l
echo -n "E1: "
expect -c 'spawn -noecho telnet 0 4243; expect >; send enable\r; expect #; send "show mgcp active\r"; expect #' | egrep 'E1.*endpoint ' | wc -l;
expect -c 'spawn -noecho telnet 0 4243; expect >; send enable\r; expect #; send "show mgcp\r"; expect #' \
| egrep 'E1.*endpoint ' | nl -v0 | grep su16 | awk '{printf( "%x", $1) ; print $0}' > /tmp/list
expect -c 'spawn -noecho telnet 0 4243; expect >; send enable\r; expect #; send "show mgcp active\r"; expect #' | grep 'E1.*endpoint '\
| awk '{ cmd ="grep "$5" /tmp/list" ; cmd | getline res ; print res} '
}
trx ()
{
echo "show trx" | nc -q1 0 4242 | egrep '( |Carrier) NM State.*OK' | wc -l
}
lc () {
_h=`_get_vty_ctrl_ip $1`
expect -c 'set h '$_h'; spawn -noecho telnet $h 4242; expect >; send enable\r; expect #; send "show lchan summary\r"; expect #' | grep TCH
}
rotate_e1_pcap () {
_suf=`date +%H_%M_%S`
expect -c 'set file '$_suf'; spawn telnet localhost 4242; expect ">"; send "enable\r"; expect "#"; send "configure terminal\r"; expect "#";
send "e1_input\r"; expect "#"; send "e1_line 0 pcap /root/cap/abis.$file\r"; expect "#";
send "exit \r"; expect "#"; send "exit\r"; expect "#"'
}
pp () {
ps awxf | grep [p]ython
}
@ -175,7 +211,8 @@ bar ()
echo "BTS #?";
return;
fi;
expect -c 'set bts '$1'; spawn telnet localhost 4242; expect ">"; send "enable\r"; expect "#"; send "configure terminal\r"; expect "#";
_h=`_get_vty_ctrl_ip $2`
expect -c 'set bts '$1'; set h '$_h' ; spawn telnet $h 4242; expect ">"; send "enable\r"; expect "#"; send "configure terminal\r"; expect "#";
send "network\r"; expect "#"; send "bts $bts\r"; expect "#"; send "cell barred 1\r"; expect "#"; send "exit \r";
expect "#"; send "exit\r"; expect "#"; send "exit\r"; expect "#"; send "bts $bts resend-system-information\r"; expect "#"; send "exit\r"; expect "#"'
}
@ -186,7 +223,8 @@ unbar ()
echo "BTS #?";
return;
fi;
expect -c 'set bts '$1'; spawn telnet localhost 4242; expect ">"; send "enable\r"; expect "#"; send "configure terminal\r"; expect "#";
_h=`_get_vty_ctrl_ip $2`
expect -c 'set bts '$1'; set h '$_h' ; spawn telnet $h 4242; expect ">"; send "enable\r"; expect "#"; send "configure terminal\r"; expect "#";
send "network\r"; expect "#"; send "bts $bts\r"; expect "#"; send "cell barred 0\r"; expect "#"; send "exit \r";
expect "#"; send "exit\r"; expect "#"; send "exit\r"; expect "#"; send "bts $bts resend-system-information\r"; expect "#"; send "exit\r"; expect "#"'
}