* Here are some features of this project
* Internet monitoring via pings to google/quad9/Cloudflare
* Packetloss monitoring via shell script, pinging google 40 times
* Speedtest monitoring via shell script -- (kind of broken, hit/miss, I'll explain below)
* DNS Stats via AdguardHome Container in Docker
* GeoIP Map for Destnation (provided by Netify logs, Check out the netify-log.sh script in the Docker folder https://github.com/benisai/Openwrt-Monitoring/blob/main/Docker/netify-log.sh)
* Device Traffic Panel via netify-log.sh (provided by Netify logs). Src + Dst + Port + GeoInfo
* Device Status (Hostname + IP + Status Online or Offline)
* System Resources monitoring (CPU/MEM/Load/Etc) via prometheus on Router
* Monthly Bandwidth monitoring via VNState2 (Will clear monthly on 1st via crontab)
* 12hr Traffic usage (calucated by itpmon results from prometheus)
* WAN Speeds via prometheus
* Live traffic per device (iptmon)
* Traffic per client usage for 2hr (calucated by itpmon results from prometheus)
* Ping Stats via CollectD
* Hourly traffic usage (calucated by itpmon results from prometheus)
* 7 Day traffic usage (calucated by itpmon results from prometheus)
* New Devices Connected to Network via shell script
* Destnation IP count (calucated by nat_traffic results from prometheus)
* Destnation Port count (calucated by nat_traffic results from prometheus)
* NAT Traffic (calucated by nat_traffic results from prometheus)
* We need to install a few pieces of software + custom shell scripts on the router to collect this data
Clone this repo to your server.
sudo wget https://github.com/benisai/Openwrt-Monitoring/blob/main/serverSetup.sh
Create Crontab config on Server (replace USER with your username for the Cronjobs)
run 'sudo crontab -e' and add the line below.
*/1 * * * * /home/USER/Openwrt-Monitoring/Docker/netify-log.sh >> /var/log/crontab.netify.txt 2>&1
wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/routersetup.sh
sh ./routersetup.sh
The routersetup.sh script will do the following: * Install Nano, netperf (needed for speedtest.sh), openssh-sftp-server,vnstat * Install Prometheus and CollectD * Install iptmon, wrtbwmon and luci-wrtbwmon * Copy custom scripts from this git to /usr/bin/ on the router * Copy custom LUA files from this git to /usr/lib/lua/prometheus-collectors on the router. * Adding new_device.sh script to dhcp dnsmasq * Adding scripts to Crontab * Update prometheus config to 'lan' * Update Collectd Export IP to home server ip address * Add iptmon to your dhcp file under dnsmasq section * Set your lan interface to assign out DNS IP of your home server * restarts services
[socket] listen_path[0] = /var/run/netifyd/netifyd.sock listen_address[0] = 10.0.5.1 <---------Add this line, update the Router IP
## dnsmasq configuration
uci set dhcp.@dnsmasq[0].dhcpscript=/usr/sbin/iptmon
echo '/usr/sbin/iptmon init' >> /etc/firewall.user
uci set luci_statistics.collectd.Include='/etc/collectd/conf.d'
uci commit
/etc/init.d/dnsmasq restart /etc/init.d/firewall restart /etc/init.d/luci_statistics restart
rm -rf /tmp/luci-modulecache/
--------
Credit: I have to give credit to Matthew Helmke, I used his blog and grafana dashboard and I added some stuff. I cant say I'm an expert in Grafana or Prometheus (first time using Prom) https://grafana.com/blog/2021/02/09/how-i-monitor-my-openwrt-router-with-grafana-cloud-and-prometheus/