From ad34675dfb34e250972e1058304312ff7ace5063 Mon Sep 17 00:00:00 2001 From: Rene Treffer Date: Sat, 28 Jul 2018 12:43:57 +0200 Subject: [PATCH 1/9] prometheus-node-exporter-lua: add lantiq dsl modem collector a.heider: Address PR comments and clean up. Signed-off-by: Rene Treffer Signed-off-by: Andre Heider (cherry picked from commit c751af86160f4467a2856ecceb2c8b599f517676) --- utils/prometheus-node-exporter-lua/Makefile | 14 ++- .../lib/lua/prometheus-collectors/ltq-dsl.lua | 100 ++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 659668958..f63ec7443 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua PKG_VERSION:=2018.07.23 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 @@ -82,6 +82,12 @@ define Package/prometheus-node-exporter-lua-openwrt DEPENDS:=prometheus-node-exporter-lua endef +define Package/prometheus-node-exporter-lua-ltq-dsl + $(call Package/prometheus-node-exporter-lua/Default) + TITLE+= (lantiq dsl collector) + DEPENDS:=prometheus-node-exporter-lua @(PACKAGE_ltq-adsl-app||PACKAGE_ltq-vdsl-app) +endef + Build/Compile= define Package/prometheus-node-exporter-lua/install @@ -142,6 +148,11 @@ define Package/prometheus-node-exporter-lua-openwrt/install $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/openwrt.lua $(1)/usr/lib/lua/prometheus-collectors/ endef +define Package/prometheus-node-exporter-lua-ltq-dsl/install + $(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors + $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua $(1)/usr/lib/lua/prometheus-collectors/ +endef + $(eval $(call BuildPackage,prometheus-node-exporter-lua)) $(eval $(call BuildPackage,prometheus-node-exporter-lua-nat_traffic)) $(eval $(call BuildPackage,prometheus-node-exporter-lua-netstat)) @@ -151,3 +162,4 @@ $(eval $(call BuildPackage,prometheus-node-exporter-lua-bmx6)) $(eval $(call BuildPackage,prometheus-node-exporter-lua-bmx7)) $(eval $(call BuildPackage,prometheus-node-exporter-lua-textfile)) $(eval $(call BuildPackage,prometheus-node-exporter-lua-openwrt)) +$(eval $(call BuildPackage,prometheus-node-exporter-lua-ltq-dsl)) diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua new file mode 100644 index 000000000..39b65fb8e --- /dev/null +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/ltq-dsl.lua @@ -0,0 +1,100 @@ +local function scrape() + local fd = io.popen("/etc/init.d/dsl_control lucistat") + local dsl_func = loadstring(fd:read("*a")) + fd:close() + + if not dsl_func then + return + end + + local dsl_stat = dsl_func() + + local dsl_line_attenuation = metric("dsl_line_attenuation_db", "gauge") + local dsl_signal_attenuation = metric("dsl_signal_attenuation_db", "gauge") + local dsl_snr = metric("dsl_signal_to_noise_margin_db", "gauge") + local dsl_aggregated_transmit_power = metric("dsl_aggregated_transmit_power_db", "gauge") + local dsl_latency = metric("dsl_latency_seconds", "gauge") + local dsl_datarate = metric("dsl_datarate", "gauge") + local dsl_max_datarate = metric("dsl_max_datarate", "gauge") + local dsl_error_seconds_total = metric("dsl_error_seconds_total", "counter") + local dsl_errors_total = metric("dsl_errors_total", "counter") + + -- dsl hardware/firmware information + metric("dsl_info", "gauge", { + atuc_vendor_id = dsl_stat.atuc_vendor_id, + atuc_system_vendor_id = dsl_stat.atuc_system_vendor_id, + chipset = dsl_stat.chipset, + firmware_version = dsl_stat.firmware_version, + api_version = dsl_stat.api_version, + }, 1) + + -- dsl line settings information + metric("dsl_line_info", "gauge", { + xtse1 = dsl_stat.xtse1, + xtse2 = dsl_stat.xtse2, + xtse3 = dsl_stat.xtse3, + xtse4 = dsl_stat.xtse4, + xtse5 = dsl_stat.xtse5, + xtse6 = dsl_stat.xtse6, + xtse7 = dsl_stat.xtse7, + xtse8 = dsl_stat.xtse8, + annex = dsl_stat.annex_s, + mode = dsl_stat.line_mode_s, + profile = dsl_stat.profile_s, + }, 1) + + -- dsl up is 1 if the line is up and running + local dsl_up + if dsl_stat.line_state == "UP" then + dsl_up = 1 + else + dsl_up = 0 + end + + metric("dsl_up", "gauge", { + detail = dsl_stat.line_state_detail, + }, dsl_up) + + -- dsl line status data + metric("dsl_uptime_seconds", "gauge", {}, dsl_stat.line_uptime) + + -- dsl db measurements + dsl_line_attenuation({direction="down"}, dsl_stat.line_attenuation_down) + dsl_line_attenuation({direction="up"}, dsl_stat.line_attenuation_up) + dsl_signal_attenuation({direction="down"}, dsl_stat.signal_attenuation_down) + dsl_signal_attenuation({direction="up"}, dsl_stat.signal_attenuation_up) + dsl_snr({direction="down"}, dsl_stat.noise_margin_down) + dsl_snr({direction="up"}, dsl_stat.noise_margin_up) + dsl_aggregated_transmit_power({direction="down"}, dsl_stat.actatp_down) + dsl_aggregated_transmit_power({direction="up"}, dsl_stat.actatp_up) + + -- dsl performance data + if dsl_stat.latency_down ~= nil then + dsl_latency({direction="down"}, dsl_stat.latency_down / 1000000) + dsl_latency({direction="up"}, dsl_stat.latency_up / 1000000) + end + dsl_datarate({direction="down"}, dsl_stat.data_rate_down) + dsl_datarate({direction="up"}, dsl_stat.data_rate_up) + dsl_max_datarate({direction="down"}, dsl_stat.max_data_rate_down) + dsl_max_datarate({direction="up"}, dsl_stat.max_data_rate_up) + + -- dsl errors + dsl_error_seconds_total({err="forward error correction",loc="near"}, dsl_stat.errors_fec_near) + dsl_error_seconds_total({err="forward error correction",loc="far"}, dsl_stat.errors_fec_far) + dsl_error_seconds_total({err="errored",loc="near"}, dsl_stat.errors_es_near) + dsl_error_seconds_total({err="errored",loc="far"}, dsl_stat.errors_es_near) + dsl_error_seconds_total({err="severely errored",loc="near"}, dsl_stat.errors_ses_near) + dsl_error_seconds_total({err="severely errored",loc="near"}, dsl_stat.errors_ses_near) + dsl_error_seconds_total({err="loss of signal",loc="near"}, dsl_stat.errors_loss_near) + dsl_error_seconds_total({err="loss of signal",loc="far"}, dsl_stat.errors_loss_far) + dsl_error_seconds_total({err="unavailable",loc="near"}, dsl_stat.errors_uas_near) + dsl_error_seconds_total({err="unavailable",loc="far"}, dsl_stat.errors_uas_far) + dsl_errors_total({err="header error code error",loc="near"}, dsl_stat.errors_hec_near) + dsl_errors_total({err="header error code error",loc="far"}, dsl_stat.errors_hec_far) + dsl_errors_total({err="non pre-emptive crc error",loc="near"}, dsl_stat.errors_crc_p_near) + dsl_errors_total({err="non pre-emptive crc error",loc="far"}, dsl_stat.errors_crc_p_far) + dsl_errors_total({err="pre-emptive crc error",loc="near"}, dsl_stat.errors_crcp_p_near) + dsl_errors_total({err="pre-emptive crc error",loc="far"}, dsl_stat.errors_crcp_p_far) +end + +return { scrape = scrape } From 70bd5a36cdb3df2dd42429bab63d65d7e20efb02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Macha=C5=82a?= Date: Sun, 30 Dec 2018 22:03:11 +0100 Subject: [PATCH 2/9] prometheus-node-exporter-lua: change network metric type to counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr MachaƂa (cherry picked from commit 626b197cc1b7f8cbb6937d7b6c1ed9982296feac) --- utils/prometheus-node-exporter-lua/Makefile | 4 ++-- .../files/usr/lib/lua/prometheus-collectors/netdev.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index f63ec7443..bab0fde12 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -4,8 +4,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua -PKG_VERSION:=2018.07.23 -PKG_RELEASE:=3 +PKG_VERSION:=2018.12.30 +PKG_RELEASE:=4 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/netdev.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/netdev.lua index 4aff513b3..679b2f37b 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/netdev.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/netdev.lua @@ -29,7 +29,7 @@ local function scrape() end end for i, ndss in ipairs(netdevsubstat) do - netdev_metric = metric("node_network_" .. ndss, "gauge") + netdev_metric = metric("node_network_" .. ndss, "counter") for dev, nds_dev in pairs(nds_table) do netdev_metric({device=dev}, nds_dev[i+1]) end From b03545e0bcd0c1df31f8cc524033112cb1a62d09 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Wed, 3 Apr 2019 21:08:11 +0100 Subject: [PATCH 3/9] prometheus-node-exporter-lua: fix missing conntrack values If the /proc/sys/net/netfilter/nc_conntrack_* files are not present, this exporter was outputting a blank value, which is invalid. These files will not be present when using an image that doesn't include the iptables and firewall packages (eg a minimal access-point type image). This updates the collector to only output the metrics if the corresponding /proc files are present. Signed-off-by: Alex Tomlins (cherry picked from commit 0100a2cb26c30ee091a259625b9496dd7805aaaa) --- .../usr/lib/lua/prometheus-collectors/conntrack.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua index 93b26c266..1abb7a191 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua @@ -1,8 +1,12 @@ local function scrape() - metric("node_nf_conntrack_entries", "gauge", nil, - string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_count"), 1, -2)) - metric("node_nf_conntrack_entries_limit", "gauge", nil, - string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_max"), 1, -2)) + local count = get_contents("/proc/sys/net/netfilter/nf_conntrack_count") + local max = get_contents("/proc/sys/net/netfilter/nf_conntrack_max") + if count ~= "" then + metric("node_nf_conntrack_entries", "gauge", nil, string.sub(count, 1, -2)) + end + if max ~= "" then + metric("node_nf_conntrack_entries_limit", "gauge", nil, string.sub(max, 1, -2)) + end end return { scrape = scrape } From a08f5e17f61ffaad11fc62511d3f88cf7fb533e8 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Thu, 4 Apr 2019 22:28:40 +0100 Subject: [PATCH 4/9] prometheus-node-exporter-lua: Bump PKG_RELEASE Signed-off-by: Alex Tomlins (cherry picked from commit deab22044be7ea52fd0e3863516a07c5bee72d68) --- utils/prometheus-node-exporter-lua/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index bab0fde12..18638b39e 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua PKG_VERSION:=2018.12.30 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 From 0d224bdfa110151cc8b463aa87464bea7a4c41dc Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Sun, 7 Apr 2019 14:08:31 +0100 Subject: [PATCH 5/9] prometheus-node-exporter-lua: wifi packets should be a counter These output a count of the number of packets transmitted/received, so should be tracked as a counter. As it stands, promtool is warning that these shouldn't be named ending _total if they're a gauge. Signed-off-by: Alex Tomlins (cherry picked from commit a45c702baa1c5e913ac6561ef0e0465b8bd780ce) --- .../files/usr/lib/lua/prometheus-collectors/wifi_stations.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua index 19b5b1eab..d9095a969 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua @@ -3,8 +3,8 @@ local iwinfo = require "iwinfo" local function scrape() local metric_wifi_station_signal = metric("wifi_station_signal_dbm","gauge") - local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","gauge") - local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","gauge") + local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","counter") + local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","counter") local u = ubus.connect() local status = u:call("network.wireless", "status", {}) From 1014b098710bb7c524c1bdc98048ce34c5273aa0 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Sun, 7 Apr 2019 14:01:12 +0100 Subject: [PATCH 6/9] prometheus-node-exporter-lua: Add wifi_station_count To return the number of connected clients. At present this can be partially inferred by using a count() over one of the existing metrics, however this doesn't handle the case when there are no connected clients. When that happens, the count() will return no data instead of 0. Signed-off-by: Alex Tomlins (cherry picked from commit 1237e196b47dbbd7cac7cf7cabe4b8c86e09e0da) --- .../files/usr/lib/lua/prometheus-collectors/wifi_stations.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua index d9095a969..25c144f02 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua @@ -2,6 +2,7 @@ local ubus = require "ubus" local iwinfo = require "iwinfo" local function scrape() + local metric_wifi_stations = metric("wifi_stations", "gauge") local metric_wifi_station_signal = metric("wifi_station_signal_dbm","gauge") local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","counter") local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","counter") @@ -13,6 +14,7 @@ local function scrape() for _, intf in ipairs(dev_table['interfaces']) do local ifname = intf['ifname'] local iw = iwinfo[iwinfo.type(ifname)] + local count = 0 local assoclist = iw.assoclist(ifname) for mac, station in pairs(assoclist) do @@ -23,7 +25,9 @@ local function scrape() metric_wifi_station_signal(labels, station.signal) metric_wifi_station_tx_packets(labels, station.tx_packets) metric_wifi_station_rx_packets(labels, station.rx_packets) + count = count + 1 end + metric_wifi_stations({ifname = ifname}, count) end end end From 60002eb621f92ea7af9510c18becb632c6044521 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Mon, 8 Apr 2019 19:52:32 +0100 Subject: [PATCH 7/9] prometheus-node-exporter-lua: Bump PKG_RELEASE Signed-off-by: Alex Tomlins (cherry picked from commit 4b6f76bfac7bd1969c8ca8829a7fe8f9fed43cd0) --- utils/prometheus-node-exporter-lua/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 18638b39e..d00bc4686 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua PKG_VERSION:=2018.12.30 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 From 06e513ba3ebda0ed16b8cb8711d6ba465eddc2c2 Mon Sep 17 00:00:00 2001 From: Kirill Lukonin Date: Thu, 11 Apr 2019 23:52:16 +0500 Subject: [PATCH 8/9] prometheus-node-exporter-lua: Add more wifi_station metrics and fix naming according to original wifi_linux.go node exporter Signed-off-by: Kirill Lukonin (cherry picked from commit 5eb8e47df282473aede488cad9ae40cad626c0bc) --- utils/prometheus-node-exporter-lua/Makefile | 4 +- .../prometheus-collectors/wifi_stations.lua | 40 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index d00bc4686..83a5c06cf 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -4,8 +4,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua -PKG_VERSION:=2018.12.30 -PKG_RELEASE:=6 +PKG_VERSION:=2019.04.12 +PKG_RELEASE:=1 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua index 25c144f02..f241e414f 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua @@ -3,9 +3,22 @@ local iwinfo = require "iwinfo" local function scrape() local metric_wifi_stations = metric("wifi_stations", "gauge") + local metric_wifi_station_signal = metric("wifi_station_signal_dbm","gauge") - local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","counter") - local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","counter") + + local metric_wifi_station_inactive = metric('wifi_station_inactive_milliseconds', 'gauge') + + local metric_wifi_station_exp_thr = metric('wifi_station_expected_throughput_kilobits_per_second', 'gauge') + + local metric_wifi_station_tx_bitrate = metric('wifi_station_transmit_kilobits_per_second', 'gauge') + local metric_wifi_station_rx_bitrate = metric('wifi_station_receive_kilobits_per_second', 'gauge') + + local metric_wifi_station_tx_packets = metric("wifi_station_transmit_packets_total","counter") + local metric_wifi_station_rx_packets = metric("wifi_station_receive_packets_total","counter") + + local metric_wifi_station_tx_bytes = metric('wifi_station_transmit_bytes_total', 'counter') + local metric_wifi_station_rx_bytes = metric('wifi_station_receive_bytes_total', 'counter') + local u = ubus.connect() local status = u:call("network.wireless", "status", {}) @@ -22,9 +35,30 @@ local function scrape() ifname = ifname, mac = mac, } - metric_wifi_station_signal(labels, station.signal) + if station.signal and station.signal ~= 0 then + metric_wifi_station_signal(labels, station.signal) + end + if station.inactive then + metric_wifi_station_inactive(labels, station.inactive) + end + if station.expected_throughput and station.expected_throughput ~= 0 then + metric_wifi_station_exp_thr(labels, station.expected_throughput) + end + if station.tx_rate and station.tx_rate ~= 0 then + metric_wifi_station_tx_bitrate(labels, station.tx_rate) + end + if station.rx_rate and station.rx_rate ~= 0 then + metric_wifi_station_rx_bitrate(labels, station.rx_rate) + end metric_wifi_station_tx_packets(labels, station.tx_packets) metric_wifi_station_rx_packets(labels, station.rx_packets) + if station.tx_bytes then + metric_wifi_station_tx_bytes(labels, station.tx_bytes) + end + if station.rx_bytes then + metric_wifi_station_rx_bytes(labels, station.rx_bytes) + end + count = count + 1 end metric_wifi_stations({ifname = ifname}, count) From 80742d0da2721fa028e5203a66818bc80ea18344 Mon Sep 17 00:00:00 2001 From: Etienne Champetier Date: Wed, 14 Aug 2019 20:48:48 -0700 Subject: [PATCH 9/9] prometheus-node-exporter-lua: add target & system to OpenWrt collector Before: node_openwrt_info{revision="r10756+1-7546be6007",model="GL.iNet GL-AR150",id="OpenWrt",board_name="glinet,gl-ar150",release="SNAPSHOT"} 1 After: node_openwrt_info{revision="r10756+1-7546be6007",target="ath79/generic",board_name="glinet,gl-ar150",id="OpenWrt",model="GL.iNet GL-AR150",release="SNAPSHOT",system="Atheros AR9330 rev 1"} 1 Fixes #9730, replace #9735 Signed-off-by: Etienne Champetier (cherry picked from commit a14bed1bc959116617b0eb75d2d9a46551a480e6) --- utils/prometheus-node-exporter-lua/Makefile | 4 +-- .../lib/lua/prometheus-collectors/openwrt.lua | 28 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 83a5c06cf..fcc5b589d 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua -PKG_VERSION:=2019.04.12 +PKG_VERSION:=2019.08.14 PKG_RELEASE:=1 PKG_MAINTAINER:=Etienne CHAMPETIER @@ -79,7 +79,7 @@ endef define Package/prometheus-node-exporter-lua-openwrt $(call Package/prometheus-node-exporter-lua/Default) TITLE+= (openwrt collector) - DEPENDS:=prometheus-node-exporter-lua + DEPENDS:=prometheus-node-exporter-lua +libubus-lua endef define Package/prometheus-node-exporter-lua-ltq-dsl diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua index 8b9785a27..8d44792b9 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua @@ -1,20 +1,20 @@ +local ubus = require "ubus" +local u = ubus.connect() +local b = u:call("system", "board", {}) + local labels = { - id = "", - release = "", - revision = "", - model = string.sub(get_contents("/tmp/sysinfo/model"), 1, -2), - board_name = string.sub(get_contents("/tmp/sysinfo/board_name"), 1, -2) + board_name = b.board_name, + id = b.release.distribution, + model = b.model, + release = b.release.version, + revision = b.release.revision, + system = b.system, + target = b.release.target } -for k, v in string.gmatch(get_contents("/etc/openwrt_release"), "(DISTRIB_%w+)='(.-)'\n") do - if k == "DISTRIB_ID" then - labels["id"] = v - elseif k == "DISTRIB_RELEASE" then - labels["release"] = v - elseif k == "DISTRIB_REVISION" then - labels["revision"] = v - end -end +b = nil +u = nil +ubus = nil local function scrape() metric("node_openwrt_info", "gauge", labels, 1)