summary refs log tree commit diff
path: root/pkgs/servers/monitoring/plugins/labs_consol_de.nix
blob: 441d9595bbd13ed44620a46b4280f53dcadf47ef (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
69
70
71
72
{ stdenv, fetchFromGitHub, buildPerlPackage, autoreconfHook, makeWrapper
, perl, NetSNMP, coreutils, gnused, gnugrep }:

let
  owner = "lausser";

  glplugin = fetchFromGitHub {
    repo   = "GLPlugin";
    rev    = "b92a261ca4bf84e5b20d3025cc9a31ade03c474b";
    sha256 = "0kflnmpjmklq8fy2vf2h8qyvaiznymdi09z2h5qscrfi51xc9gmh";
    inherit owner;
  };

  generic = { pname, version, rev, sha256, description, ... } @ attrs:
  let
    attrs' = builtins.removeAttrs attrs [ "pname" "version" "rev" "sha256"];
  in perl.stdenv.mkDerivation rec {
    name = stdenv.lib.replaceStrings [ "-" ] [ "_" ] "${pname}-${version}";

    src = fetchFromGitHub {
      repo   = pname;
      inherit owner rev sha256;
    };

    buildInputs = [ perl NetSNMP ];

    nativeBuildInputs = [ autoreconfHook makeWrapper ];

    prePatch = with stdenv.lib; ''
      ln -s ${glplugin}/* GLPlugin
      substituteInPlace plugins-scripts/Makefile.am \
        --replace /bin/cat  ${getBin coreutils}/bin/cat \
        --replace /bin/echo ${getBin coreutils}/bin/echo \
        --replace /bin/grep ${getBin gnugrep}/bin/grep \
        --replace /bin/sed  ${getBin gnused}/bin/sed
    '';

    postInstall = ''
      test -d $out/libexec && ln -sr $out/libexec $out/bin
    '';

    postFixup = ''
      for f in $out/bin/* ; do
        wrapProgram $f --prefix PERL5LIB : $PERL5LIB
      done
    '';

    meta = with stdenv.lib; {
      homepage   = https://labs.consol.de/;
      license    = licenses.gpl2;
      maintainer = with maintainers; [ peterhoeg ];
      inherit description;
    };
  };

in {
  check-nwc-health = generic {
    pname       = "check_nwc_health";
    version     = "20170804";
    rev         = "e959b412b5cf027c82a446668e026214fdcf8df3";
    sha256      = "11l74xw62g15rqrbf9ff2bfd5iw159gwhhgbkxwdqi8sp9j6navk";
    description = "Check plugin for network equipment.";
  };

  check-ups-health = generic {
    pname       = "check_ups_health";
    version     = "20170804";
    rev         = "32a8a359ea46ec0d6f3b7aea19ddedaad63b04b9";
    sha256      = "05na48dxfxrg0i9185j1ck2795p0rw1zwcs8ra0f14cm0qw0lp4l";
    description = "Check plugin for UPSs.";
  };
}