openwrt-prometheus-exporter: init at 2024.06.16

This commit is contained in:
soyouzpanda 2025-02-20 00:51:16 +01:00
parent 2dd59bbbe1
commit 89b0722869
Signed by: ecoppens
GPG key ID: 871893E37A732093
2 changed files with 66 additions and 0 deletions

View file

@ -91,6 +91,7 @@ in {
odhcp-script = callPackage ./odhcp-script {}; odhcp-script = callPackage ./odhcp-script {};
odhcp6c = callPackage ./odhcp6c {}; odhcp6c = callPackage ./odhcp6c {};
openwrt = callPackage ./openwrt {}; openwrt = callPackage ./openwrt {};
openwrt-prometheus-exporter = callPackage ./openwrt-prometheus-exporter {};
ppp = callPackage ./ppp {}; ppp = callPackage ./ppp {};
pppoe = callPackage ./pppoe {}; pppoe = callPackage ./pppoe {};
preinit = callPackage ./preinit {}; preinit = callPackage ./preinit {};

View file

@ -0,0 +1,65 @@
{
lib,
stdenv,
fetchFromGitHub,
uhttpd,
ubus,
lua,
}:
let
pkg-path = "utils/prometheus-node-exporter-lua/files/usr";
in
stdenv.mkDerivation rec {
pname = "openwrt-prometheus-exporter";
version = "24.10";
src = fetchFromGitHub {
owner = "openwrt";
repo = "packages";
rev = "openwrt-${version}";
hash = "sha256-O8yYVbuSY25PDY5oNTPMDDICE5RBIdvH1cavRXeQoLI=";
};
buildInputs = [
uhttpd
ubus
lua
];
dontBuild = true;
patchPhase = ''
runHook prePatch
substituteInPlace ${pkg-path}/bin/prometheus-node-exporter-lua \
--replace-fail "/usr/lib/lua/prometheus-collectors/*.lua" "$out/share/lua/${lua.luaversion}/prometheus-collectors/*.lua"
runHook postPatch
'';
enabledCollectors = [
"hostapd_ubus_stations.lua"
"cpu.lua"
];
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/lua/${lua.luaversion}/prometheus-collectors}
cp ${pkg-path}/bin/prometheus-node-exporter-lua $out/bin/openwrt-prometheus-exporter
cp ${pkg-path}/lib/lua/prometheus-collectors/{${lib.concatStringsSep "," enabledCollectors}} $out/share/lua/${lua.luaversion}/prometheus-collectors/
runHook postInstall
'';
meta = {
description = "Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md";
homepage = "https://github.com/openwrt/packages";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ soyouzpanda ];
mainProgram = "openwrt-prometheus-exporter";
platforms = lib.platforms.all;
};
}