Skip to content

Commit

Permalink
prometheus-node-exporter-lua: add modemmanager exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
macjl committed Nov 13, 2024
1 parent c9b32b9 commit 97cc261
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion utils/prometheus-node-exporter-lua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=prometheus-node-exporter-lua
PKG_VERSION:=2024.06.16
PKG_VERSION:=2024.11.09
PKG_RELEASE:=2

PKG_MAINTAINER:=Etienne CHAMPETIER <[email protected]>
Expand Down Expand Up @@ -257,6 +257,17 @@ define Package/prometheus-node-exporter-lua-mwan3/install
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/mwan3.lua $(1)/usr/lib/lua/prometheus-collectors/
endef

define Package/prometheus-node-exporter-lua-modemmanager
$(call Package/prometheus-node-exporter-lua/Default)
TITLE+= (modemmanager collector)
DEPENDS:=prometheus-node-exporter-lua +modemmanager +lua-cjson
endef

define Package/prometheus-node-exporter-lua-modemmanager/install
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/modemmanager.lua $(1)/usr/lib/lua/prometheus-collectors/
endef

$(eval $(call BuildPackage,prometheus-node-exporter-lua))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-bmx7))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-dawn))
Expand All @@ -276,3 +287,4 @@ $(eval $(call BuildPackage,prometheus-node-exporter-lua-wifi_stations))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-snmp6))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-realtek-poe))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-mwan3))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-modemmanager))
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local cjson = require "cjson"

local function scrape()

local file = assert(io.popen('mmcli -m any -J --signal-get', 'r'))
file:flush()
local output = file:read('*all')
file:close()

table = cjson.decode(output)

for k,v in pairs(table["modem"]["signal"]) do
for k2,value in pairs(v) do
if ( tonumber(value) ~= nil ) then
metricname = "modemmanager_signal_" .. k .. "_" .. k2
metric(metricname, "gauge", nil, value)
end
end
end

end

return { scrape = scrape }

0 comments on commit 97cc261

Please sign in to comment.