summary refs log tree commit diff
path: root/pkgs/servers/monitoring/longview/default.nix
blob: 5459d58ceb9f87d738b3e6fdacbf5f5dd239acac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{stdenv, fetchFromGitHub, perl, perlPackages, makeWrapper, glibc }:

stdenv.mkDerivation rec {
  version = "1.1.5";
  pname = "longview";

  src = fetchFromGitHub {
    owner = "linode";
    repo = "longview";
    rev = "v${version}";
    sha256 = "1i9lli8iw8sb1bd633i82fzhx5gz85ma9d1hra41pkv2p3h823pa";
  };

  patches = [
    # log to systemd journal
    ./log-stdout.patch
  ];

  # Read all configuration from /run/longview
  postPatch = ''
    substituteInPlace Linode/Longview/Util.pm \
        --replace /var/run/longview.pid /run/longview/longview.pid \
        --replace /etc/linode /run/longview
    substituteInPlace Linode/Longview.pl \
        --replace /etc/linode /run/longview
  '';

  buildInputs = [ perl makeWrapper glibc ]
    ++ (with perlPackages; [
      LWP
      LWPProtocolHttps
      MozillaCA
      CryptSSLeay
      IOSocketInet6
      LinuxDistribution
      JSONPP
      JSON
      LogLogLite
      TryTiny
      DBI
      DBDmysql
    ]);

  dontBuild = true;

  installPhase = ''
    mkdir -p $out/bin $out/usr
    mv Linode $out
    ln -s ../Linode/Longview.pl $out/bin/longview
    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
        ${perl}/bin/h2ph -d $out ${glibc.dev}/include/$h
        mkdir -p $out/usr/include/$(dirname $h)
        mv $out${glibc.dev}/include/''${h%.h}.ph $out/usr/include/$(dirname $h)
    done
    wrapProgram $out/Linode/Longview.pl --prefix PATH : ${perl}/bin:$out/bin \
     --suffix PERL5LIB : $out/Linode --suffix PERL5LIB : $PERL5LIB \
     --suffix PERL5LIB : $out --suffix INC : $out
  '';

  meta = with stdenv.lib; {
    homepage = https://www.linode.com/longview;
    description = "Longview collects all of your system-level metrics and sends them to Linode";
    license = licenses.gpl2Plus;
    maintainers = [ maintainers.rvl ];
    inherit version;
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}