public:projects:monitoring
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| public:projects:monitoring [2026/06/10 20:28] – ↷ Page moved from members:projects:monitoring to public:projects:monitoring admin2 | public:projects:monitoring [2026/06/10 20:29] (current) – ↷ Links adapted because of a move operation admin2 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Monitoring ====== | ||
| + | |||
| + | ===== Overview ===== | ||
| + | |||
| + | There is a Raspberry Pi running: | ||
| + | |||
| + | * home page to list services (http:// | ||
| + | * Packaged Software | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * Custom-made Software | ||
| + | * MQTT listener which posts to InfluxDB ([[https:// | ||
| + | * several ESP8266/etc sending data to MQTT ([[https:// | ||
| + | * Shelly Pro 3EM Prometheus exporter ([[https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Code ===== | ||
| + | |||
| + | * generic ESP8266 C++ code for sensors to send measurements to MQTT | ||
| + | * https:// | ||
| + | * MQTT to InfluxDB listener (on Pi) | ||
| + | * https:// | ||
| + | |||
| + | ===== Sensors ===== | ||
| + | |||
| + | ==== MQTT Message Format ==== | ||
| + | |||
| + | any environment monitoring MQTT message that looks like " | ||
| + | |||
| + | SHHNoT/ | ||
| + | |||
| + | e.g., | ||
| + | |||
| + | SHHNoT/ | ||
| + | |||
| + | ==== Measurements ==== | ||
| + | |||
| + | All sensors should broadcast the measurements: | ||
| + | |||
| + | * a special " | ||
| + | * data they measure (e.g., " | ||
| + | * RSSI WiFi strength | ||
| + | |||
| + | an example payload for a single device could be: | ||
| + | |||
| + | SHHNoT/ | ||
| + | SHHNoT/ | ||
| + | SHHNoT/ | ||
| + | SHHNoT/ | ||
| + | |||
| + | ==== Sensors in use ==== | ||
| + | |||
| + | 1. SCD40 (CO2/ | ||
| + | |||
| + | {{public: | ||
| + | |||
| + | 2. SCD40 (CO2/ | ||
| + | |||
| + | (the red wire goes from D5/GPIO14) | ||
| + | |||
| + | {{public: | ||
| + | |||
| + | 3. SDS011 (particulate matter – PM2.5 and PM10) | ||
| + | |||
| + | {{public: | ||
| + | |||
| + | ===== Brother exporter ===== | ||
| + | |||
| + | setup: | ||
| + | |||
| + | < | ||
| + | # install | ||
| + | git clone https:// | ||
| + | # build | ||
| + | go mod download | ||
| + | VERSION=${VERSION: | ||
| + | COMMIT=${COMMIT: | ||
| + | BUILD_DATE=${BUILD_DATE: | ||
| + | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -ldflags=" | ||
| + | -X github.com/ | ||
| + | -X github.com/ | ||
| + | -X github.com/ | ||
| + | -o brother-exporter ./ | ||
| + | |||
| + | # config | ||
| + | cp config.example.yaml config.yaml | ||
| + | sed ' | ||
| + | |||
| + | # service file | ||
| + | cat << EOUFILE | sudo tee / | ||
| + | [Unit] | ||
| + | Description=Brother Printer Exporter | ||
| + | Documentation=https:// | ||
| + | After=network-online.target | ||
| + | |||
| + | [Service] | ||
| + | Type=simple | ||
| + | User=prometheus | ||
| + | Group=prometheus | ||
| + | Restart=on-failure | ||
| + | RestartSec=10 | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | EOUFILE | ||
| + | sudo systemctl enable brother-exporter.service | ||
| + | sudo systemctl start brother-exporter.service | ||
| + | sudo systemctl status brother-exporter.service | ||
| + | |||
| + | # test | ||
| + | curl http:// | ||
| + | </ | ||
| + | |||
| + | ===== Mothership ===== | ||
| + | |||
| + | To install InfluxDB and Grafana on the Raspberry Pi, run something like: | ||
| + | |||
| + | # add users | ||
| + | sudo useradd -r -s /bin/false influxdb | ||
| + | sudo useradd -r -s /bin/false grafana | ||
| + | sudo useradd -r -s /bin/false mqttlistener | ||
| + | sudo useradd -r -s /bin/false prometheus | ||
| + | | ||
| + | # create folders | ||
| + | mkdir -p / | ||
| + | mkdir -p / | ||
| + | |||
| + | # install influxdb | ||
| + | sudo apt update | ||
| + | sudo apt upgrade | ||
| + | curl https:// | ||
| + | echo "deb [signed-by=/ | ||
| + | sudo apt update | ||
| + | sudo apt install influxdb2 | ||
| + | sudo systemctl status influxdb.service | ||
| + | | ||
| + | # install grafana | ||
| + | sudo apt-get install -y apt-transport-https software-properties-common wget | ||
| + | sudo mkdir -p / | ||
| + | wget -q -O - https:// | ||
| + | echo "deb [signed-by=/ | ||
| + | sudo apt-get update | ||
| + | sudo apt-get install grafana | ||
| + | |||
| + | # install prometheus | ||
| + | cd /usr/shhm/ | ||
| + | wget https:// | ||
| + | tar -xzf prometheus-2.53.5.linux-arm64.tar.gz | ||
| + | rm prometheus-2.53.5.linux-arm64.tar.gz | ||
| + | mv prometheus-2.53.5.linux-arm64 prometheus | ||
| + | sudo chown -R prometheus: | ||
| + | cat << EOUFILE | sudo tee / | ||
| + | [Unit] | ||
| + | Description=Prometheus Server | ||
| + | Documentation=https:// | ||
| + | After=network-online.target | ||
| + | | ||
| + | [Service] | ||
| + | User=prometheus | ||
| + | Group=prometheus | ||
| + | Restart=on-failure | ||
| + | RestartSec=10 | ||
| + | ExecStart=/ | ||
| + | --config.file=/ | ||
| + | --storage.tsdb.path=/ | ||
| + | --storage.tsdb.retention.time=30d | ||
| + | | ||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | EOUFILE | ||
| + | sudo systemctl enable prometheus.service | ||
| + | sudo systemctl start prometheus.service | ||
| + | sudo systemctl status prometheus.service | ||
| + | | ||
| + | # install node_exporter | ||
| + | cd /usr/shhm/ | ||
| + | wget https:// | ||
| + | tar -xzf node_exporter-1.9.1.linux-arm64.tar.gz | ||
| + | rm node_exporter-1.9.1.linux-arm64.tar.gz | ||
| + | mv node_exporter-1.9.1.linux-arm64 node_exporter | ||
| + | sudo chown -R prometheus: | ||
| + | cat << EOUFILE | sudo tee / | ||
| + | [Unit] | ||
| + | Description=Node Exporter for Prometheus | ||
| + | After=network.target | ||
| + | | ||
| + | [Service] | ||
| + | Type=simple | ||
| + | User=prometheus | ||
| + | Group=users | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | Restart=on-failure | ||
| + | RestartSec=10 | ||
| + | | ||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | EOUFILE | ||
| + | sudo systemctl enable node_exporter.service | ||
| + | sudo systemctl start node_exporter.service | ||
| + | sudo systemctl status node_exporter.service | ||
| + | |||
