Skip to content

pljakobs/rgbww-monitoring-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 RGBWW IoT Device Monitoring System

A comprehensive monitoring solution for RGBWW IoT devices with automatic network discovery, Prometheus metrics collection, and Grafana dashboards.

✨ Features

  • πŸ” Automatic Device Discovery: Network topology crawling via /hosts endpoints
  • πŸ”‘ Stable Device IDs: Uses device IDs as primary keys for consistent metrics
  • πŸ“Š Prometheus Integration: Collects metrics from device /info endpoints
  • πŸ“ˆ Grafana Dashboards: Pre-configured dashboards for monitoring and visualization
  • 🌐 Network Topology Mapping: Discovers entire device networks automatically
  • ⚑ Automated Scheduling: 30-minute discovery intervals
  • πŸ“¦ Multiple Deployment Options: Native installation or containerized

πŸš€ Quick Start

Option 1: Native Installation (Recommended for LXC/Limited Environments)

cd native-install/
sudo ./install.sh

Option 2: Containerized (Docker/Podman)

cd containerized/
export INITIAL_CONTROLLER_IP=192.168.1.100  # Your IoT device IP
./rgbww-monitor.sh start

πŸ“Š What You Get

Monitored Metrics

Metric Description Labels
device_info Static device information deviceid, device_name, current_rom, git_version, ip
device_uptime_seconds Device uptime in seconds deviceid
device_heap_free_bytes Available heap memory deviceid
device_connected Connection status (1=online, 0=offline) deviceid

Pre-configured Dashboards

  • πŸ“‹ Device Overview: Complete inventory with status, memory, uptime
  • πŸ—ΊοΈ Network Topology: Geographic and network visualization
  • πŸ“ˆ Historical Trends: Time-series analysis of device metrics
  • ⚠️ Alerting: Built-in alerts for offline devices and low memory

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   IoT Devices   β”‚    β”‚   JSON Exporter  β”‚    β”‚   Prometheus    β”‚
β”‚                 β”‚    β”‚                  β”‚    β”‚                 β”‚
β”‚ /info endpoint  │◄──── Queries devices  │◄──── Scrapes metrics β”‚
β”‚ /config endpointβ”‚    β”‚ Converts JSON    β”‚    β”‚ Stores data     β”‚
β”‚ /hosts endpoint β”‚    β”‚ to metrics       β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–²                        β–²                        β–²
         β”‚                        β”‚                        β”‚
         └────────────────────────┴────────────────────────┴──────┐
                            Discovery Script (30min timer)         β”‚
                                                                   β–Ό
                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                    β”‚    Grafana      β”‚
                                                    β”‚   Dashboards    β”‚
                                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

rgbww-monitoring-project/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ LICENSE                      # MIT License
β”œβ”€β”€ CHANGELOG.md                 # Version history
β”œβ”€β”€ native-install/              # Native system installation
β”‚   β”œβ”€β”€ install.sh              # One-command installer
β”‚   β”œβ”€β”€ uninstall.sh            # Complete removal
β”‚   β”œβ”€β”€ config/                 # Configuration files
β”‚   β”œβ”€β”€ systemd/                # Service definitions
β”‚   └── scripts/                # Management scripts
└── containerized/              # Docker/Podman deployment
    β”œβ”€β”€ docker-compose.yml      # Multi-service orchestration
    β”œβ”€β”€ rgbww-monitor.sh        # Container management script
    β”œβ”€β”€ prometheus/             # Custom Prometheus image
    β”œβ”€β”€ json-exporter/          # JSON Exporter image
    └── grafana/                # Grafana with dashboards

πŸ”§ Device Discovery

How It Works

  1. Initial Seed: Starts with one known device IP or network scan
  2. Topology Crawling: Queries /hosts endpoint on each discovered device
  3. Multi-Round Discovery: Continues until no new devices are found
  4. Metadata Collection: Fetches device names from /config endpoint
  5. Stable Identification: Uses device IDs from /info as primary keys

Device Endpoints

Endpoint Purpose Data Extracted
/info Device status uptime, heap_free, deviceid, current_rom, git_version
/config Device configuration device_name
/hosts Network topology IP addresses of connected devices

πŸ› οΈ Installation Guide

Prerequisites

For Native Installation:

  • Linux system with systemd
  • Root access
  • Network access to IoT devices
  • Dependencies: curl, jq (auto-installed)

For Containerized:

  • Docker or Podman with docker-compose
  • Ports 3000, 7979, 9090 available
  • Initial controller IP or network range

Native Installation

# Clone the repository
git clone https://github.com/your-username/rgbww-monitoring.git
cd rgbww-monitoring/native-install/

# Run installer
sudo ./install.sh

# Check status
sudo systemctl status json_exporter iot-discovery.timer

Containerized Installation

# Clone and setup
git clone https://github.com/your-username/rgbww-monitoring.git
cd rgbww-monitoring/containerized/

# Configure initial controller
export INITIAL_CONTROLLER_IP=192.168.1.100

# Start stack
./rgbww-monitor.sh start

# Access Grafana: http://localhost:3000 (admin/rgbww123)

πŸ“ˆ Usage Examples

Manual Device Management

# Add device manually
sudo /etc/prometheus/manage-iot-devices.sh add 192.168.1.100

# Discover all devices from one known device
sudo /etc/prometheus/manage-iot-devices.sh discover 192.168.1.100

# List all discovered devices
sudo /etc/prometheus/manage-iot-devices.sh list

# Check system status
sudo /etc/prometheus/iot-status.sh

Prometheus Queries

# Devices with low memory
device_heap_free_bytes < 10240

# Average uptime by ROM version
avg by (current_rom) (device_uptime_seconds)

# Device connectivity over time
rate(device_connected[5m])

# Count devices by network
count by (ip) (device_info)

πŸ” Troubleshooting

Common Issues

No devices discovered:

  • Check network connectivity: curl http://<device-ip>/info
  • Verify initial controller IP is reachable
  • Check discovery logs: journalctl -u iot-discovery.service

JSON Exporter not working:

  • Test configuration: systemctl status json_exporter
  • Check device endpoints return valid JSON
  • Verify port 7979 is accessible

Grafana dashboards not loading:

  • Check Prometheus connection in Grafana data sources
  • Verify metrics are being collected: curl http://localhost:9090/api/v1/query?query=device_info

Log Locations

  • Discovery: journalctl -u iot-discovery.service
  • JSON Exporter: journalctl -u json_exporter
  • Prometheus: journalctl -u prometheus
  • Installation: /tmp/rgbww-install.log

🎨 Customization

Adding Custom Metrics

Edit /etc/prometheus/json_exporter.yml to extract additional fields from device endpoints.

Custom Dashboards

  1. Create dashboard in Grafana
  2. Export JSON
  3. Save to grafana/dashboards/ directory
  4. Restart Grafana

Discovery Interval

# Change discovery frequency
sudo systemctl edit iot-discovery.timer

# Add:
[Timer]
OnCalendar=
OnCalendar=*:0/15  # Every 15 minutes

πŸš€ Production Deployment

Security Recommendations

  • Change default Grafana password
  • Configure HTTPS/TLS certificates
  • Set up authentication (LDAP/OAuth)
  • Configure firewall rules
  • Set up log rotation

High Availability

  • Use external Prometheus storage
  • Configure Grafana with external database
  • Set up backup automation
  • Use load balancer for Grafana

Monitoring

  • Set up alerting rules
  • Configure notification channels
  • Monitor system resource usage
  • Set up external health checks

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature-name
  3. Commit changes: git commit -am 'Add feature'
  4. Push to branch: git push origin feature-name
  5. Submit pull request

Development Setup

# Local development
cd native-install/
sudo ./install.sh

# Test changes
sudo /etc/prometheus/manage-iot-devices.sh discover
sudo /etc/prometheus/iot-status.sh

πŸ“ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Copyleft Notice: This is free software under a copyleft license. Any derivative works must also be released under GPL v3 or later, ensuring that improvements remain free and open source for the community.

πŸŽ‰ Acknowledgments

  • Prometheus community for excellent monitoring tools
  • Grafana team for beautiful visualization platform
  • JSON Exporter for flexible metric conversion
  • RGBWW IoT device developers for providing accessible APIs

πŸ“ž Support

  • Documentation: See individual README files in each deployment directory
  • Issues: Report bugs via GitHub issues
  • Discussions: Use GitHub discussions for questions
  • Quick Help: Check troubleshooting section above

πŸš€ Ready to monitor your IoT devices? Choose your deployment method and get started!

About

Prometheus / Grafana container to monitor rgbww controllers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published