2021-06-28 23:13:55 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, writeShellScript
|
|
|
|
, autoreconfHook
|
|
|
|
, pkg-config
|
|
|
|
, runCommand
|
|
|
|
, coreutils
|
|
|
|
, gnugrep
|
|
|
|
, gnused
|
|
|
|
, lm_sensors
|
|
|
|
, net-snmp
|
|
|
|
, openssh
|
|
|
|
, openssl
|
|
|
|
, perl
|
|
|
|
, dnsutils
|
|
|
|
, libdbi
|
|
|
|
, libmysqlclient
|
|
|
|
, uriparser
|
|
|
|
, zlib
|
|
|
|
, openldap
|
|
|
|
, procps
|
|
|
|
, runtimeShell
|
2023-11-16 04:20:00 +00:00
|
|
|
, unixtools
|
2021-06-28 23:13:55 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2021-06-28 23:13:55 +00:00
|
|
|
binPath = lib.makeBinPath [
|
|
|
|
(placeholder "out")
|
|
|
|
"/run/wrappers"
|
|
|
|
coreutils
|
|
|
|
gnugrep
|
|
|
|
gnused
|
|
|
|
lm_sensors
|
|
|
|
net-snmp
|
|
|
|
procps
|
2023-11-16 04:20:00 +00:00
|
|
|
unixtools.ping
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
mailq = runCommand "mailq-wrapper" { preferLocalBuild = true; } ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
ln -s /run/wrappers/bin/sendmail $out/bin/mailq
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
# For unknown reasons the installer tries executing $out/share and fails so
|
|
|
|
# we create it and remove it again later.
|
|
|
|
share = writeShellScript "share" ''
|
|
|
|
exit 0
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "monitoring-plugins";
|
|
|
|
version = "2.3.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-06-28 23:13:55 +00:00
|
|
|
owner = "monitoring-plugins";
|
|
|
|
repo = "monitoring-plugins";
|
|
|
|
rev = "v" + lib.versions.majorMinor version;
|
|
|
|
sha256 = "sha256-yLhHOSrPFRjW701aOL8LPe4OnuJxL6f+dTxNqm0evIg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
# TODO: Awful hack. Grrr...
|
2020-04-24 23:36:52 +00:00
|
|
|
# Anyway the check that configure performs to figure out the ping
|
|
|
|
# syntax is totally impure, because it runs an actual ping to
|
|
|
|
# localhost (which won't work for ping6 if IPv6 support isn't
|
|
|
|
# configured on the build machine).
|
2021-06-28 23:13:55 +00:00
|
|
|
#
|
|
|
|
# --with-ping-command needs to be done here instead of in
|
|
|
|
# configureFlags due to the spaces in the argument
|
|
|
|
postPatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace po/Makefile.in.in \
|
2021-06-28 23:13:55 +00:00
|
|
|
--replace /bin/sh ${runtimeShell}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
sed -i configure.ac \
|
2021-06-28 23:13:55 +00:00
|
|
|
-e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"${binPath}\"|'
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
configureFlagsArray+=(
|
2023-11-16 04:20:00 +00:00
|
|
|
--with-ping-command='ping -4 -n -U -w %d -c %d %s'
|
|
|
|
--with-ping6-command='ping -6 -n -U -w %d -c %d %s'
|
2020-04-24 23:36:52 +00:00
|
|
|
)
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
install -Dm555 ${share} $out/share
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
configureFlags = [
|
|
|
|
"--libexecdir=${placeholder "out"}/bin"
|
|
|
|
"--with-mailq-command=${mailq}/bin/mailq"
|
|
|
|
"--with-sudo-command=/run/wrappers/bin/sudo"
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
dnsutils
|
|
|
|
libdbi
|
|
|
|
libmysqlclient
|
|
|
|
net-snmp
|
|
|
|
openldap
|
|
|
|
# TODO: make openssh a runtime dependency only
|
|
|
|
openssh
|
|
|
|
openssl
|
|
|
|
perl
|
|
|
|
procps
|
|
|
|
uriparser
|
|
|
|
zlib
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
rm $out/share
|
|
|
|
'';
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
meta = with lib; {
|
2020-10-19 00:13:06 +00:00
|
|
|
description = "Official monitoring plugins for Nagios/Icinga/Sensu and others";
|
2021-06-28 23:13:55 +00:00
|
|
|
homepage = "https://www.monitoring-plugins.org";
|
|
|
|
license = licenses.gpl3Only;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice relrod ];
|
2021-06-28 23:13:55 +00:00
|
|
|
platforms = platforms.linux;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|