git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #34250 from peterhoeg/p/wmi

check-wmiplus: init at 1.64

commite121bf850364dddfcdf2664ca9d195064b667510 authorPeter Hoeg <peter@hoeg.com> dateWed 25 Sep 2019, 05:09 (7 years ago) parent76e1ac47f0c4d3
3 files changed+119
pkgs/servers/monitoring/plugins/wmiplus/default.nix+77 pkgs/servers/monitoring/plugins/wmiplus/wmiplus_fix_manpage.patch+40 pkgs/top-level/all-packages.nix+2
pkgs/servers/monitoring/plugins/wmiplus/default.nixnew file+77
@@ -0,0 +1,77 @@
1+{ stdenv, fetchFromGitHub, makeWrapper, perlPackages, txt2man
2+, monitoring-plugins
3+, wmic-bin ? null }:
4+
5+stdenv.mkDerivation rec {
6+ pname = "check-wmiplus";
7+ version = "1.64";
8+
9+ # We fetch from github.com instead of the proper upstream as nix-build errors
10+ # out with 406 when trying to fetch the sources
11+ src = fetchFromGitHub {
12+ owner = "speartail";
13+ repo = "checkwmiplus";
14+ rev = "v${version}";
15+ sha256 = "1m36rd2wnc5dk4mm9q4ch67w19144dl112p9s6lhc1sh6h25ln6r";
16+ };
17+
18+ patches = [
19+ ./wmiplus_fix_manpage.patch
20+ ];
21+
22+ propagatedBuildInputs = with perlPackages; [
23+ BHooksEndOfScope ClassDataInheritable ClassInspector ClassSingleton
24+ ConfigIniFiles DateTime DateTimeLocale DateTimeTimeZone DevelStackTrace
25+ EvalClosure ExceptionClass FileShareDir ModuleImplementation ModuleRuntime
26+ MROCompat namespaceautoclean namespaceclean NumberFormat PackageStash
27+ ParamsValidate ParamsValidationCompiler RoleTiny Specio
28+ SubExporterProgressive SubIdentify TryTiny
29+ ];
30+
31+ nativeBuildInputs = [ makeWrapper txt2man ];
32+
33+ dontConfigure = true;
34+ dontBuild = true;
35+ doCheck = false; # no checks
36+
37+ postPatch = ''
38+ substituteInPlace check_wmi_plus.pl \
39+ --replace /usr/bin/wmic ${wmic-bin}/bin/wmic \
40+ --replace /etc/check_wmi_plus $out/etc/check_wmi_plus \
41+ --replace /opt/nagios/bin/plugins $out/etc/check_wmi_plus \
42+ --replace /usr/lib/nagios/plugins ${monitoring-plugins}/libexec \
43+ --replace '$base_dir/check_wmi_plus_help.pl' "$out/bin/check_wmi_plus_help.pl"
44+
45+ for f in *.pl ; do
46+ substituteInPlace $f --replace /usr/bin/perl ${perlPackages.perl}/bin/perl
47+ done
48+ '';
49+
50+ installPhase = ''
51+ runHook preInstall
52+
53+ install -Dm755 -t $out/bin *.pl
54+ install -Dm644 -t $out/share/doc/${pname} *.txt
55+ cp -r etc $out/
56+
57+ runHook postInstall
58+ '';
59+
60+ # 1. we need to wait until the main binary has been fixed up with proper perl paths before we can run it to generate the man page
61+ # 2. txt2man returns exit code 3 even if it works, so we add the || true bit
62+ postFixup = ''
63+ wrapProgram $out/bin/check_wmi_plus.pl \
64+ --set PERL5LIB "${perlPackages.makePerlPath propagatedBuildInputs}"
65+
66+ mkdir -p $out/share/man/man1
67+ $out/bin/check_wmi_plus.pl --help | txt2man -d 1970-01-01 -s 1 -t check_wmi_plus -r "Check WMI Plus ${version}" > $out/share/man/man1/check_wmi_plus.1 || true
68+ gzip $out/share/man/man1/check_wmi_plus.1
69+ '';
70+
71+ meta = with stdenv.lib; {
72+ description = "A sensu/nagios plugin using WMI to query Windows hosts";
73+ homepage = "http://edcint.co.nz/checkwmiplus";
74+ license = licenses.gpl2;
75+ maintainers = with maintainers; [ peterhoeg ];
76+ };
77+}
pkgs/servers/monitoring/plugins/wmiplus/wmiplus_fix_manpage.patchnew file+40
@@ -0,0 +1,40 @@
1+diff --git a/check_wmi_plus.makeman.sh b/check_wmi_plus.makeman.sh
2+index 38dc7a4..3fe4369 100755
3+--- a/check_wmi_plus.makeman.sh
4++++ b/check_wmi_plus.makeman.sh
5+@@ -19,15 +19,6 @@ mkdir -p "$manpage_dir/man1"
6+ # the full path to the manpage file
7+ manfile="$manpage_dir/man1/check_wmi_plus.1"
8+
9+-# if we are not running in a terminal then only show the text-based help
10+-if [ ! -t 0 ]; then
11+- # we are not running in a terminal
12+- echo "Not running in a terminal - showing text-based help"
13+- echo
14+- exec $check_wmi_plus_text_help
15+-fi
16+-
17+-
18+ usage()
19+ {
20+ cat << EOT
21+diff --git a/check_wmi_plus_help.pl b/check_wmi_plus_help.pl
22+index 3440db2..2982da2 100755
23+--- a/check_wmi_plus_help.pl
24++++ b/check_wmi_plus_help.pl
25+@@ -24,7 +24,7 @@ if ($opt_help) {
26+ # we have the script to make the manpage and have not been asked to show text only help
27+ exec ("$make_manpage_script \"$0 --itexthelp\" \"$manpage_dir\"") or print STDERR "couldn't exec $make_manpage_script: $!";
28+ } else {
29+- print "Warning: Can not access/execute Manpage script ($make_manpage_script).\nShowing help in text-only format.\n\n";
30++ # print "Warning: Can not access/execute Manpage script ($make_manpage_script).\nShowing help in text-only format.\n\n";
31+ }
32+ }
33+
34+@@ -692,4 +692,4 @@ show_ini_help_overview(1);
35+ finish_program($ERRORS{'UNKNOWN'});
36+ }
37+
38+-1;
39+\ No newline at end of file
40++1;
pkgs/top-level/all-packages.nix+2
@@ -15187,6 +15187,8 @@ in
1518715187 sensu-go-backend
1518815188 sensu-go-cli;
1518915189
15190+ check-wmiplus = callPackage ../servers/monitoring/plugins/wmiplus { };
15191+
1519015192 uchiwa = callPackage ../servers/monitoring/uchiwa { };
1519115193
1519215194 shishi = callPackage ../servers/shishi {