Results 1 to 6 of 6

Thread: Ubuntu / Debian topology change tool CLI

  1. #1
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Ubuntu / Debian topology change tool CLI

    Hi all
    Is their a command line based tool for Ubuntu / Debian that can show topology changes i a network between a source and destination.
    So when a topology change happends (source takes a different path to destination) it prints such info to the terminal screen.

    Thanks on advance
    Kind regards

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    traceroute

    The closest might be traceroute or traceroute6. They operate from the shell but have to be installed explicitly.

  3. #3
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Ubuntu / Debian topology change tool CLI

    I tried using
    Code:
    traceroute --mtu
    and
    Code:
    tracepath
    Which i am currently playing around with, thanks for the reply

  4. #4
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Ubuntu / Debian topology change tool CLI

    You have to point traceroute at a particular target

    Code:
    traceroute --mtu 8.8.8.8
    It won't tell you the topology itself but will give you an idea of the route that those particular packets happened to take on that one occasion.

  5. #5
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Ubuntu / Debian topology change tool CLI

    Thanks for the reply Lars

    I putted together a small script and are wondering how this can be improved.
    Which i have NO doubt it can be My bash skills is extreamly rusty

    Code:
    #!/bin/bash
    
    ##This script looks for changes in the topology, from a source to a destination target.
    ##If a change happends it will be printed to the screen of the device that runs the script.
    
    ##The script takes two arguments [destination_target], [sleep_between_traceroutes]
    
    if [[ $EUID -ne 0 ]]; then
        echo "This script must be run as root" 1>&2
        exit 1
    fi
    
    destination_target=${1}
    sleep_between_traceroutes=${2}
    run="1"
    
    path1="/tmp/topologyChange1.txt"
    path2="/tmp/topologyChange2.txt"
    
    file1="0"
    
    count="0"
    
    echo "script start up"
    if [ -e ${path1} ]; then
        rm -v ${path1}
    fi
    
    if [ -e ${path2} ]; then
        rm -v ${path2}
    fi
    while [ ${run} -eq 1 ]
    do
        let "count++"
        echo "Script has runned ${count} times"
        if [ ${file1} -eq 0 ]; then
            traceroute -n -I ${destination_target} |awk '{print $2}' |sed '1d' > ${path1}
            file1="1"
        else
            traceroute -n -I ${destination_target} |awk '{print $2}' |sed '1d '> ${path2}        
        fi
    
        if [ -e ${path1} ] && [ -e ${path2} ]; then
            
            echo "checking topology"    
            if [[ ! $(diff -s ${path1} ${path2}) == "Files /tmp/topologyChange1.txt and /tmp/topologyChange2.txt are identical" ]]; then
                clear
                echo "topology has changed"
    
                diff -y ${path1} ${path2}
    
                mv ${path2} ${path1}
            else
                echo "no topology change"
                echo ""
            fi
        
        fi
    
        sleep ${sleep_between_traceroutes}
    done
    
    exit 0
    Last edited by Drenriza; March 6th, 2015 at 11:36 AM.

  6. #6
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    awk

    I see that you could use just awk and do not need sed also. There are several ways to do that. One would be to check if the second column starts with a digit.

    Code:
     awk '$2 ~ /^[0-9]/ {print $2}'
    You might ask over on the Development & Programming subcategory for other tips.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •