Skip to content

Instantly share code, notes, and snippets.

@michaeljfazio
Created February 5, 2020 18:03
Show Gist options
  • Save michaeljfazio/c228ba598d7e9ff2d1499a402ea8231c to your computer and use it in GitHub Desktop.
Save michaeljfazio/c228ba598d7e9ff2d1499a402ea8231c to your computer and use it in GitHub Desktop.
Generate Peers List
#!/bin/bash
function extract()
{
while read line
do
arr=( $(echo $line | tr ';' ' ') )
addr=${arr[15]::-1}
ip=$(echo $addr | cut -d: -f1)
port=$(echo $addr | cut -d: -f2)
id=${arr[13]::-1}
echo "$id:$ip:$port"
done
}
journalctl -u jormungandr.service --since "1 hour ago" 2> /dev/null | grep "connecting to peer" | extract | sort | uniq | while read line
do
id=$(echo $line | cut -d: -f1)
ip=$(echo $line | cut -d: -f2)
port=$(echo $line | cut -d: -f3)
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
echo "- address: \"/ip4/$ip/tcp/$port\""
echo " id: \"$id\""
fi
done
@michaeljfazio
Copy link
Author

michaeljfazio commented Feb 8, 2020 via email

@citizencosmos
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment