-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArista2.py
115 lines (87 loc) · 4.04 KB
/
Arista2.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#In this script, we have 100 leaf switches.
import pyeapi
import pprint
switches =[]
Problemliolanlar=[]
Po100_Problemliolanlar=[]
Mlag_LLDP_Problemiolanlar=[]
BGP_Problemiolanlar=[]
vericekme_problemiolanlar=[]
problemli_cihazlar=[]
i=101
while i<201:
fourh_octet=i
IP= "10.129.34."+str(fourh_octet)
i = i+1
switches.append(IP)
for i in switches:
try:
node = pyeapi.connect(transport="https", host=i,username="xxxx", password="xxx!", port=None)
hostname = node.execute(["show hostname"])
cihazin_adi = hostname['result'][0]['hostname']
leafnumber= cihazin_adi.split("-")
lldp = node.execute(["show lldp neighbors"])
cihazdaki_komsuluk = list(lldp['result'][0]['lldpNeighbors'])
cihazdaki_komsuluk.reverse()
cihazdaki_lldp_sayisi = len(cihazdaki_komsuluk)
cvx=node.execute(["show management cvx"])
po100 = node.execute(["show interfaces port-Channel 100 status"])
bgp = node.execute(["show ip bgp summary"])
bgppeer = bgp['result'][0]['vrfs']['default']['peers']
print
print"***************************************"
print "cihazin adi:", cihazin_adi
print "cihazdaki LLDP sayisi:",cihazdaki_lldp_sayisi
print "cihazin peer komsusu:",cihazdaki_komsuluk[2]['neighborDevice']
print "Port-channel100:", po100['result'][0]['interfaceStatuses']['Port-Channel100']['linkStatus']
list_neighbor_hostname=cihazdaki_komsuluk[2]['neighborDevice'].split("-")
list_neighbor_hostname_2= cihazdaki_komsuluk[3]['neighborDevice'].split("-")
except:
print "Veri Cekilemedi"
vericekme_problemiolanlar.append(i)
if po100['result'][0]['interfaceStatuses']['Port-Channel100']['linkStatus'] == "connected":
list_neighbor_hostname=cihazdaki_komsuluk[2]['neighborDevice'].split("-")
list_neighbor_hostname_2= cihazdaki_komsuluk[1]['neighborDevice'].split("-")
try:
if int(leafnumber[7])-int(list_neighbor_hostname[7])==1 or int(leafnumber[7])-int(list_neighbor_hostname[7])==-1:
print " 1. Mlag peer komsuluk dogru"
else:
print " 1.Mlag Peerde problem var"
Mlag_LLDP_Problemiolanlar.append(cihazin_adi)
except:
print "1.LLDPde hata var"
Mlag_LLDP_Problemiolanlar.append(cihazin_adi)
try:
if int(leafnumber[7])-int(list_neighbor_hostname_2[7])==1 or int(leafnumber[7])-int(list_neighbor_hostname_2[7])==-1:
print " 2. Mlag peer komsuluk dogru"
else:
print "2.Mlag Peerde Problem var"
Mlag_LLDP_Problemiolanlar.append(cihazin_adi)
except:
print "2.LLDPde hata var"
Mlag_LLDP_Problemiolanlar.append(cihazin_adi)
elif po100['result'][0]['interfaceStatuses']['Port-Channel100']['linkStatus'] != "connected":
print " Po100 da problem var"
Po100_Problemliolanlar.append(cihazin_adi)
print "LLDP KOMSULUKLARI"
for t in cihazdaki_komsuluk:
print t['neighborDevice'], ":", t['port']
print "BGP KOMSULUKLARI"
try:
for peer in bgppeer:
print peer,":",bgp['result'][0]['vrfs']['default']['peers'][peer]['peerState']
try:
if bgp['result'][0]['vrfs']['default']['peers'][peer]['peerState'] != "Established":
BGP_Problemiolanlar.append(cihazin_adi)
except:
BGP_Problemiolanlar.append(cihazin_adi)
print "Bgp peerlerde hata var"
except:
print "BGPde hata var"
BGP_Problemiolanlar.append(cihazin_adi)
print"***************************************"
print
print "Herhangi bir veri cekme problemi olan cihazlar:",vericekme_problemiolanlar
print "PO100 Problemi olanlar:",Po100_Problemliolanlar
print "Mlag LLDP Problemi olanlar:",Mlag_LLDP_Problemiolanlar
print "BGP Problemi olanlar:",BGP_Problemiolanlar