-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathumbrella_clouddns.py
56 lines (52 loc) · 1.94 KB
/
umbrella_clouddns.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
from .agent_based_api.v1 import (
contains,
startswith,
register,
render,
Metric,
OIDEnd,
Result,
Service,
SNMPTree,
State,
)
register.snmp_section(
name = "umbrellava_clouddns",
detect = startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.8072.3.2.10"),
fetch=SNMPTree(
base=".1.3.6.1.4.1.8072.1.3.2.4.1.2.3.100.110.115",
oids=[
'1', # UmbrellaDNSConnectionState
'2', # UmbrellaResolver2UDPlookup
'3', # UmbrellaResolver2TCPlookup
'4', # UmbrellaResolver1UDPlookup
'5', # UmbrellaResolver1TCPlookup
])
)
def check_umbrellava_clouddns(item, section):
for UmbrellaDNSConnectionState, UmbrellaResolver2UDPlookup,UmbrellaResolver2TCPlookup,UmbrellaResolver1UDPlookup, UmbrellaResolver1TCPlookup in section:
if "green" in UmbrellaDNSConnectionState:
state = State.OK
elif "yellow" in UmbrellaDNSConnectionState:
state = State.WARN
else:
state = State.CRIT
summary = (UmbrellaDNSConnectionState.split(':')[-1])
outputlist = [UmbrellaResolver2UDPlookup,UmbrellaResolver2TCPlookup,UmbrellaResolver1UDPlookup, UmbrellaResolver1TCPlookup]
for listitem in outputlist:
if listitem:
summary += ("," + listitem)
yield Result(
state = state,
summary = summary)
return
def discover_umbrellava_clouddns(section):
for UmbrellaDNSConnectionState, UmbrellaResolver2UDPlookup,UmbrellaResolver2TCPlookup,UmbrellaResolver1UDPlookup, UmbrellaResolver1TCPlookup in section:
servicename = UmbrellaDNSConnectionState[UmbrellaDNSConnectionState.find(':')+len(':'):UmbrellaDNSConnectionState.rfind(':')]
yield Service(item=servicename)
register.check_plugin(
name = "umbrellava_clouddns",
service_name = "UmbrellaVA %s",
discovery_function = discover_umbrellava_clouddns,
check_function = check_umbrellava_clouddns,
)