93 lines
2.5 KiB
Nix
93 lines
2.5 KiB
Nix
{ depot, pkgs, ... }:
|
|
let
|
|
inherit (pkgs) prometheus-snmp-exporter curl cacert unzip p7zip;
|
|
|
|
hpMibs = pkgs.stdenvNoCC.mkDerivation rec {
|
|
pname = "hp-mibs";
|
|
version = "11.50";
|
|
|
|
src = pkgs.fetchurl {
|
|
url = "https://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1580676047/v188074/upd11.50mib.tar.gz";
|
|
hash = "sha256:0jxxcirbvhlqrflj0j2vzddqaq7wl7v3g7xi0gcjmxlj6rfkk7i9";
|
|
};
|
|
sourceRoot = ".";
|
|
|
|
buildPhase = ":";
|
|
installPhase = ''
|
|
mkdir $out
|
|
cp $(ls | grep -i '\.mib$') $out
|
|
'';
|
|
};
|
|
|
|
mibsDrv = pkgs.stdenvNoCC.mkDerivation {
|
|
pname = "prometheus-snmp-mibs";
|
|
version = "lukegb-${prometheus-snmp-exporter.version}";
|
|
|
|
outputHashMode = "recursive";
|
|
outputHash = {
|
|
x86_64-linux = "sha256-Z+TdmISyOC0UWqxLEaNu86LLlVRue+hq8mEfEQWpZhM=";
|
|
aarch64-linux = "sha256-dTvqPxNmA4B0NP47KXp5C+IHV4/TqfG+YT4TDov1gAE=";
|
|
}.${pkgs.system};
|
|
|
|
buildInputs = [
|
|
curl
|
|
p7zip
|
|
prometheus-snmp-exporter
|
|
unzip
|
|
];
|
|
passthru.hp = hpMibs;
|
|
|
|
CURL_OPTS = "--retry 3 --retry-delay 3 --compressed --location --fail";
|
|
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
|
|
src = prometheus-snmp-exporter.src;
|
|
|
|
unpackPhase = ''
|
|
mkdir $NIX_BUILD_TOP/build
|
|
cp $src/generator/Makefile $NIX_BUILD_TOP/build/Makefile
|
|
'';
|
|
|
|
patchPhase = ''
|
|
sed -i $NIX_BUILD_TOP/build/Makefile -e 's,powernet451,powernet452,g' -e 's,POWERNETMIB_451,POWERNETMIB_452,g'
|
|
cat $NIX_BUILD_TOP/build/Makefile
|
|
'';
|
|
|
|
buildPhase = ''
|
|
pushd $NIX_BUILD_TOP/build
|
|
mkdir mibs
|
|
make CURL_OPTS="$CURL_OPTS"
|
|
|
|
# Additional mibs...
|
|
cp ${hpMibs}/cpqhost.mib ./mibs/
|
|
awk 'BEGIN { p=1 } /INDEX\s+{.+cpqRackServerBladeRack,/ { print " INDEX { cpqRackServerBladeIndex }"; p=0 } /}/ { if (p==0) { p=2 } } { if (p==1) { print } if (p==2) { p=1 } }' ${hpMibs}/cpqrack.mib > ./mibs/cpqrack.mib
|
|
'';
|
|
|
|
installPhase = ''
|
|
cp -R $NIX_BUILD_TOP/build/mibs $out
|
|
'';
|
|
};
|
|
in
|
|
pkgs.stdenvNoCC.mkDerivation {
|
|
pname = "prometheus-snmp-config";
|
|
version = "lukegb";
|
|
|
|
src = prometheus-snmp-exporter.src;
|
|
passthru.mibs = mibsDrv;
|
|
|
|
buildInputs = [ prometheus-snmp-exporter ];
|
|
MIBDIRS = mibsDrv;
|
|
|
|
unpackPhase = ''
|
|
mkdir $NIX_BUILD_TOP/build
|
|
cat $src/generator/generator.yml ${./generator.yml} > $NIX_BUILD_TOP/build/generator.yml
|
|
'';
|
|
|
|
buildPhase = ''
|
|
pushd $NIX_BUILD_TOP/build
|
|
generator generate
|
|
'';
|
|
|
|
installPhase = ''
|
|
cp $NIX_BUILD_TOP/build/snmp.yml $out
|
|
'';
|
|
}
|