packages/fff: Add package fff-mqtt-monitoring

This package allows to publish monitoring data from alfred
to the mqtt broker.

Anyone can access this data and can build its own monitoring.

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
Acked-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Christian Dresel 2020-12-19 11:01:56 +01:00 committed by Fabian Bläse
parent 7afe5fd767
commit 9090702580
4 changed files with 45 additions and 0 deletions

View File

@ -15,6 +15,7 @@ define Package/fff-layer3
+fff-boardname \
+fff-dhcp \
+fff-layer3-config \
+fff-mqtt-monitoring \
+fff-network \
+fff-ra \
+fff-wireguard \

View File

@ -0,0 +1,35 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-mqtt-monitoring
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-mqtt-monitoring
include $(INCLUDE_DIR)/package.mk
define Package/fff-mqtt-monitoring
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken mqtt configuration
URL:=https://www.freifunk-franken.de
DEPENDS:= \
+alfred-json \
+fff-mqtt \
+micrond \
+fff-alfred
endef
define Package/fff-mqtt-monitoring/description
This package send monitoring informations to
the mqtt broker
endef
define Build/Compile
# nothing
endef
define Package/fff-mqtt-monitoring/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-mqtt-monitoring))

View File

@ -0,0 +1 @@
*/5 * * * * sleep $(/usr/bin/random 70 85); /usr/sbin/alfred-mqtt-proxy

View File

@ -0,0 +1,8 @@
#!/bin/sh
MACADDR=$(cat /sys/class/net/br-client/address | /bin/sed 's/://g')
fetch_id="64"
if [ -n "$(uci -q get fff.mqtt.server)" ] ; then
mosquitto_pub -h "$(uci get fff.mqtt.server)" -p 1883 -t /monitoring/v1/$MACADDR -m "$(/bin/alfred-json -r "$fetch_id")"
fi