about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/monitoring/nagios/plugins/zfs.nix
blob: 0ec84722d20126dd1c83b49192863bee0a51c8bf (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
{ lib
, stdenv
, fetchFromGitHub
, python3
, zfs
, sudo
}:

stdenv.mkDerivation rec {
  pname = "check_zfs";
  version = "2.0";

  src = fetchFromGitHub {
    owner = "zlacelle";
    repo = "nagios_check_zfs_linux";
    rev = version;
    sha256 = "gPLCNt6hp4E94s9/PRgsnBN5XXQQ+s2MGcgRFeknXg4=";
  };

  buildInputs = [ python3 zfs sudo ];

  postPatch = ''
    patchShebangs check_zfs.py
    substituteInPlace check_zfs.py \
      --replace "'/usr/bin/sudo'" "'${sudo}/bin/sudo'" \
      --replace "'/sbin/zpool'" "'${zfs}/bin/zpool'" \
      --replace "'/sbin/zfs'" "'${zfs}/bin/zfs'"
  '';

  installPhase = ''
    runHook preInstall

    install -Dm 755 check_zfs.py $out/bin/check_zfs

    runHook postInstall
  '';

  meta = with lib; {
    description = "Check the health, capacity, fragmentation, and other things for use with Nagios monitoring";
    mainProgram = "check_zfs";
    homepage = "https://github.com/zlacelle/nagios_check_zfs_linux";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ mariaa144 ];
  };
}