1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
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 ];
38
39 mailq = runCommand "mailq-wrapper" { preferLocalBuild = true; } ''
40 mkdir -p $out/bin
41 ln -s /run/wrappers/bin/sendmail $out/bin/mailq
42 '';
43in
44stdenv.mkDerivation rec {
45 pname = "monitoring-plugins";
46 version = "2.3.5";
47
48 src = fetchFromGitHub {
49 owner = "monitoring-plugins";
50 repo = "monitoring-plugins";
51 rev = "v${version}";
52 sha256 = "sha256-J9fzlxIpujoG7diSRscFhmEV9HpBOxFTJSmGGFjAzcM=";
53 };
54
55 patches = [
56 # fix build (makefile cannot produce -lcrypto)
57 # remove on next release
58 (fetchpatch {
59 url = "https://github.com/monitoring-plugins/monitoring-plugins/commit/bad156676894a2755c8b76519a11cdd2037e5cd6.patch";
60 hash = "sha256-aI/sX04KXe968SwdS8ZamNtgdNbHtho5cDsDaA+cjZY=";
61 })
62 # fix check_smtp with --starttls https://github.com/monitoring-plugins/monitoring-plugins/pull/1952
63 # remove on next release
64 (fetchpatch {
65 url = "https://github.com/monitoring-plugins/monitoring-plugins/commit/2eea6bb2a04bbfb169bac5f0f7c319f998e8ab87.patch";
66 hash = "sha256-CyVD340+zOxuxRRPmtowD3DFFRB1Q7+AANzul9HqwBI=";
67 })
68 ];
69
70 # TODO: Awful hack. Grrr...
71 # Anyway the check that configure performs to figure out the ping
72 # syntax is totally impure, because it runs an actual ping to
73 # localhost (which won't work for ping6 if IPv6 support isn't
74 # configured on the build machine).
75 #
76 # --with-ping-command needs to be done here instead of in
77 # configureFlags due to the spaces in the argument
78 postPatch = ''
79 substituteInPlace po/Makefile.in.in \
80 --replace /bin/sh ${runtimeShell}
81
82 sed -i configure.ac \
83 -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"${binPath}\"|'
84
85 configureFlagsArray+=(
86 --with-ping-command='${lib.getBin unixtools.ping}/bin/ping -4 -n -U -w %d -c %d %s'
87 --with-ping6-command='${lib.getBin unixtools.ping}/bin/ping -6 -n -U -w %d -c %d %s'
88 )
89 '';
90
91 configureFlags = [
92 "--libexecdir=${placeholder "out"}/bin"
93 "--with-mailq-command=${mailq}/bin/mailq"
94 "--with-sudo-command=/run/wrappers/bin/sudo"
95 ];
96
97 buildInputs = [
98 dnsutils
99 libdbi
100 libmysqlclient
101 net-snmp
102 openldap
103 # TODO: make openssh a runtime dependency only
104 openssh
105 openssl
106 perl
107 procps
108 uriparser
109 zlib
110 ];
111
112 nativeBuildInputs = [ autoreconfHook pkg-config ];
113
114 enableParallelBuilding = true;
115
116 meta = with lib; {
117 description = "Official monitoring plugins for Nagios/Icinga/Sensu and others";
118 homepage = "https://www.monitoring-plugins.org";
119 license = licenses.gpl3Only;
120 maintainers = with maintainers; [ thoughtpolice relrod ];
121 platforms = platforms.linux;
122 };
123}