-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prometheus-node-exporter-lua: add modemmanager exporter
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|
@@ -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)) | ||
|
@@ -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)) |
23 changes: 23 additions & 0 deletions
23
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/modemmanager.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |