-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate
More file actions
26 lines (24 loc) · 853 Bytes
/
Copy pathtemplate
File metadata and controls
26 lines (24 loc) · 853 Bytes
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
#!/bin/bash
interface_info=$(ls /sys/class/net | grep -i ^en)
echo "Starting CDPR for host $HOSTNAME"
echo "Interface(s) : $interface_info"
> sw_int_port.txt
for i in $interface_info
do
echo "--- Interface $i :" > CDPR
echo "Checking Link Status ..."
status=`ethtool $i | grep -i "Link detected: yes" | awk '{print $3}'`
if [ $status == "yes" ]
then
echo "Interface link status is UP"
cdpr -d $i >> CDPR
data=`cat CDPR | grep value | awk '{ print $2}'`
#echo "Interface Data : " $data
switch=`echo $data | awk '{print $1}'`
#echo "Switch Information : " $switch
port=`echo $data | awk '{print $3}'`
#echo "Port Information : " $port
echo " - $switch[Name=$switch] -> $switch"_"$port[Name=$port, MTU=1500]" >> sw_int_port.txt
echo " - $switch"_"$port -> *[Type=host,Name=$HOSTNAME]/$i" >> sw_int_port.txt
fi
done