1{lib, stdenv, fetchFromGitHub, perl, perlPackages, makeWrapper, glibc }:
2
3stdenv.mkDerivation rec {
4 version = "1.1.5";
5 pname = "longview";
6
7 src = fetchFromGitHub {
8 owner = "linode";
9 repo = "longview";
10 rev = "v${version}";
11 sha256 = "1i9lli8iw8sb1bd633i82fzhx5gz85ma9d1hra41pkv2p3h823pa";
12 };
13
14 patches = [
15 # log to systemd journal
16 ./log-stdout.patch
17 ];
18
19 # Read all configuration from /run/longview
20 postPatch = ''
21 substituteInPlace Linode/Longview/Util.pm \
22 --replace /var/run/longview.pid /run/longview/longview.pid \
23 --replace /etc/linode /run/longview
24 substituteInPlace Linode/Longview.pl \
25 --replace /etc/linode /run/longview
26 '';
27
28 nativeBuildInputs = [ makeWrapper ];
29 buildInputs = [ perl glibc ]
30 ++ (with perlPackages; [
31 LWP
32 LWPProtocolHttps
33 MozillaCA
34 CryptSSLeay
35 IOSocketINET6
36 LinuxDistribution
37 JSONPP
38 JSON
39 LogLogLite
40 TryTiny
41 DBI
42 DBDmysql
43 ]);
44
45 dontBuild = true;
46
47 installPhase = ''
48 mkdir -p $out/bin $out/usr
49 mv Linode $out
50 ln -s ../Linode/Longview.pl $out/bin/longview
51 for h in syscall.h sys/syscall.h asm/unistd.h asm/unistd_32.h asm/unistd_64.h bits/wordsize.h bits/syscall.h; do
52 ${perl}/bin/h2ph -d $out ${glibc.dev}/include/$h
53 mkdir -p $out/usr/include/$(dirname $h)
54 mv $out${glibc.dev}/include/''${h%.h}.ph $out/usr/include/$(dirname $h)
55 done
56 wrapProgram $out/Linode/Longview.pl --prefix PATH : ${perl}/bin:$out/bin \
57 --suffix PERL5LIB : $out/Linode --suffix PERL5LIB : $PERL5LIB \
58 --suffix PERL5LIB : $out --suffix INC : $out
59 '';
60
61 meta = with lib; {
62 homepage = "https://www.linode.com/longview";
63 description = "Collects all of your system-level metrics and sends them to Linode";
64 license = licenses.gpl2Plus;
65 maintainers = [ maintainers.rvl ];
66 inherit version;
67 platforms = [ "x86_64-linux" "i686-linux" ];
68 };
69}