Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Next revisionBoth sides next revision | ||
monitors:submqttm [2020/11/07 21:06] – created wnelis | monitors:submqttm [2020/11/13 12:43] – [Installation] wnelis | ||
---|---|---|---|
Line 11: | Line 11: | ||
- | Script submqttm.py is a skeleton for one or more Xymon tests, which receive their measurements via MQTT. An abstract class XymonTest is defined, which handles the receipt of the topics, the detection that all required information is received, and the transmission of the Xymon message to the Xymon server. Per Xymon test a derived class needs to be defined, containing (at least) method BuildMessage, | + | Script submqttm.py |
- | As distributed, | + | As distributed, |
+ | This script was developed to handle multiple small, low power sensors based on an ESP8266 micro-controller. As multiple destinations for the collected data are expected, and as MQTT provides for a simple transfer and distribution mechanism, these micro-controllers publish their measurements using MQTT. | ||
===== Installation ===== | ===== Installation ===== | ||
=== Client side === | === Client side === | ||
- | Source | + | The source |
- | Continuously | + | |
- | Tests with mode ' | + | Service submqttm is defined by creating a file named / |
+ | < | ||
+ | [Unit] | ||
+ | Description=Xymon client with MQTT input | ||
+ | |||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=xymon | ||
+ | Group=xymon | ||
+ | ExecStart=/ | ||
+ | WorkingDirectory=/ | ||
+ | StandardOutput=null | ||
+ | StandardError=null | ||
+ | Restart=on-abort | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Once file submqttm.service is created, the following two commands are needed to activate the script: | ||
+ | < | ||
+ | sudo systemctl start submqttm | ||
+ | sudo systemctl enable submqttm | ||
+ | </ | ||
+ | |||
+ | Note that though the script is running continuously, | ||
=== Server side === | === Server side === | ||
- | xymonserver.cfg | + | For the initial client, which monitors the throughput of one MQTT broker, two extensions of the xymon server configuration are needed. First, |
- | graphs.cfg | + | |
+ | < | ||
+ | TEST2RRD+=", | ||
+ | GRAPHS_mqtt=" | ||
+ | </ | ||
+ | |||
+ | Secondly, | ||
+ | |||
+ | < | ||
+ | [mqtttm] | ||
+ | TITLE , MQTT message rate | ||
+ | YAXIS Throughput [p/s] | ||
+ | -l 0 | ||
+ | DEF: | ||
+ | DEF: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | |||
+ | [mqttto] | ||
+ | TITLE , MQTT bit rate | ||
+ | YAXIS Throughput [b/s] | ||
+ | -l 0 | ||
+ | DEF: | ||
+ | DEF: | ||
+ | CDEF: | ||
+ | CDEF: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | LINE1: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | GPRINT: | ||
+ | </ | ||
+ | |||
+ | A small note: typically I'll end each TITLE-line with two spaces. This results in a bigger separation between the title and the date-range, which improves the readability of the top line in the graph. Those two trailing spaces are missing in the above definition of the graphs. | ||
===== Source ===== | ===== Source ===== | ||
Line 95: | Line 168: | ||
# Throughput statistics of the MQTT broker | # Throughput statistics of the MQTT broker | ||
{ ' | { ' | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 103: | Line 176: | ||
), | ), | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 177: | Line 250: | ||
syslog.syslog ( ' ' | syslog.syslog ( ' ' | ||
syslog.closelog() | syslog.closelog() | ||
+ | |||
+ | def join( self, TimeOut=None ): | ||
+ | self.stop() | ||
+ | super().join( TimeOut ) | ||
def stop( self ): | def stop( self ): | ||
Line 289: | Line 366: | ||
# | # | ||
- | # Method InformXymon takes a formatted message for the xymon server, prepends | + | # Method InformXymon takes a formatted message for the Xymon server, prepends |
# the status message header and sends the resulting message to the Xymon | # the status message header and sends the resulting message to the Xymon | ||
# server. The method returns True if sending the message succeeded, otherwise | # server. The method returns True if sending the message succeeded, otherwise | ||
Line 635: | Line 712: | ||
</ | </ | ||
- | Module watchdog.py | + | ==== watchdog.py ==== |
+ | |||
+ | Module watchdog.py | ||
<hidden onHidden=" | <hidden onHidden=" |