|
@@ -15,6 +15,7 @@ class base(object):
|
15
|
15
|
MONITORING_HEARTBEAT = "heartbeat"
|
16
|
16
|
MONITORING_BATTERY = "battery"
|
17
|
17
|
MONITORING_FOLLOW_SETPOINT = "follow_setpoint"
|
|
18
|
+ MONITORING_LINKQUALITY = "linkquality"
|
18
|
19
|
#
|
19
|
20
|
FOLLOW_REQUEST_WARNING = 5 # Seconds, till warning comes up, if device does not follow the command
|
20
|
21
|
FOLLOW_REQUEST_ERROR = 60 # Seconds, till error comes up, if device does not follow the command
|
|
@@ -23,6 +24,9 @@ class base(object):
|
23
|
24
|
BATTERY_LVL_WARNING = 15
|
24
|
25
|
BATTERY_LVL_ERROR = 5
|
25
|
26
|
#
|
|
27
|
+ LINKQUALITY_WARNING = 50
|
|
28
|
+ LINKQUALITY_ERROR = 25
|
|
29
|
+ #
|
26
|
30
|
LAST_MSG_WARNING = 6 * 60 * 60
|
27
|
31
|
LAST_MSG_ERROR = 24 * 60 * 60
|
28
|
32
|
|
|
@@ -40,6 +44,7 @@ class base(object):
|
40
|
44
|
self.__state_storage__ = {}
|
41
|
45
|
#
|
42
|
46
|
self.battery = None
|
|
47
|
+ self.linkquality = None
|
43
|
48
|
|
44
|
49
|
def __rx__(self, client, userdata, message):
|
45
|
50
|
try:
|
|
@@ -66,6 +71,11 @@ class base(object):
|
66
|
71
|
#
|
67
|
72
|
if self.MONITORING_BATTERY in payload and message.topic == self.topic:
|
68
|
73
|
self.battery = payload[self.MONITORING_BATTERY]
|
|
74
|
+ #
|
|
75
|
+ # linkquality
|
|
76
|
+ #
|
|
77
|
+ if self.MONITORING_LINKQUALITY in payload and message.topic == self.topic:
|
|
78
|
+ self.linkquality = payload[self.MONITORING_LINKQUALITY]
|
69
|
79
|
|
70
|
80
|
def target(self, key, value):
|
71
|
81
|
tm_t, value_t = self.__target_storage__.get(key, (0, None))
|
|
@@ -126,6 +136,18 @@ class base(object):
|
126
|
136
|
return self.__nagios_return__(self.MONITORING_BATTERY, nagios.Nagios.WARNING, "Battery level low (%.1f%%)" % self.battery)
|
127
|
137
|
else:
|
128
|
138
|
return self.__nagios_return__(self.MONITORING_BATTERY, nagios.Nagios.OK, "Battery okay (%.1f%%)" % self.battery)
|
|
139
|
+ #
|
|
140
|
+ # LINKQUALITY
|
|
141
|
+ #
|
|
142
|
+ elif key == self.MONITORING_LINKQUALITY:
|
|
143
|
+ if self.linkquality is None:
|
|
144
|
+ return self.__nagios_return__(self.MONITORING_LINKQUALITY, nagios.Nagios.UNKNOWN, "Device exists, but no data received or unknown monitoring")
|
|
145
|
+ elif self.linkquality <= self.LINKQUALITY_ERROR:
|
|
146
|
+ return self.__nagios_return__(self.MONITORING_LINKQUALITY, nagios.Nagios.ERROR, "Linkquality critical low (%d)" % self.linkquality)
|
|
147
|
+ elif self.linkquality <= self.LINKQUALITY_WARNING:
|
|
148
|
+ return self.__nagios_return__(self.MONITORING_LINKQUALITY, nagios.Nagios.WARNING, "Linkquality level low (%d)" % self.linkquality)
|
|
149
|
+ else:
|
|
150
|
+ return self.__nagios_return__(self.MONITORING_LINKQUALITY, nagios.Nagios.OK, "Linkquality okay (%d)" % self.linkquality)
|
129
|
151
|
|
130
|
152
|
def __nagios_return__(self, monitoring_name, status, msg, force=False):
|
131
|
153
|
tm = time.time()
|