forked from gl-inet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel YU
committed
Mar 20, 2020
1 parent
5339b30
commit 8d0c420
Showing
23 changed files
with
1,070 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
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,177 @@ | ||
# | ||
# Copyright (C) 2013-2017 OpenWrt.org | ||
# | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=prometheus-node-exporter-lua | ||
PKG_VERSION:=2020.02.03 | ||
PKG_RELEASE:=1 | ||
|
||
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com> | ||
PKG_LICENSE:=Apache-2.0 | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/prometheus-node-exporter-lua/Default | ||
SECTION:=utils | ||
CATEGORY:=Utilities | ||
TITLE:=Prometheus node exporter | ||
PKGARCH:=all | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
DEPENDS:=+luasocket +lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua/conffiles | ||
/etc/config/prometheus-node-exporter-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua/description | ||
Provides node metrics as Prometheus scraping endpoint. | ||
|
||
This service is a lightweight rewrite in LUA of the offical Prometheus node_exporter. | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-nat_traffic | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (nat_traffic collector) | ||
DEPENDS:=prometheus-node-exporter-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-netstat | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (netstat collector) | ||
DEPENDS:=prometheus-node-exporter-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-wifi | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (wifi collector) | ||
DEPENDS:=prometheus-node-exporter-lua +libiwinfo-lua +libubus-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-wifi_stations | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (wifi_stations collector) | ||
DEPENDS:=prometheus-node-exporter-lua +libiwinfo-lua +libubus-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-hostapd_stations | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (hostapd_stations collector) - Requires a full hostapd / wpad build | ||
DEPENDS:=prometheus-node-exporter-lua +hostapd-utils +lua-bit32 +libubus-lua | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-bmx6 | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (bmx6 links collector) | ||
DEPENDS:=prometheus-node-exporter-lua bmx6 +lua-cjson +bmx6-json | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-bmx7 | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (bmx7 links collector) | ||
DEPENDS:=prometheus-node-exporter-lua bmx7 +lua-cjson +bmx7-json | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-textfile | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (textfile collector) | ||
DEPENDS:=prometheus-node-exporter-lua +luci-lib-nixio | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-openwrt | ||
$(call Package/prometheus-node-exporter-lua/Default) | ||
TITLE+= (openwrt collector) | ||
DEPENDS:=prometheus-node-exporter-lua +libubus-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 | ||
$(INSTALL_DIR) $(1)/etc/config | ||
$(INSTALL_CONF) ./files/etc/config/prometheus-node-exporter-lua $(1)/etc/config/prometheus-node-exporter-lua | ||
$(INSTALL_DIR) $(1)/etc/init.d | ||
$(INSTALL_BIN) ./files/etc/init.d/prometheus-node-exporter-lua $(1)/etc/init.d/prometheus-node-exporter-lua | ||
$(INSTALL_DIR) $(1)/usr/bin | ||
$(INSTALL_BIN) ./files/usr/bin/prometheus-node-exporter-lua $(1)/usr/bin/prometheus-node-exporter-lua | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/cpu.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/conntrack.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/filefd.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/loadavg.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/meminfo.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/netdev.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/time.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/uname.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-nat_traffic/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/nat_traffic.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-netstat/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/netstat.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-wifi/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/wifi.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-wifi_stations/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/wifi_stations.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-hostapd_stations/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-bmx6/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/bmx6.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-bmx7/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/bmx7.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-textfile/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/textfile.lua $(1)/usr/lib/lua/prometheus-collectors/ | ||
endef | ||
|
||
define Package/prometheus-node-exporter-lua-openwrt/install | ||
$(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors | ||
$(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)) | ||
$(eval $(call BuildPackage,prometheus-node-exporter-lua-wifi)) | ||
$(eval $(call BuildPackage,prometheus-node-exporter-lua-wifi_stations)) | ||
$(eval $(call BuildPackage,prometheus-node-exporter-lua-hostapd_stations)) | ||
$(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)) |
4 changes: 4 additions & 0 deletions
4
prometheus-node-exporter-lua/files/etc/config/prometheus-node-exporter-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,4 @@ | ||
config prometheus-node-exporter-lua 'main' | ||
option listen_interface 'loopback' | ||
option listen_ipv6 '0' | ||
option listen_port '9100' |
59 changes: 59 additions & 0 deletions
59
prometheus-node-exporter-lua/files/etc/init.d/prometheus-node-exporter-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,59 @@ | ||
#!/bin/sh /etc/rc.common | ||
# Copyright (C) 2013-2017 OpenWrt.org | ||
|
||
START=60 | ||
USE_PROCD=1 | ||
|
||
_log() { | ||
logger -p daemon.info -t prometheus-node-exporter-lua "$@" | ||
} | ||
|
||
start_service() { | ||
. /lib/functions/network.sh | ||
|
||
local interface ipv6 port bind | ||
|
||
config_load prometheus-node-exporter-lua.main | ||
config_get interface "main" listen_interface "loopback" | ||
config_get_bool ipv6 "main" listen_ipv6 0 | ||
config_get port "main" listen_port 9100 | ||
|
||
if [ "$interface" = "*" ]; then | ||
[ "$ipv6" = 1 ] && bind="::" || bind="0.0.0.0" | ||
else | ||
if [ "$ipv6" = 1 ]; then | ||
network_get_ipaddr6 bind "$interface" | ||
else | ||
network_get_ipaddr bind "$interface" | ||
fi | ||
|
||
network_is_up "$interface" && [ -n "$bind" ] || { | ||
_log "defering start until listen interface $interface becomes ready" | ||
return 0 | ||
} | ||
fi | ||
|
||
procd_open_instance | ||
|
||
procd_set_param command /usr/bin/prometheus-node-exporter-lua | ||
procd_append_param command --bind ${bind} | ||
procd_append_param command --port ${port} | ||
|
||
procd_set_param stdout 1 | ||
procd_set_param stderr 1 | ||
procd_set_param respawn | ||
|
||
procd_close_instance | ||
} | ||
|
||
service_triggers() | ||
{ | ||
local interface | ||
|
||
procd_add_reload_trigger "prometheus-node-exporter-lua" | ||
|
||
config_load prometheus-node-exporter-lua.main | ||
config_get interface "main" listen_interface "loopback" | ||
|
||
[ "$interface" = "*" ] || procd_add_reload_interface_trigger "$interface" | ||
} |
Oops, something went wrong.