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