benisai / Openwrt-Monitoring

Openwrt Monitoring via Grafana
95 stars 17 forks source link

Steps works but no graph on :1999 port ? #5

Open thyagorodriguesalvarez opened 1 year ago

thyagorodriguesalvarez commented 1 year ago

Thanks for sharing this !! actually all those steps works but i cant get to the graph, why!?

`

=== Please set the IP address to point to your Home Server (Where Docker is installed) ============

HOMESERVER="192.168.1.1" echo "Using IP Address: ${HOMESERVER} for HomeServer (where Docker is installed)"

=== Updating CollectD export ip ==============

echo 'updating luci_statistics server export config to ${HOMESERVER}' sed -i "s/192.168.1.1/${HOMESERVER}/g" /etc/config/luci_statistics

=== Setting up DNS ===========

L=$(uci show dhcp.lan.dhcp_option | grep "$HOMESERVER") if [[ -z "$L" ]]; then echo "Adding $HOMESERVER DNS entry to LAN Interface" uci add_list dhcp.lan.dhcp_option="6,${HOMESERVER}" uci commit dhcp elif [[ -n "$L" ]]; then echo "${HOMESERVER} DNS was found, no changes to DNS" fi

=== Setting Services to enable and restarting Services =============

echo 'Enable and Restart services' /etc/init.d/cron start /etc/init.d/cron enable /etc/init.d/wrtbwmon enable /etc/init.d/wrtbwmon start

/etc/init.d/vnstat_backup enable

/etc/init.d/vnstat restart /etc/init.d/luci_statistics enable /etc/init.d/collectd enable /etc/init.d/collectd restart /etc/init.d/prometheus-node-exporter-lua restart /etc/init.d/dnsmasq restart /etc/init.d/firewall restart /etc/init.d/cron restart `

` root@OpenWrt:~# vi /etc/netifyd.conf

Netify Agent configuration

Copyright (C) 2016-2022 eGloo Incorporated

#

This is free software, licensed under the GNU General Public License v3.

#

Read the netifyd.conf(5) man page for documentation.

See /usr/share/netifyd/netifyd.conf-sample for all possible options.

[netifyd] enable_sink = no

[socket] listen_path[0] = /var/run/netifyd/netifyd.sock listen_address[0] = 192.168.1.1

[protocols] all=include `

root@OpenWrt:~# docker -v Docker version 24.0.2, build cb74dfc

benisai commented 1 year ago

Hello friend, which graph are we talking about in grafana? Can you include a screenshot for me?

Make sure to add your data source as well in grafana

benisai commented 1 year ago

Please do not forget to update the IP address in the Prometheus.yml file. Change 10.0.5.1 to your routers IP address. You should be able to scrape your data and then the graphs should work.

scrape_configs:

thyagorodriguesalvarez commented 1 year ago

sure, lets troubleshoot it :) give me some seconds

thyagorodriguesalvarez commented 1 year ago

have in consideration these steps on my bpi-r3 with OpenWrt 23.05.0-rc2, r23228-cd17d8df2a : Router Setup (Openwrt 21.x)

Download the shell script to setup the router
    wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/routersetup.sh
        nano routersetup.sh
            replace 10.0.5.5 with your Home Server IP
sh routersetup.sh
Configure Netify.d
    You have to add your routers IP address to line below to enable TCP sockets in the netifyd engine. In /etc/netifyd.conf:
    (replace 10.0.5.1 with your routers IP address)

    [socket]
    listen_path[0] = /var/run/netifyd/netifyd.sock
    listen_address[0] = 10.0.5.1    

    Reboot Router

