BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
plugin.healthcheck_watchdog.BoswatchPlugin Class Reference

Public Member Functions

 __init__ (self, config)
 Do not change anything here!
 
 onLoad (self)
 Called by import of the plugin.
 
 setup (self)
 Called before alarm.
 
 fms (self, bwPacket)
 Called on FMS alarm.
 
 pocsag (self, bwPacket)
 Called on POCSAG alarm.
 
 zvei (self, bwPacket)
 Called on ZVEI alarm.
 
 msg (self, bwPacket)
 Called on MSG packet.
 
 teardown (self)
 Called after alarm Remove if not implemented.
 
 onUnload (self)
 Called by destruction of the plugin Remove if not implemented.
 
- Public Member Functions inherited from plugin.pluginBase.PluginBase
 parseWildcards (self, msg)
 Return the message with parsed wildcards.
 

Data Fields

 timer
 
 timeout
 
 url
 
- Data Fields inherited from plugin.pluginBase.PluginBase
 config
 

Protected Member Functions

 _reset_watchdog (self)
 
 _on_timeout (self)
 
 _send_ping (self)
 
- Protected Member Functions inherited from plugin.pluginBase.PluginBase
 _cleanup (self)
 Cleanup routine calls onUnload() directly.
 
 _run (self, bwPacket)
 start an complete running turn of an plugin.
 
 _getStatistics (self)
 Returns statistical information's from last plugin run.
 

Additional Inherited Members

- Protected Attributes inherited from plugin.pluginBase.PluginBase
 _pluginName
 
 _bwPacket
 
 _sumTime
 
 _cumTime
 
 _setupTime
 
 _alarmTime
 
 _teardownTime
 
 _runCount
 
 _setupErrorCount
 
 _alarmErrorCount
 
 _teardownErrorCount
 
- Static Protected Attributes inherited from plugin.pluginBase.PluginBase
list _pluginsActive = []
 

Detailed Description

Überwachung der Log-Aktivität via Healthchecks.io

Constructor & Destructor Documentation

◆ __init__()

plugin.healthcheck_watchdog.BoswatchPlugin.__init__ (   self,
  config 
)

Do not change anything here!

Reimplemented from plugin.pluginBase.PluginBase.

32 def __init__(self, config):
33 r"""!Do not change anything here!"""
34 super().__init__(__name__, config) # you can access the config class on 'self.config'
35

Member Function Documentation

◆ _reset_watchdog()

plugin.healthcheck_watchdog.BoswatchPlugin._reset_watchdog (   self)
protected
Stoppt den aktuellen Timer und startet einen neuen
36 def _reset_watchdog(self):
37 """Stoppt den aktuellen Timer und startet einen neuen"""
38 if self.timer:
39 self.timer.cancel()
40
41 self.timer = threading.Timer(self.timeout, self._on_timeout)
42 self.timer.daemon = True # Damit der Thread BOSWatch nicht am Beenden hindert
43 self.timer.start()
44

◆ _on_timeout()

plugin.healthcheck_watchdog.BoswatchPlugin._on_timeout (   self)
protected
Wird aufgerufen, wenn x Sekunden lang kein Paket kam
45 def _on_timeout(self):
46 """Wird aufgerufen, wenn x Sekunden lang kein Paket kam"""
47 logging.warning("WATCHDOG: Seit %s Sekunden keine Aktivität! Sende KEIN Signal.", self.timeout)
48 # Wir senden hier absichtlich NICHTS an Healthchecks.io.
49 # Healthchecks.io schlägt Alarm, weil der regelmäßige "Ping" ausbleibt.
50

◆ _send_ping()

plugin.healthcheck_watchdog.BoswatchPlugin._send_ping (   self)
protected
Sendet den 'Alles OK' Ping an Healthchecks.io
51 def _send_ping(self):
52 """Sendet den 'Alles OK' Ping an Healthchecks.io"""
53 try:
54 requests.get(self.url, timeout=10)
55 logging.debug("WATCHDOG: Ping an Healthchecks.io gesendet.")
56 except Exception as e:
57 logging.error("WATCHDOG: Fehler beim Ping: %s", e)
58

◆ onLoad()

plugin.healthcheck_watchdog.BoswatchPlugin.onLoad (   self)

Called by import of the plugin.

Reimplemented from plugin.pluginBase.PluginBase.

59 def onLoad(self):
60 r"""!Called by import of the plugin"""
61 self.timer = None
62 # Konfiguration aus der yaml laden
63 self.url = self.config.get("ping_url")
64 # Standard: 125 Sekunden (2 Min 5 Sek)
65 self.timeout = int(self.config.get("timeout", default=125))
66 pass
67

◆ setup()

plugin.healthcheck_watchdog.BoswatchPlugin.setup (   self)

Called before alarm.

Reimplemented from plugin.pluginBase.PluginBase.

68 def setup(self):
69 r"""!Called before alarm"""
70 self._reset_watchdog()
71 pass
72

◆ fms()

plugin.healthcheck_watchdog.BoswatchPlugin.fms (   self,
  bwPacket 
)

Called on FMS alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

73 def fms(self, bwPacket):
74 r"""!Called on FMS alarm
75
76 @param bwPacket: bwPacket instance
77 Remove if not implemented"""
78 self._send_ping()
79 self._reset_watchdog()
80 pass
81

◆ pocsag()

plugin.healthcheck_watchdog.BoswatchPlugin.pocsag (   self,
  bwPacket 
)

Called on POCSAG alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

82 def pocsag(self, bwPacket):
83 r"""!Called on POCSAG alarm
84
85 @param bwPacket: bwPacket instance
86 Remove if not implemented"""
87 self._send_ping()
88 self._reset_watchdog()
89 pass
90

◆ zvei()

plugin.healthcheck_watchdog.BoswatchPlugin.zvei (   self,
  bwPacket 
)

Called on ZVEI alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

91 def zvei(self, bwPacket):
92 r"""!Called on ZVEI alarm
93
94 @param bwPacket: bwPacket instance
95 Remove if not implemented"""
96 self._send_ping()
97 self._reset_watchdog()
98 pass
99

◆ msg()

plugin.healthcheck_watchdog.BoswatchPlugin.msg (   self,
  bwPacket 
)

Called on MSG packet.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

100 def msg(self, bwPacket):
101 r"""!Called on MSG packet
102
103 @param bwPacket: bwPacket instance
104 Remove if not implemented"""
105 self._send_ping()
106 self._reset_watchdog()
107 pass
108

◆ teardown()

plugin.healthcheck_watchdog.BoswatchPlugin.teardown (   self)

Called after alarm Remove if not implemented.

Reimplemented from plugin.pluginBase.PluginBase.

109 def teardown(self):
110 r"""!Called after alarm
111 Remove if not implemented"""
112 pass
113

◆ onUnload()

plugin.healthcheck_watchdog.BoswatchPlugin.onUnload (   self)

Called by destruction of the plugin Remove if not implemented.

Reimplemented from plugin.pluginBase.PluginBase.

114 def onUnload(self):
115 r"""!Called by destruction of the plugin
116 Remove if not implemented"""
117 if self.timer:
118 self.timer.cancel()
119 pass

Field Documentation

◆ timer

plugin.healthcheck_watchdog.BoswatchPlugin.timer

◆ timeout

plugin.healthcheck_watchdog.BoswatchPlugin.timeout

◆ url

plugin.healthcheck_watchdog.BoswatchPlugin.url