-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMerakiSkyPy.py
67 lines (61 loc) · 2.74 KB
/
MerakiSkyPy.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
import meraki
import time
from skpy import Skype
sk = Skype("xxxx@xx.xx", "xxxxx") # Your Skype email address and password
ch = sk.contacts["live:xxxxxx"].chat # A skype contact name which is going to receive the notification
OfficeStatus = {}
APStatus = {}
OldStatus=[]
dashboard = meraki.DashboardAPI("xxxxxxxxxxxxxxxxxxxxxx")#Your API key
SecurityDevices_OrgID="xxxxxxxxxxxxxxxxx" #Your Security Devices organization ID
WirelessDevices_OrgID="xxxxxxxxxxxxxxxxxxxxxx" #Your Wireless Devices organization ID
#Get Security Devices status
def getOfficeStatus():
Office_Status = dashboard.organizations.getOrganizationDevicesStatuses(
SecurityDevices_OrgID, total_pages='all')
for item in Office_Status:
OfficeName=item['name']
OfficeStatus[OfficeName]= item['status']
return OfficeStatus
#Get Wireless Devices status
def getAPsStatus():
AP_Status = dashboard.organizations.getOrganizationDevicesStatuses(
WirelessDevices_OrgID, total_pages='all')
for item in AP_Status:
APName=item['name']
APStatus[APName]= item['status']
return APStatus
def getStatus():
try:
print("Scanning Security Devices")
Offices_Status=getOfficeStatus()
for x, y in Offices_Status.items():
if(y=="offline"):
if(not(x + " is "+ y) in OldStatus):
OldStatus.append(x + " is "+ y)
print(x + " is "+ y)
ch.sendMsg(x + " is "+ y)
else:
if((x + " is offline") in OldStatus):
ch.sendMsg(x + " is back "+ y)
OldStatus.remove((x + " is offline"))
time.sleep(60)
time.sleep(30)
print("Scanning Wireless Devices")
APs_Status=getAPsStatus()
for i, j in APs_Status.items():
if(j=="offline"):
if(not(i + " is "+ j) in OldStatus):
OldStatus.append(i + " is "+ j)
print(i + " is "+ j)
ch.sendMsg(i + " is "+ j)
else:
if((i + " is offline") in OldStatus):
ch.sendMsg(i + " is back "+ j)
OldStatus.remove((i + " is offline"))
return OldStatus
except:
print("Request timeout------waiting for 60 seconds")
while True:
getStatus()
time.sleep(120)