From 39bf20e7a3d9828822fcb1c531c2abdb54dc7bd9 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 7 Aug 2017 22:56:15 +0800 Subject: [PATCH 1/4] check-nwc-health and check-ups-health: init at 20170804 --- .../monitoring/plugins/labs_consol_de.nix | 72 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 + 2 files changed, 75 insertions(+) create mode 100644 pkgs/servers/monitoring/plugins/labs_consol_de.nix diff --git a/pkgs/servers/monitoring/plugins/labs_consol_de.nix b/pkgs/servers/monitoring/plugins/labs_consol_de.nix new file mode 100644 index 00000000000..441d9595bbd --- /dev/null +++ b/pkgs/servers/monitoring/plugins/labs_consol_de.nix @@ -0,0 +1,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."; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7c26ba7c826..2dc4b9c0ee7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11340,6 +11340,9 @@ with pkgs; munin = callPackage ../servers/monitoring/munin { }; nagiosPluginsOfficial = callPackage ../servers/monitoring/nagios/plugins/official-2.x.nix { }; + inherit (callPackage ../servers/monitoring/plugins/labs_consol_de.nix { inherit (perlPackages) NetSNMP; }) + check-nwc-health + check-ups-health; neo4j = callPackage ../servers/nosql/neo4j { }; From 6ddd4cec8051cfa02cca88b142c2a4eaf4499d7a Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 7 Aug 2017 23:24:07 +0800 Subject: [PATCH 2/4] check-esxi-hardware: init at 20161013 --- pkgs/servers/monitoring/plugins/esxi.nix | 37 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 39 insertions(+) create mode 100644 pkgs/servers/monitoring/plugins/esxi.nix diff --git a/pkgs/servers/monitoring/plugins/esxi.nix b/pkgs/servers/monitoring/plugins/esxi.nix new file mode 100644 index 00000000000..312caab954b --- /dev/null +++ b/pkgs/servers/monitoring/plugins/esxi.nix @@ -0,0 +1,37 @@ +{ stdenv, fetchFromGitHub, python2Packages }: + +let + bName = "check_esxi_hardware"; + pName = stdenv.lib.replaceStrings [ "_" ] [ "-" ] "${bName}"; + +in python2Packages.buildPythonApplication rec { + name = "${pName}-${version}"; + version = "20161013"; + + src = fetchFromGitHub { + owner = "Napsty"; + repo = bName; + rev = version; + sha256 = "19zybcg62dqcinixnp1p8zw916x3w7xvy6dlsmn347iigfa5s55s"; + }; + + dontBuild = true; + doCheck = false; + + installPhase = '' + runHook preInstall + + install -Dm755 -t $out/bin ${bName}.py + install -Dm644 -t $out/share/doc/${pName} README.md + + runHook postInstall + ''; + + propagatedBuildInputs = with python2Packages; [ pywbem ]; + + meta = with stdenv.lib; { + homepage = https://www.claudiokuenzler.com/nagios-plugins/; + license = licenses.gpl2; + maintainer = with maintainers; [ peterhoeg ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2dc4b9c0ee7..c2ad6955a4e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11346,6 +11346,8 @@ with pkgs; neo4j = callPackage ../servers/nosql/neo4j { }; + check-esxi-hardware = callPackage ../servers/monitoring/plugins/esxi.nix {}; + net_snmp = callPackage ../servers/monitoring/net-snmp { # https://sourceforge.net/p/net-snmp/bugs/2712/ # remove after net-snmp > 5.7.3 From f49aa9029755bb0b0bd2a964528c7731b2d3f969 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 7 Aug 2017 22:56:54 +0800 Subject: [PATCH 3/4] monitoring-plugins: rename from nagiosPluginsOfficial The upstream project has renamed itself. We now stick this into a folder where we can keep other shared monitoring plugins. --- .../nagios/plugins/official-2.x.nix | 36 ---------- pkgs/servers/monitoring/plugins/default.nix | 71 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +- 3 files changed, 74 insertions(+), 37 deletions(-) delete mode 100644 pkgs/servers/monitoring/nagios/plugins/official-2.x.nix create mode 100644 pkgs/servers/monitoring/plugins/default.nix diff --git a/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix b/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix deleted file mode 100644 index 67c3954ef56..00000000000 --- a/pkgs/servers/monitoring/nagios/plugins/official-2.x.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ stdenv, fetchurl, openssh, openssl }: - -stdenv.mkDerivation rec { - name = "nagios-plugins-${version}"; - version = "2.2.0"; - - src = fetchurl { - url = "http://nagios-plugins.org/download/${name}.tar.gz"; - sha256 = "074yia04py5y07sbgkvri10dv8nf41kqq1x6kmwqcix5vvm9qyy3"; - }; - - # !!! Awful hack. Grrr... this of course only works on NixOS. - # Anyway the check that configure performs to figure out the ping - # syntax is totally impure, because it runs an actual ping to - # localhost (which won't work for ping6 if IPv6 support isn't - # configured on the build machine). - preConfigure= " - configureFlagsArray=( - --with-ping-command='/run/wrappers/bin/ping -4 -n -U -w %d -c %d %s' - --with-ping6-command='/run/wrappers/bin/ping -6 -n -U -w %d -c %d %s' - ) - "; - - postInstall = "ln -s libexec $out/bin"; - - # !!! make openssh a runtime dependency only - buildInputs = [ openssh openssl ]; - - meta = { - description = "Official plugins for Nagios"; - homepage = http://www.nagios.org/download/plugins; - license = stdenv.lib.licenses.gpl2; - platforms = stdenv.lib.platforms.linux; - maintainers = with stdenv.lib.maintainers; [ thoughtpolice relrod ]; - }; -} diff --git a/pkgs/servers/monitoring/plugins/default.nix b/pkgs/servers/monitoring/plugins/default.nix new file mode 100644 index 00000000000..808257ca121 --- /dev/null +++ b/pkgs/servers/monitoring/plugins/default.nix @@ -0,0 +1,71 @@ +{ stdenv, fetchFromGitHub, autoreconfHook +, coreutils, gnugrep, gnused, lm_sensors, net_snmp, openssh, openssl, perl }: + +with stdenv.lib; + +let + majorVersion = "2.2"; + minorVersion = ".0"; + + binPath = makeBinPath [ coreutils gnugrep gnused lm_sensors net_snmp ]; + +in stdenv.mkDerivation rec { + name = "monitoring-plugins-${majorVersion}${minorVersion}"; + + src = fetchFromGitHub { + owner = "monitoring-plugins"; + repo = "monitoring-plugins"; + rev = "v${majorVersion}"; + sha256 = "1pw7i6d2cnb5nxi2lbkwps2qzz04j9zd86fzpv9ka896b4aqrwv1"; + }; + + # !!! Awful hack. Grrr... this of course only works on NixOS. + # Anyway the check that configure performs to figure out the ping + # syntax is totally impure, because it runs an actual ping to + # localhost (which won't work for ping6 if IPv6 support isn't + # configured on the build machine). + preConfigure= '' + substituteInPlace po/Makefile.in.in \ + --replace /bin/sh ${stdenv.shell} + + sed -i configure.ac \ + -e 's|^DEFAULT_PATH=.*|DEFAULT_PATH=\"\$out/bin:/run/wrappers/bin:${binPath}\"|' + + configureFlagsArray=( + --with-ping-command='/run/wrappers/bin/ping -4 -n -U -w %d -c %d %s' + --with-ping6-command='/run/wrappers/bin/ping -6 -n -U -w %d -c %d %s' + ) + ''; + + # !!! make openssh a runtime dependency only + buildInputs = [ net_snmp openssh openssl perl ]; + + nativeBuildInputs = [ autoreconfHook ]; + + enableParallelBuilding = true; + + # For unknown reasons the installer tries executing $out/share and fails if + # it doesn't succeed. + # So we create it and remove it again later. + preBuild = '' + mkdir -p $out + cat <<_EOF > $out/share +#!${stdenv.shell} +exit 0 +_EOF + chmod 755 $out/share + ''; + + postInstall = '' + rm $out/share + ln -s libexec $out/bin + ''; + + meta = { + description = "Official monitoring plugins for Nagios/Ichinga/Sensu and others."; + homepage = https://www.monitoring-plugins.org; + license = licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ thoughtpolice relrod ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c2ad6955a4e..2bf6c719145 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11339,7 +11339,9 @@ with pkgs; munin = callPackage ../servers/monitoring/munin { }; - nagiosPluginsOfficial = callPackage ../servers/monitoring/nagios/plugins/official-2.x.nix { }; + monitoring-plugins = callPackage ../servers/monitoring/plugins { }; + nagiosPluginsOfficial = monitoring-plugins; + inherit (callPackage ../servers/monitoring/plugins/labs_consol_de.nix { inherit (perlPackages) NetSNMP; }) check-nwc-health check-ups-health; From b6941c45009b5e02d2de7a89d3319df03d11ecf8 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Mon, 7 Aug 2017 23:23:48 +0800 Subject: [PATCH 4/4] pywbem: init at 0.10.0 --- .../python-modules/pywbem/default.nix | 44 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 3 ++ 2 files changed, 47 insertions(+) create mode 100644 pkgs/development/python-modules/pywbem/default.nix diff --git a/pkgs/development/python-modules/pywbem/default.nix b/pkgs/development/python-modules/pywbem/default.nix new file mode 100644 index 00000000000..b728d4f6b94 --- /dev/null +++ b/pkgs/development/python-modules/pywbem/default.nix @@ -0,0 +1,44 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, libxml2 +, m2crypto, ply, pyyaml, six +, httpretty, lxml, mock, pytest, requests +}: + +buildPythonPackage rec { + name = "pywbem-${version}"; + version = "0.10.0"; + + src = fetchFromGitHub { + owner = "pywbem"; + repo = "pywbem"; + rev = "v${version}"; + sha256 = "0jcwklip03xcni0dvsk9va8ilqz21g4fxwqd5kzvv91slaadfcym"; + }; + + propagatedBuildInputs = [ m2crypto ply pyyaml six ]; + + checkInputs = [ httpretty lxml mock pytest requests ]; + + # 1 test fails because it doesn't like running in our sandbox. Deleting the + # whole file is admittedly a little heavy-handed but at least the vast + # majority of tests are run. + checkPhase = '' + rm testsuite/testclient/networkerror.yaml + + substituteInPlace makefile \ + --replace "PYTHONPATH=." "" \ + --replace '--cov $(package_name) --cov-config coveragerc' "" + + for f in testsuite/test_cim_xml.py testsuite/validate.py ; do + substituteInPlace $f --replace "'xmllint" "'${stdenv.lib.getBin libxml2}/bin/xmllint" + done + + make PATH=$PATH:${stdenv.lib.getBin libxml2}/bin test + ''; + + meta = with stdenv.lib; { + description = "Support for the WBEM standard for systems management."; + homepage = http://pywbem.github.io/pywbem/; + license = licenses.gpl2; + maintainers = with maintainers; [ peterhoeg ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5a817b75292..6aca05cf2c5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -29464,6 +29464,9 @@ EOF }; }; + # We need "normal" libxml2 and not the python package by the same name. + pywbem = callPackage ../development/python-modules/pywbem { libxml2 = pkgs.libxml2; }; + unicorn = buildPythonPackage rec { name = "unicorn-${version}"; version = "1.0.1";