`root@OpenWrt:~# ls routersetup.sh root@OpenWrt:~# cat routersetup.sh

!/bin/sh

=== Please set the IP address to point to your Home Server (Where Docker is installed) ============

HOMESERVER="192.168.1.1" echo "Using IP Address: ${HOMESERVER} for HomeServer (where Docker is installed)"

=== Set Custom Alias for clear as cls ============

mkdir -p /etc/profile.d cat << "EOF" > /etc/profile.d/alias.sh alias cls="clear" EOF

=== Update repo =============

echo 'Updating software packages' opkg update

List of software to check and install

software="netperf openssh-sftp-server vnstat2 vnstati2 luci-app-vnstat2 netifyd collectd collectd-mod-iptables collectd-mod-ping luci-app-statistics collectd-mod-dhcpleases prometheus prometheus-node-exporter-lua prometheus-node-exporter-lua-nat_traffic prometheus-node-exporter-lua-openwrt prometheus-node-exporter-lua-uci_dhcp_host prometheus-node-exporter-lua-wifi prometheus-node-exporter-lua-wifi_stations"

Loop through the list of software

for s in $software do

Check if the software is installed

opkg list-installed | grep -q "^$s -" if [ $? -ne 0 ] then

If not installed, install it

echo "$s is not installed. Installing..."
opkg update
opkg install $s
echo "$s installation complete."

else

If installed, print a message

echo "$s is already installed."

fi done

echo 'Installing IPTMON 1.6.1 from GitHub' wget https://github.com/oofnikj/iptmon/releases/download/v0.1.6/iptmon_0.1.6-1_all.ipk -O /root/iptmon_0.1.6-1_all.ipk opkg install /root/iptmon_0.1.6-1_all.ipk

ipt=$(uci show dhcp.@dnsmasq[0].dhcpscript | grep "iptmon") if [[ -z "$ipt" ]]; then echo "Adding iptmon to DHCPScript option" uci set dhcp.@dnsmasq[0].dhcpscript=/usr/sbin/iptmon uci commit

echo '/usr/sbin/iptmon init' >> /etc/firewall.user

    elif [[ -n "$ipt" ]]; then

echo "IPTMon was found, no changes made to DHCP" fi

Changing vnstat backup location to SD Card.

dt=$(date '+%d%m%Y%H%M%S'); DatabaseDir "/var/lib/vnstat" DIR=/tmp/mountd/disk1_part1 if [[ -d "$DIR" ]]; then echo "$DIR directory exists." echo "Backing up /etc/vnstat.conf.$dt" cp /etc/vnstat.conf /etc/vnstat.conf.$dt sed -i 's/;DatabaseDir /DatabaseDir /g' /etc/vnstat.conf sed -i 's,/var/lib/vnstat,/tmp/mountd/disk1_part1/vnstat,g' /etc/vnstat.conf

Change VNStatDB save time from 5 mins to 1 min

sed -i 's/;SaveInterval 5 /;SaveInterval 1 /g' /etc/vnstat.conf
else

echo "$DIR directory does not exist." fi

echo 'Installing WrtBWmon' wget https://github.com/pyrovski/wrtbwmon/releases/download/0.36/wrtbwmon_0.36_all.ipk -O /root/wrtbwmon_0.36_all.ipk wget https://github.com/Kiougar/luci-wrtbwmon/releases/download/v0.8.3/luci-wrtbwmon_v0.8.3_all.ipk -O /root/luci-wrtbwmon_v0.8.3_all.ipk opkg install /root/wrtbwmon_0.36_all.ipk opkg install /root/luci-wrtbwmon_v0.8.3_all.ipk

Copying scripts and lua files to router

echo 'Copying shell scripts and files from Github to Router' wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/speedtest.sh -O /usr/bin/speedtest.sh && chmod +x /usr/bin/speedtest.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/15-second-script.sh -O /usr/bin/15-second-script.sh && chmod +x /usr/bin/15-second-script.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-minute-script.sh -O /usr/bin/1-minute-script.sh && chmod +x /usr/bin/1-minute-script.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-hour-script.sh -O /usr/bin/1-hour-script.sh && chmod +x /usr/bin/1-hour-script.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/5-minute-script.sh -O /usr/bin/5-minute-script.sh && chmod +x /usr/bin/5-minute-script.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/12am-script.sh -O /usr/bin/12am-script.sh && chmod +x /usr/bin/12am-script.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/99-new-device -O /etc/hotplug.d/dhcp/99-new-device wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/device-status-ping.sh -O /usr/bin/device-status-ping.sh && chmod +x /usr/bin/device-status-ping.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/packet-loss.sh -O /usr/bin/packet-loss.sh && chmod +x /usr/bin/packet-loss.sh wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/new_device.sh -O /usr/bin/new_device.sh && chmod +x /usr/bin/new_device.sh

echo 'Copying custom LUA Files from GIT to router' wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/nat_traffic.lua -O /usr/lib/lua/prometheus-collectors/nat_traffic.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/speedtest.lua -O /usr/lib/lua/prometheus-collectors/speedtest.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/wanip.lua -O /usr/lib/lua/prometheus-collectors/wanip.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/packetloss.lua -O /usr/lib/lua/prometheus-collectors/packetloss.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/new_device.lua -O /usr/lib/lua/prometheus-collectors/new_device.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/vnstatmonth.lua -O /usr/lib/lua/prometheus-collectors/vnstatmonth.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/device-status.lua -O /usr/lib/lua/prometheus-collectors/device-status.lua wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/gl-router-temp.lua -O /usr/lib/lua/prometheus-collectors/gl-router-temp.lua

echo 'Copying Extra files'

wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/vnstat_backup -O /etc/init.d/vnstat_backup && chmod +x /etc/init.d/vnstat_backup

wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/wrtbwmon -O /usr/sbin/wrtbwmon && chmod +x /usr/sbin/wrtbwmon

wget https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/luci_statistics -O /etc/config/luci_statistics

Adding new_device.sh script to dhcp dnsmasq

echo 'Adding new_device.sh script to dhcp dnsmasq.conf' if [[ -z "$new_device.sh" ]]; then echo "Adding new_device.sh to DHCPScript option" uci set dhcp.@dnsmasq[0].dhcpscript=/usr/sbin/new_device.sh uci commit elif [[ -n "$new_device.sh" ]]; then echo "Script New_Device.sh was found, no changes made to DHCP" fi

Adding scripts to Crontab

echo 'Add Scripts to crontab' C=$(crontab -l | grep "ready") if [[ -z "$C" ]]; then echo "Adding Scripts.sh to crontab" crontab -l | { cat; echo "59 12 /ready"; } | crontab - crontab -l | { cat; echo "0 /8 /usr/bin/speedtest.sh"; } | crontab - crontab -l | { cat; echo "10 6 rm -rf /tmp/speedtest.out"; } | crontab - crontab -l | { cat; echo "1 0 /usr/bin/12am-script.sh"; } | crontab - crontab -l | { cat; echo "0 /usr/bin/1-hour-script.sh"; } | crontab - crontab -l | { cat; echo "/1 /usr/bin/1-minute-script.sh"; } | crontab - crontab -l | { cat; echo "/5 /usr/bin/5-minute-script.sh"; } | crontab - crontab -l | { cat; echo " /usr/bin/15-second-script.sh"; } | crontab - crontab -l | { cat; echo " sleep 15; /usr/bin/15-second-script.sh"; } | crontab - crontab -l | { cat; echo " sleep 30; /usr/bin/15-second-script.sh"; } | crontab - crontab -l | { cat; echo " sleep 45; /usr/bin/15-second-script.sh"; } | crontab - crontab -l | { cat; echo "/1 /usr/bin/device-status-ping.sh"; } | crontab - crontab -l | { cat; echo "/1 /usr/bin/new_device.sh"; } | crontab - crontab -l | { cat; echo "/1 * /usr/bin/packet-loss.sh"; } | crontab - elif [[ -n "$C" ]]; then echo "Keyword (ready) was found in crontab, no changes made" fi

=== Setting up app-statistics and prometheus configs =============

echo 'updating prometheus config from loopback to lan' sed -i 's/loopback/lan/g' /etc/config/prometheus-node-exporter-lua

=== Updating CollectD export ip ==============

echo 'updating luci_statistics server export config to ${HOMESERVER}' sed -i "s/192.168.1.1/${HOMESERVER}/g" /etc/config/luci_statistics

=== Setting up DNS ===========

L=$(uci show dhcp.lan.dhcp_option | grep "$HOMESERVER") if [[ -z "$L" ]]; then echo "Adding $HOMESERVER DNS entry to LAN Interface" uci add_list dhcp.lan.dhcp_option="6,${HOMESERVER}" uci commit dhcp elif [[ -n "$L" ]]; then echo "${HOMESERVER} DNS was found, no changes to DNS" fi

=== Setting Services to enable and restarting Services =============

echo 'Enable and Restart services' /etc/init.d/cron start /etc/init.d/cron enable /etc/init.d/wrtbwmon enable /etc/init.d/wrtbwmon start

/etc/init.d/vnstat_backup enable

/etc/init.d/vnstat restart /etc/init.d/luci_statistics enable /etc/init.d/collectd enable /etc/init.d/collectd restart /etc/init.d/prometheus-node-exporter-lua restart /etc/init.d/dnsmasq restart /etc/init.d/firewall restart /etc/init.d/cron restart

===

echo 'You should restart the router now for these changes to take effect...' root@OpenWrt:~# sh routersetup.sh Using IP Address: 192.168.1.1 for HomeServer (where Docker is installed) Updating software packages Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/targets/mediatek/filogic/packages/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_core Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/targets/mediatek/filogic/packages/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/base/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_base Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/base/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/luci/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_luci Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/luci/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/packages/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_packages Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/packages/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/routing/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_routing Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/routing/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/telephony/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_telephony Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/telephony/Packages.sig Signature check passed. netperf is already installed. openssh-sftp-server is already installed. vnstat2 is already installed. vnstati2 is already installed. luci-app-vnstat2 is already installed. netifyd is already installed. collectd is already installed. collectd-mod-iptables is already installed. collectd-mod-ping is already installed. luci-app-statistics is already installed. collectd-mod-dhcpleases is already installed. prometheus is already installed. prometheus-node-exporter-lua is already installed. prometheus-node-exporter-lua-nat_traffic is already installed. prometheus-node-exporter-lua-openwrt is already installed. prometheus-node-exporter-lua-uci_dhcp_host is already installed. prometheus-node-exporter-lua-wifi is already installed. prometheus-node-exporter-lua-wifi_stations is already installed. Installing IPTMON 1.6.1 from GitHub Downloading 'https://github.com/oofnikj/iptmon/releases/download/v0.1.6/iptmon_0.1.6-1_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/246513201/91e82e80-4f2c-11eb-9486-e5f9d788c52b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131618Z&X-Amz-Expires=300&X-Amz-Signature=6354b8195f3f277a25febedb7805e363dece668fbbfc0809b826df6cd21a1f8f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=246513201&response-content-disposition=attachment%3B%20filename%3Diptmon_0.1.6-1_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/iptmon_0.1.6-1_all.ipk' /root/iptmon_0.1.6-1 100% || 3322 0:00:00 ETA Download completed (3322 bytes) Package iptmon (0.1.6-1) installed in root is up to date. IPTMon was found, no changes made to DHCP routersetup.sh: line 60: DatabaseDir: not found /tmp/mountd/disk1_part1 directory does not exist. Installing WrtBWmon Downloading 'https://github.com/pyrovski/wrtbwmon/releases/download/0.36/wrtbwmon_0.36_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/23052705/3964365a-db59-11e6-927e-bfab1a2263e5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131620Z&X-Amz-Expires=300&X-Amz-Signature=1e9257257190a273071ffdd6c378b18e5b28df903feec895147a8a0cc47e6a0e&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=23052705&response-content-disposition=attachment%3B%20filename%3Dwrtbwmon_0.36_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/wrtbwmon_0.36_all.ipk' /root/wrtbwmon0.36 100% || 6223 0:00:00 ETA Download completed (6223 bytes) Downloading 'https://github.com/Kiougar/luci-wrtbwmon/releases/download/v0.8.3/luci-wrtbwmon_v0.8.3_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/77686685/43944000-2b09-11e9-8495-ef41a3951565?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131621Z&X-Amz-Expires=300&X-Amz-Signature=a351f9812a497ae66098e91eea7d98159012a1eb972559207e22725c7cd1e1a5&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=77686685&response-content-disposition=attachment%3B%20filename%3Dluci-wrtbwmon_v0.8.3_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/luci-wrtbwmon_v0.8.3all.ipk' /root/luci-wrtbwmon 100% || 7390 0:00:00 ETA Download completed (7390 bytes) Package wrtbwmon (0.36) installed in root is up to date. Package luci-wrtbwmon (v0.8.3) installed in root is up to date. Copying shell scripts and files from Github to Router Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/speedtest.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/speedtest.sh' /usr/bin/speedtest.s 100% || 3846 0:00:00 ETA Download completed (3846 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/15-second-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/15-second-script.sh' /usr/bin/15-second-s 100% || 721 0:00:00 ETA Download completed (721 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-minute-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/1-minute-script.sh' /usr/bin/1-minute-sc 100% || 2457 0:00:00 ETA Download completed (2457 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-hour-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/1-hour-script.sh' /usr/bin/1-hour-scri 100% || 428 0:00:00 ETA Download completed (428 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/5-minute-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/5-minute-script.sh' /usr/bin/5-minute-sc 100% || 243 0:00:00 ETA Download completed (243 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/12am-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/12am-script.sh' /usr/bin/12am-script 100% || 1653 0:00:00 ETA Download completed (1653 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/99-new-device' Connecting to 185.199.111.133:443 Writing to '/etc/hotplug.d/dhcp/99-new-device' /etc/hotplug.d/dhcp/ 100% || 292 0:00:00 ETA Download completed (292 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/device-status-ping.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/device-status-ping.sh' /usr/bin/device-stat 100% || 288 0:00:00 ETA Download completed (288 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/packet-loss.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/packet-loss.sh' /usr/bin/packet-loss 100% || 173 0:00:00 ETA Download completed (173 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/new_device.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/new_device.sh' /usr/bin/new_device. 100% || 255 0:00:00 ETA Download completed (255 bytes) Copying custom LUA Files from GIT to router Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/nat_traffic.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/nat_traffic.lua' /usr/lib/lua/prometh 100% || 1297 0:00:00 ETA Download completed (1297 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/speedtest.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/speedtest.lua' /usr/lib/lua/prometh 100% || 246 0:00:00 ETA Download completed (246 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/wanip.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/wanip.lua' /usr/lib/lua/prometh 100% || 782 0:00:00 ETA Download completed (782 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/packetloss.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/packetloss.lua' /usr/lib/lua/prometh 100% || 181 0:00:00 ETA Download completed (181 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/new_device.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/new_device.lua' /usr/lib/lua/prometh 100% || 1011 0:00:00 ETA Download completed (1011 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/vnstatmonth.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/vnstatmonth.lua' /usr/lib/lua/prometh 100% || 270 0:00:00 ETA Download completed (270 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/device-status.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/device-status.lua' /usr/lib/lua/prometh 100% || 1032 0:00:00 ETA Download completed (1032 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/gl-router-temp.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/gl-router-temp.lua' /usr/lib/lua/prometh 100% || 237 0:00:00 ETA Download completed (237 bytes) Adding new_device.sh script to dhcp dnsmasq.conf Script New_Device.sh was found, no changes made to DHCP Add Scripts to crontab Keyword (ready) was found in crontab, no changes made updating prometheus config from loopback to lan updating luci_statistics server export config to ${HOMESERVER} 192.168.1.1 DNS was found, no changes to DNS Enable and Restart services Warning: using existing /tmp/usage.db udhcpc: started, v1.36.1 udhcpc: broadcasting discover udhcpc: no lease, failing You should restart the router now for these changes to take effect... root@OpenWrt:~# vi routersetup.sh root@OpenWrt:~# sh routersetup.sh Using IP Address: 192.168.1.1 for HomeServer (where Docker is installed) Updating software packages Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/targets/mediatek/filogic/packages/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_core Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/targets/mediatek/filogic/packages/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/base/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_base Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/base/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/luci/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_luci Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/luci/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/packages/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_packages Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/packages/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/routing/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_routing Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/routing/Packages.sig Signature check passed. Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/telephony/Packages.gz Updated list of available packages in /var/opkg-lists/openwrt_telephony Downloading https://downloads.openwrt.org/releases/23.05.0-rc2/packages/aarch64_cortex-a53/telephony/Packages.sig Signature check passed. netperf is already installed. openssh-sftp-server is already installed. vnstat2 is already installed. vnstati2 is already installed. luci-app-vnstat2 is already installed. netifyd is already installed. collectd is already installed. collectd-mod-iptables is already installed. collectd-mod-ping is already installed. luci-app-statistics is already installed. collectd-mod-dhcpleases is already installed. prometheus is already installed. prometheus-node-exporter-lua is already installed. prometheus-node-exporter-lua-nat_traffic is already installed. prometheus-node-exporter-lua-openwrt is already installed. prometheus-node-exporter-lua-uci_dhcp_host is already installed. prometheus-node-exporter-lua-wifi is already installed. prometheus-node-exporter-lua-wifi_stations is already installed. Installing IPTMON 1.6.1 from GitHub Downloading 'https://github.com/oofnikj/iptmon/releases/download/v0.1.6/iptmon_0.1.6-1_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/246513201/91e82e80-4f2c-11eb-9486-e5f9d788c52b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131910Z&X-Amz-Expires=300&X-Amz-Signature=3317bd642ee0b612cf3d097ba5dbd9e540a184419bb7d1d28203cdd4f93361e6&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=246513201&response-content-disposition=attachment%3B%20filename%3Diptmon_0.1.6-1_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/iptmon_0.1.6-1_all.ipk' /root/iptmon_0.1.6-1 100% || 3322 0:00:00 ETA Download completed (3322 bytes) Package iptmon (0.1.6-1) installed in root is up to date. IPTMon was found, no changes made to DHCP routersetup.sh: line 60: DatabaseDir: not found /tmp/mountd/disk1_part1 directory does not exist. Installing WrtBWmon Downloading 'https://github.com/pyrovski/wrtbwmon/releases/download/0.36/wrtbwmon_0.36_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/23052705/3964365a-db59-11e6-927e-bfab1a2263e5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131911Z&X-Amz-Expires=300&X-Amz-Signature=38b6a8a6a222a16321ccf2e13edad01ac2064faa7fcb15b628e59241b79d6f10&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=23052705&response-content-disposition=attachment%3B%20filename%3Dwrtbwmon_0.36_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/wrtbwmon_0.36_all.ipk' /root/wrtbwmon0.36 100% || 6223 0:00:00 ETA Download completed (6223 bytes) Downloading 'https://github.com/Kiougar/luci-wrtbwmon/releases/download/v0.8.3/luci-wrtbwmon_v0.8.3_all.ipk' Connecting to 140.82.121.3:443 Redirected to /github-production-release-asset-2e65be/77686685/43944000-2b09-11e9-8495-ef41a3951565?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230713%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230713T131912Z&X-Amz-Expires=300&X-Amz-Signature=51dfae7871cf5e4937925297cd65542f05fd9c7df165345628cb2654c3e22a91&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=77686685&response-content-disposition=attachment%3B%20filename%3Dluci-wrtbwmon_v0.8.3_all.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com Writing to '/root/luci-wrtbwmon_v0.8.3all.ipk' /root/luci-wrtbwmon 100% || 7390 0:00:00 ETA Download completed (7390 bytes) Package wrtbwmon (0.36) installed in root is up to date. Package luci-wrtbwmon (v0.8.3) installed in root is up to date. Copying shell scripts and files from Github to Router Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/speedtest.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/speedtest.sh' /usr/bin/speedtest.s 100% || 3846 0:00:00 ETA Download completed (3846 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/15-second-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/15-second-script.sh' /usr/bin/15-second-s 100% || 721 0:00:00 ETA Download completed (721 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-minute-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/1-minute-script.sh' /usr/bin/1-minute-sc 100% || 2457 0:00:00 ETA Download completed (2457 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/1-hour-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/1-hour-script.sh' /usr/bin/1-hour-scri 100% || 428 0:00:00 ETA Download completed (428 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/5-minute-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/5-minute-script.sh' /usr/bin/5-minute-sc 100% || 243 0:00:00 ETA Download completed (243 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/12am-script.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/12am-script.sh' /usr/bin/12am-script 100% || 1653 0:00:00 ETA Download completed (1653 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/99-new-device' Connecting to 185.199.111.133:443 Writing to '/etc/hotplug.d/dhcp/99-new-device' /etc/hotplug.d/dhcp/ 100% || 292 0:00:00 ETA Download completed (292 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/device-status-ping.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/device-status-ping.sh' /usr/bin/device-stat 100% || 288 0:00:00 ETA Download completed (288 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/packet-loss.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/packet-loss.sh' /usr/bin/packet-loss 100% || 173 0:00:00 ETA Download completed (173 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/scripts/new_device.sh' Connecting to 185.199.111.133:443 Writing to '/usr/bin/new_device.sh' /usr/bin/new_device. 100% || 255 0:00:00 ETA Download completed (255 bytes) Copying custom LUA Files from GIT to router Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/nat_traffic.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/nat_traffic.lua' /usr/lib/lua/prometh 100% || 1297 0:00:00 ETA Download completed (1297 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/speedtest.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/speedtest.lua' /usr/lib/lua/prometh 100% || 246 0:00:00 ETA Download completed (246 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/wanip.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/wanip.lua' /usr/lib/lua/prometh 100% || 782 0:00:00 ETA Download completed (782 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/packetloss.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/packetloss.lua' /usr/lib/lua/prometh 100% || 181 0:00:00 ETA Download completed (181 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/new_device.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/new_device.lua' /usr/lib/lua/prometh 100% || 1011 0:00:00 ETA Download completed (1011 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/vnstatmonth.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/vnstatmonth.lua' /usr/lib/lua/prometh 100% || 270 0:00:00 ETA Download completed (270 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/device-status.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/device-status.lua' /usr/lib/lua/prometh 100% || 1032 0:00:00 ETA Download completed (1032 bytes) Downloading 'https://raw.githubusercontent.com/benisai/Openwrt-Monitoring/main/Router/lua/gl-router-temp.lua' Connecting to 185.199.111.133:443 Writing to '/usr/lib/lua/prometheus-collectors/gl-router-temp.lua' /usr/lib/lua/prometh 100% || 237 0:00:00 ETA Download completed (237 bytes) Adding new_device.sh script to dhcp dnsmasq.conf Script New_Device.sh was found, no changes made to DHCP Add Scripts to crontab Keyword (ready) was found in crontab, no changes made updating prometheus config from loopback to lan updating luci_statistics server export config to ${HOMESERVER} 192.168.1.1 DNS was found, no changes to DNS Enable and Restart services Warning: using existing /tmp/usage.db udhcpc: started, v1.36.1 udhcpc: broadcasting discover udhcpc: no lease, failing You should restart the router now for these changes to take effect... `

