librenms: init at 23.9.1

This commit is contained in:
Jennifer Graul 2023-07-07 13:45:02 +02:00 committed by Yureka
parent 10df9a49ed
commit 6328874039
3 changed files with 127 additions and 0 deletions

View file

@ -0,0 +1,18 @@
diff --git a/LibreNMS/Config.php b/LibreNMS/Config.php
index 5ed6b71..de7718a 100644
--- a/LibreNMS/Config.php
+++ b/LibreNMS/Config.php
@@ -460,13 +460,6 @@ class Config
self::persist('device_display_default', $display_value);
}
- // make sure we have full path to binaries in case PATH isn't set
- foreach (['fping', 'fping6', 'snmpgetnext', 'rrdtool', 'traceroute'] as $bin) {
- if (! is_executable(self::get($bin))) {
- self::persist($bin, self::locateBinary($bin));
- }
- }
-
if (! self::has('rrdtool_version')) {
self::persist('rrdtool_version', Rrd::version());
}

View file

@ -0,0 +1,107 @@
{ pkgs, stdenv, lib, fetchFromGitHub, unixtools, php82, python3, makeWrapper
# run-time dependencies
, graphviz
, ipmitool
, libvirt
, monitoring-plugins
, mtr
, net-snmp
, nfdump
, nmap
, rrdtool
, system-sendmail
, whois
, dataDir ? "/var/lib/librenms", logDir ? "/var/log/librenms" }:
let
phpPackage = php82.withExtensions ({ enabled, all }: enabled ++ [ all.memcached ]);
in phpPackage.buildComposerProject rec {
name = pname + "-" + version;
pname = "librenms";
version = "23.9.1";
src = fetchFromGitHub {
owner = "librenms";
repo = pname;
rev = "${version}";
sha256 = "sha256-glcD9AhxkvMmGo/7/RhQFeOtvHJ4pSiEFxaAjeVrTaI=";
};
vendorHash = "sha256-s6vdGfM7Ehy1bbkB44EQaHBBvTkpVw9yxhVsc/O8dHc=";
php = phpPackage;
buildInputs = [
unixtools.whereis
(python3.withPackages (ps: with ps; [
pymysql
python-dotenv
redis
setuptools
psutil
command_runner
]))
];
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mv $out/share/php/librenms/* $out
rm -r $out/share
# This broken logic leads to bad settings being persisted in the database
patch -p1 -d $out -i ${./broken-binary-paths.diff}
substituteInPlace \
$out/misc/config_definitions.json \
--replace '"default": "/bin/ping",' '"default": "/run/wrappers/bin/ping",' \
--replace '"default": "fping",' '"default": "/run/wrappers/bin/fping",' \
--replace '"default": "fping6",' '"default": "/run/wrappers/bin/fping6",' \
--replace '"default": "rrdtool",' '"default": "${rrdtool}/bin/rrdtool",' \
--replace '"default": "snmpgetnext",' '"default": "${net-snmp}/bin/snmpgetnext",' \
--replace '"default": "traceroute",' '"default": "/run/wrappers/bin/traceroute",' \
--replace '"default": "/usr/bin/dot",' '"default": "${graphviz}/bin/dot",' \
--replace '"default": "/usr/bin/ipmitool",' '"default": "${ipmitool}/bin/ipmitool",' \
--replace '"default": "/usr/bin/mtr",' '"default": "${mtr}/bin/mtr",' \
--replace '"default": "/usr/bin/nfdump",' '"default": "${nfdump}/bin/nfdump",' \
--replace '"default": "/usr/bin/nmap",' '"default": "${nmap}/bin/nmap",' \
--replace '"default": "/usr/bin/sfdp",' '"default": "${graphviz}/bin/sfdp",' \
--replace '"default": "/usr/bin/snmpbulkwalk",' '"default": "${net-snmp}/bin/snmpbulkwalk",' \
--replace '"default": "/usr/bin/snmpget",' '"default": "${net-snmp}/bin/snmpget",' \
--replace '"default": "/usr/bin/snmptranslate",' '"default": "${net-snmp}/bin/snmptranslate",' \
--replace '"default": "/usr/bin/snmpwalk",' '"default": "${net-snmp}/bin/snmpwalk",' \
--replace '"default": "/usr/bin/virsh",' '"default": "${libvirt}/bin/virsh",' \
--replace '"default": "/usr/bin/whois",' '"default": "${whois}/bin/whois",' \
--replace '"default": "/usr/lib/nagios/plugins",' '"default": "${monitoring-plugins}/libexec",' \
--replace '"default": "/usr/sbin/sendmail",' '"default": "${system-sendmail}/bin/sendmail",'
substituteInPlace $out/LibreNMS/wrapper.py --replace '/usr/bin/env php' '${phpPackage}/bin/php'
substituteInPlace $out/LibreNMS/__init__.py --replace '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
substituteInPlace $out/snmp-scan.py --replace '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
wrapProgram $out/daily.sh --prefix PATH : ${phpPackage}/bin
rm -rf $out/logs $out/rrd $out/bootstrap/cache $out/storage $out/.env
ln -s ${logDir} $out/logs
ln -s ${dataDir}/config.php $out/config.php
ln -s ${dataDir}/.env $out/.env
ln -s ${dataDir}/rrd $out/rrd
ln -s ${dataDir}/storage $out/storage
ln -s ${dataDir}/cache $out/bootstrap/cache
runHook postInstall
'';
passthru = { phpPackage = phpPackage; };
meta = with lib; {
description = "A auto-discovering PHP/MySQL/SNMP based network monitoring";
homepage = "https://www.librenms.org/";
license = licenses.gpl3Only;
maintainers = teams.wdz.members;
platforms = platforms.linux;
};
}

View file

@ -5853,6 +5853,8 @@ with pkgs;
libnvme = callPackage ../os-specific/linux/libnvme { };
librenms = callPackage ../servers/monitoring/librenms { };
libxnd = callPackage ../development/libraries/libxnd { };
libz = callPackage ../development/libraries/libz { };