1{ stdenv, fetchFromGitHub, autoreconfHook
2, coreutils, gnugrep, gnused, lm_sensors, net_snmp, openssh, openssl, perl }:
3
4with stdenv.lib;
5
6let
7 majorVersion = "2.2";
8 minorVersion = ".0";
9
10 binPath = makeBinPath [ coreutils gnugrep gnused lm_sensors net_snmp ];
11
12in stdenv.mkDerivation rec {
13 name = "monitoring-plugins-${majorVersion}${minorVersion}";
14
15 src = fetchFromGitHub {
16 owner = "monitoring-plugins";
17 repo = "monitoring-plugins";
18 rev = "v${majorVersion}";
19 sha256 = "1pw7i6d2cnb5nxi2lbkwps2qzz04j9zd86fzpv9ka896b4aqrwv1";
20 };
21
22 # !!! Awful hack. Grrr... this of course only works on NixOS.
23 # Anyway the check that configure performs to figure out the ping
24 # syntax is totally impure, because it runs an actual ping to
25 # localhost (which won't work for ping6 if IPv6 support isn't
26 # configured on the build machine).
27 preConfigure= ''
28 substituteInPlace po/Makefile.in.in \
29 --replace /bin/sh ${stdenv.shell}
30
31 sed -i configure.ac \
32 -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"\$out/bin:/run/wrappers/bin:${binPath}\"|'
33
34 configureFlagsArray=(
35 --with-ping-command='/run/wrappers/bin/ping -4 -n -U -w %d -c %d %s'
36 --with-ping6-command='/run/wrappers/bin/ping -6 -n -U -w %d -c %d %s'
37 )
38 '';
39
40 # !!! make openssh a runtime dependency only
41 buildInputs = [ net_snmp openssh openssl perl ];
42
43 nativeBuildInputs = [ autoreconfHook ];
44
45 enableParallelBuilding = true;
46
47 # For unknown reasons the installer tries executing $out/share and fails if
48 # it doesn't succeed.
49 # So we create it and remove it again later.
50 preBuild = ''
51 mkdir -p $out
52 cat <<_EOF > $out/share
53#!${stdenv.shell}
54exit 0
55_EOF
56 chmod 755 $out/share
57 '';
58
59 postInstall = ''
60 rm $out/share
61 ln -s libexec $out/bin
62 '';
63
64 meta = {
65 description = "Official monitoring plugins for Nagios/Ichinga/Sensu and others.";
66 homepage = https://www.monitoring-plugins.org;
67 license = licenses.gpl2;
68 platforms = platforms.linux;
69 maintainers = with maintainers; [ thoughtpolice relrod ];
70 };
71}