then its suposed to be on 192.168.1.1:9100 ? or i am missing a big step ? (complete new on it man... sorry)

`

thyagorodriguesalvarez commented 1 year ago

root@OpenWrt:~# netstat -tulpn | grep 9100 tcp 0 0 192.168.1.1:9100 0.0.0.0:* LISTEN 9799/uhttpd tcp 0 0 fd1d:50a7:c8aa::1:9100 :::* LISTEN 9799/uhttpd

but when on web : ERROR: File Not Found.

thyagorodriguesalvarez commented 1 year ago

root@OpenWrt:~# ps | grep prometheus 6622 promethe 786m S /usr/bin/prometheus --config.file=/etc/prometheus.yml --storage.tsdb.path=/srv/prometheus --web.listen-address=127.0.0.1:9090 9799 root 4128 S /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua -k 70 -p 192.168.1.1:9100 -p [fd1d:50a7:c8aa::1]:91 11385 root 1320 R grep prometheus root@OpenWrt:~#

thyagorodriguesalvarez commented 1 year ago

`root@OpenWrt:~# nmap 192.168.1.1 -p 9100 Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-13 13:27 UTC Nmap scan report for smartdns (192.168.1.1) Host is up (0.00024s latency).

PORT STATE SERVICE 9100/tcp open jetdirect

