Skip to content

Instantly share code, notes, and snippets.

@nmicic
Last active December 19, 2024 07:58
Show Gist options
  • Select an option

  • Save nmicic/b5d9f20a409a9d019faa3f318c629b51 to your computer and use it in GitHub Desktop.

Select an option

Save nmicic/b5d9f20a409a9d019faa3f318c629b51 to your computer and use it in GitHub Desktop.
get egptc peers list from SSD or show egtpc peer output
#!/usr/bin/awk -f
#Use: chmod +x ./extract_egtpc_peers.awk;
# cat SSD.txt | ./extract_egtpc_peers.awk
# Example to use on multiple SSD's:
# cat SSD1.txt | ./extract_egtpc_peers.awk > peers1.txt
# cat SSD2.txt | ./extract_egtpc_peers.awk > peers2.txt
# cat SSD3.txt | ./extract_egtpc_peers.awk > peers3.txt
# then agregate outputs into one:
# cat peers*.txt | sort | uniq > all.txt
# -> if SSD1,2,3 are from different nodes, then all.txt will have agregated view from all.
# then we can also use: egtpc test echo gtp-version 2 src-address <source node IP address> peer-address <remote node IP address>
# OR ping (with src ip) for test. For example:
# cat all.txt | awk ‘{print “egtpc test echo gtp-version 2 src-address 1.2.3.4 peer-address “$1}’
# NOTE: replace 1.2.3.4 with source loopback interface from StarOS.
BEGIN {
collecting = 0
}
/show egtpc peers/ {
collecting = 1
next
}
/^Total Peers:/ {
total_peers = $NF
exit
}
collecting == 1 {
if ($0 ~ /\|\|\|\|\|/ || $0 ~ /-----/ || $0 ~ /vvvvv/)
next
if (NF >= 9) { # Ensure we have enough columns
if ($3 ~ /:/ || $3 ~ /\./) # Basic IP address validation
print $3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment