-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-ospf
60 lines (53 loc) · 2.2 KB
/
check-ospf
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
# Check OSPF Network from site A
:local DeviceName [/system identity get name]
:local add1 "172.17.0.1" # site B
:local add2 "172.17.20.2" # site C
:local inS "V2"
/routing ospf neighbor
:if ([:len [find ((address=$add1) and (state="Full")) ]] > 0) do={
:log info "[OSPF] neighbor to SiteB is UP"
} else={
:log info "[OSPF] neighbor to SiteB is DOWN"
# START Send Telegram Module
:local MessageText "\E2\9A\A0 $DeviceName: [OSPF] neighbor to SiteB is DOWN"
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
$SendTelegramMessage MessageText=$MessageText
# END Send Telegram Module
:delay 10s
# Reset OSPF
/routing ospf instance
set [find name=$inS] disabled=yes; :delay 2s; set [find name=$inS] disabled=no
# We check again if OSPF has recovered
:delay 60
:if ([:len [find ((address=$add1) and (state="Full")) ]] > 0) do={
# START Send Telegram Module
:local MessageText "\E2\9C\85 $DeviceName: [OSPF] neighbor to SiteB has recovered"
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
$SendTelegramMessage MessageText=$MessageText
# END Send Telegram Module
}
}
/routing ospf neighbor
:if ([:len [find ((address=$add2) and (state="Full")) ]] > 0) do={
:log info "[OSPF] neighbor to SiteC is UP"
} else={
:log info "[OSPF] neighbor to SiteC is DOWN"
# START Send Telegram Module
:local MessageText "\E2\9A\A0 $DeviceName: [OSPF] neighbor to SiteC is DOWN"
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
$SendTelegramMessage MessageText=$MessageText
# END Send Telegram Module
:delay 10s
# Reset OSPF
/routing ospf instance
set [find name=$inS] disabled=yes; :delay 2s; set [find name=$inS] disabled=no
# We check again if OSPF has recovered
:delay 60
:if ([:len [find ((address=$add2) and (state="Full")) ]] > 0) do={
# START Send Telegram Module
:local MessageText "\E2\9C\85 $DeviceName: [OSPF] neighbor to SiteC has recovered"
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
$SendTelegramMessage MessageText=$MessageText
# END Send Telegram Module
}
}