lte-failover-monitor.py
Network failover script between the Quectel LTE modem and 915 MHz Wi-Fi HaLow.
The HL9 has two critical wireless interfaces: LTE Cat 1 bis and Wi-Fi HaLow. This script uses RouterOS CLI commands to check interface status. It is designed to be scheduled (scheduler) every minute. In case of HaLow signal loss, it attempts to restart the LTE connection to ensure service continuity for asset tracking.
lte-failover-monitor.py
#!/bin/bash
# Script de monitoring LTE/Wi-Fi HaLow pour KNOT HL9
# À exécuter via le planificateur RouterOS (System > Scheduler)
# Vérifier si l'interface LTE est active
LTE_STATUS=$(/ip neighbor print where interface=lte1 | grep "status" | awk '{print $3}')
if [ "$LTE_STATUS" != "active" ]; then
echo "LTE inactive, vérification du Wi-Fi HaLow..."
# Vérifier le lien HaLow (interface radio 915MHz)
HALOW_STATUS=$(/interface wireless print where name=halow-radio | grep "status" | awk '{print $3}')
if [ "$HALOW_STATUS" != "running" ]; then
# Forcer une reconnexion LTE via AT command si nécessaire
/interface lte set lte1 apn="internet"
/interface lte restart lte1
logger warning "Reconnexion LTE forcée suite à échec HaLow"
else
logger info "Utilisation du Wi-Fi HaLow comme fallback"
fi
else
logger info "Connexion LTE stable"
fi