Nmap done: 1 IP address (1 host up) scanned in 0.40 seconds `

`root@OpenWrt:~# curl 192.168.1.1:9100/metrics

TYPE node_scrape_collector_duration_seconds gauge

TYPE node_scrape_collector_success gauge

node_scrape_collector_duration_seconds{collector="bmx6"} 0.00016212463378906 node_scrape_collector_success{collector="bmx6"} 0 node_scrape_collector_duration_seconds{collector="bmx7"} 8.9883804321289e-05 node_scrape_collector_success{collector="bmx7"} 0

TYPE node_nf_conntrack_entries gauge

node_nf_conntrack_entries 191

TYPE node_nf_conntrack_entries_limit gauge

node_nf_conntrack_entries_limit 65536 node_scrape_collector_duration_seconds{collector="conntrack"} 0.00021696090698242 node_scrape_collector_success{collector="conntrack"} 1

TYPE node_boot_time_seconds gauge

node_boot_time_seconds 1689254653

TYPE node_context_switches_total counter

node_context_switches_total 696768

TYPE node_cpu_seconds_total counter

node_cpu_seconds_total{cpu="cpu0",mode="user"} 3.99 node_cpu_seconds_total{cpu="cpu0",mode="nice"} 0.19 node_cpu_seconds_total{cpu="cpu0",mode="system"} 5.12 node_cpu_seconds_total{cpu="cpu0",mode="idle"} 227.2 node_cpu_seconds_total{cpu="cpu0",mode="iowait"} 2.25 node_cpu_seconds_total{cpu="cpu0",mode="irq"} 0.61 node_cpu_seconds_total{cpu="cpu0",mode="softirq"} 0.26 node_cpu_seconds_total{cpu="cpu0",mode="steal"} 0 node_cpu_seconds_total{cpu="cpu0",mode="guest"} 0 node_cpu_seconds_total{cpu="cpu0",mode="guest_nice"} 0 node_cpu_seconds_total{cpu="cpu1",mode="user"} 4.21 node_cpu_seconds_total{cpu="cpu1",mode="nice"} 0.12 node_cpu_seconds_total{cpu="cpu1",mode="system"} 6.11 node_cpu_seconds_total{cpu="cpu1",mode="idle"} 225.23 node_cpu_seconds_total{cpu="cpu1",mode="iowait"} 2.88 node_cpu_seconds_total{cpu="cpu1",mode="irq"} 0.14 node_cpu_seconds_total{cpu="cpu1",mode="softirq"} 0.21 node_cpu_seconds_total{cpu="cpu1",mode="steal"} 0 node_cpu_seconds_total{cpu="cpu1",mode="guest"} 0 node_cpu_seconds_total{cpu="cpu1",mode="guest_nice"} 0 node_cpu_seconds_total{cpu="cpu2",mode="user"} 5.47 node_cpu_seconds_total{cpu="cpu2",mode="nice"} 0.22 node_cpu_seconds_total{cpu="cpu2",mode="system"} 5.86 node_cpu_seconds_total{cpu="cpu2",mode="idle"} 224.85 node_cpu_seconds_total{cpu="cpu2",mode="iowait"} 2.74 node_cpu_seconds_total{cpu="cpu2",mode="irq"} 0.14 node_cpu_seconds_total{cpu="cpu2",mode="softirq"} 0.23 node_cpu_seconds_total{cpu="cpu2",mode="steal"} 0 node_cpu_seconds_total{cpu="cpu2",mode="guest"} 0 node_cpu_seconds_total{cpu="cpu2",mode="guest_nice"} 0 node_cpu_seconds_total{cpu="cpu3",mode="user"} 4.53 node_cpu_seconds_total{cpu="cpu3",mode="nice"} 0.06 node_cpu_seconds_total{cpu="cpu3",mode="system"} 5.96 node_cpu_seconds_total{cpu="cpu3",mode="idle"} 225.43 node_cpu_seconds_total{cpu="cpu3",mode="iowait"} 3.3 node_cpu_seconds_total{cpu="cpu3",mode="irq"} 0.16 node_cpu_seconds_total{cpu="cpu3",mode="softirq"} 0.12 node_cpu_seconds_total{cpu="cpu3",mode="steal"} 0 node_cpu_seconds_total{cpu="cpu3",mode="guest"} 0 node_cpu_seconds_total{cpu="cpu3",mode="guest_nice"} 0

