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)
 
 _do_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 threading.Thread(
54 target=self._do_ping,
55 daemon=True
56 ).start()
57

◆ _do_ping()

plugin.healthcheck_watchdog.BoswatchPlugin._do_ping (   self)
protected
Worker: führt den eigentlichen HTTP-Request aus
58 def _do_ping(self):
59 """Worker: führt den eigentlichen HTTP-Request aus"""
60 try:
61 requests.get(self.url, timeout=10)
62 logging.debug("WATCHDOG: Ping an Healthchecks.io gesendet.")
63 except Exception as e:
64 logging.error("WATCHDOG: Fehler beim Ping: %s", e)
65

◆ onLoad()

plugin.healthcheck_watchdog.BoswatchPlugin.onLoad (   self)

Called by import of the plugin.

Reimplemented from plugin.pluginBase.PluginBase.

66 def onLoad(self):
67 r"""!Called by import of the plugin"""
68 self.timer = None
69 # Konfiguration aus der yaml laden
70 self.url = self.config.get("ping_url")
71 # Standard: 125 Sekunden (2 Min 5 Sek)
72 self.timeout = int(self.config.get("timeout", default=125))
73 pass
74

◆ setup()

plugin.healthcheck_watchdog.BoswatchPlugin.setup (   self)

Called before alarm.

Reimplemented from plugin.pluginBase.PluginBase.

75 def setup(self):
76 r"""!Called before alarm"""
77 self._reset_watchdog()
78 pass
79

◆ fms()

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

Called on FMS alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

80 def fms(self, bwPacket):
81 r"""!Called on FMS alarm
82
83 @param bwPacket: bwPacket instance
84 Remove if not implemented"""
85 self._send_ping()
86 self._reset_watchdog()
87 pass
88

◆ pocsag()

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

Called on POCSAG alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

89 def pocsag(self, bwPacket):
90 r"""!Called on POCSAG alarm
91
92 @param bwPacket: bwPacket instance
93 Remove if not implemented"""
94 self._send_ping()
95 self._reset_watchdog()
96 pass
97

◆ zvei()

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

Called on ZVEI alarm.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

98 def zvei(self, bwPacket):
99 r"""!Called on ZVEI alarm
100
101 @param bwPacket: bwPacket instance
102 Remove if not implemented"""
103 self._send_ping()
104 self._reset_watchdog()
105 pass
106

◆ msg()

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

Called on MSG packet.

Parameters
bwPacketbwPacket instance Remove if not implemented

Reimplemented from plugin.pluginBase.PluginBase.

107 def msg(self, bwPacket):
108 r"""!Called on MSG packet
109
110 @param bwPacket: bwPacket instance
111 Remove if not implemented"""
112 self._send_ping()
113 self._reset_watchdog()
114 pass
115

◆ teardown()

plugin.healthcheck_watchdog.BoswatchPlugin.teardown (   self)

Called after alarm Remove if not implemented.

Reimplemented from plugin.pluginBase.PluginBase.

116 def teardown(self):
117 r"""!Called after alarm
118 Remove if not implemented"""
119 pass
120

◆ onUnload()

plugin.healthcheck_watchdog.BoswatchPlugin.onUnload (   self)

Called by destruction of the plugin Remove if not implemented.

Reimplemented from plugin.pluginBase.PluginBase.

121 def onUnload(self):
122 r"""!Called by destruction of the plugin
123 Remove if not implemented"""
124 if self.timer:
125 self.timer.cancel()
126 pass

Field Documentation

◆ timer

plugin.healthcheck_watchdog.BoswatchPlugin.timer

◆ timeout

plugin.healthcheck_watchdog.BoswatchPlugin.timeout

◆ url

plugin.healthcheck_watchdog.BoswatchPlugin.url