1{ lib
2, stdenv
3, fetchFromGitHub
4, writeShellScript
5, autoreconfHook
6, pkg-config
7, runCommand
8, coreutils
9, gnugrep
10, gnused
11, lm_sensors
12, net-snmp
13, openssh
14, openssl
15, perl
16, dnsutils
17, libdbi
18, libmysqlclient
19, uriparser
20, zlib
21, openldap
22, procps
23, runtimeShell
24}:
25
26let
27 binPath = lib.makeBinPath [
28 (placeholder "out")
29 "/run/wrappers"
30 coreutils
31 gnugrep
32 gnused
33 lm_sensors
34 net-snmp
35 procps
36 ];
37
38 mailq = runCommand "mailq-wrapper" { preferLocalBuild = true; } ''
39 mkdir -p $out/bin
40 ln -s /run/wrappers/bin/sendmail $out/bin/mailq
41 '';
42
43 # For unknown reasons the installer tries executing $out/share and fails so
44 # we create it and remove it again later.
45 share = writeShellScript "share" ''
46 exit 0
47 '';
48
49in
50stdenv.mkDerivation rec {
51 pname = "monitoring-plugins";
52 version = "2.3.0";
53
54 src = fetchFromGitHub {
55 owner = "monitoring-plugins";
56 repo = "monitoring-plugins";
57 rev = "v" + lib.versions.majorMinor version;
58 sha256 = "sha256-yLhHOSrPFRjW701aOL8LPe4OnuJxL6f+dTxNqm0evIg=";
59 };
60
61 # TODO: Awful hack. Grrr... this of course only works on NixOS.
62 # Anyway the check that configure performs to figure out the ping
63 # syntax is totally impure, because it runs an actual ping to
64 # localhost (which won't work for ping6 if IPv6 support isn't
65 # configured on the build machine).
66 #
67 # --with-ping-command needs to be done here instead of in
68 # configureFlags due to the spaces in the argument
69 postPatch = ''
70 substituteInPlace po/Makefile.in.in \
71 --replace /bin/sh ${runtimeShell}
72
73 sed -i configure.ac \
74 -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"${binPath}\"|'
75
76 configureFlagsArray+=(
77 --with-ping-command='/run/wrappers/bin/ping -4 -n -U -w %d -c %d %s'
78 --with-ping6-command='/run/wrappers/bin/ping -6 -n -U -w %d -c %d %s'
79 )
80
81 install -Dm555 ${share} $out/share
82 '';
83
84 configureFlags = [
85 "--libexecdir=${placeholder "out"}/bin"
86 "--with-mailq-command=${mailq}/bin/mailq"
87 "--with-sudo-command=/run/wrappers/bin/sudo"
88 ];
89
90 buildInputs = [
91 dnsutils
92 libdbi
93 libmysqlclient
94 net-snmp
95 openldap
96 # TODO: make openssh a runtime dependency only
97 openssh
98 openssl
99 perl
100 procps
101 uriparser
102 zlib
103 ];
104
105 nativeBuildInputs = [ autoreconfHook pkg-config ];
106
107 enableParallelBuilding = true;
108
109 postInstall = ''
110 rm $out/share
111 '';
112
113 meta = with lib; {
114 description = "Official monitoring plugins for Nagios/Icinga/Sensu and others";
115 homepage = "https://www.monitoring-plugins.org";
116 license = licenses.gpl3Only;
117 maintainers = with maintainers; [ thoughtpolice relrod ];
118 platforms = platforms.linux;
119 };
120}