TYPE node_intr_total counter

node_intr_total 394661

TYPE node_forks_total counter

node_forks_total 12176

TYPE node_procs_running_total gauge

`

thyagorodriguesalvarez commented 1 year ago

root@OpenWrt:/etc/config# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 67a3736ae35c grafana/grafana:7.3.6 "/run.sh" 2 minutes ago Up 15 seconds 3000/tcp Grafana 6c76a241d923 prom/prometheus:v2.23.0 "/bin/prometheus --c…" 4 minutes ago Up 16 seconds 9090/tcp Monitoring

benisai commented 1 year ago

Your 192.168.1.1:9100/metrics output seems a little short. Did all the shell script and lua files copy? Your version of openwrt is newer than mine, and by default it does not use iptables, so iptmon will not work. I also see you have docker runnning on openwrt, and I dont think middleware loki will work with that arch. I did not test the netify.sh script on openwrt, but rather ubuntu, so I dont think your geoip map will work.

I think your best bet is to move Docker stuff over to a x86 linux node and try that first.

thyagorodriguesalvarez commented 1 year ago

Hi, the metrics i cut then to dont feed much in here, thats a new version yes, because its an bpi-r3, so you think its not possible to work !? :(

benisai commented 1 year ago

I haven't tested it like that. I would try some telnets and see if you can connect from docker to the router Prometheus

thyagorodriguesalvarez commented 1 year ago

give me an email i will send you credentials to router access if i understand well :) ssh/https access, would be very very nice if we could manage it to work as its very stable/safe system, i was testing fortinet and i find it boring as hell xD but "have the graphics wich help a lot :/

benisai commented 12 months ago

What's your time zone? We can probably work something out.

benisai commented 12 months ago

Do you have an x86 Linux with docker?

thyagorodriguesalvarez commented 12 months ago

no my friend :) its actually an "bpi-r3" (https://wiki.banana-pi.org/Banana_Pi_BPI-R3) with openwrt i can put it in a old router and downgrade the version too but it will be slow as hell ... so i have this router with docker, i can make a new installation and then start from zero (snapshot openwrt) im in spain now its gmt/utc/cest+1 and you? (but i dont mind about time ah we can do it the time ure avaliable.