File: create_network_map.sh

package info (click to toggle)
thc-ipv6 3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,116 kB
  • sloc: ansic: 52,618; sh: 529; makefile: 77; perl: 34
file content (29 lines) | stat: -rwxr-xr-x 716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
test -z "$1" -o '!' -e "$1" && {
  echo "Syntax: $0 file1 file2 file3 file4 ... > map.gv"
  echo Creates a GV file for use with Graphviz to create a network topology map
  echo file1 must have per line one entry only.
  echo "Afterwards run it like: dot -Tjpg map.gv > map.jpg"
  exit 1
}

echo "digraph my_test {"
echo "  ratio = \"auto\";"
echo "  micross = 2.0;"
echo "  label = \"network topology map\";"
#echo '  #"host_entry_example" [shape=box];'

for i in $*; do
  FIRST=""
  CNT=1
  while read l ; do
    test "$l" = "???" && l="$CNT-???-$CNT"
    test -n "$FIRST" && {
      echo "  \"$FIRST\" -> \"$l\";"
    }
    CNT=`expr $CNT + 1`
    FIRST="$l"
  done < "$i"
done | sort | uniq

echo "}"