diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index ce6fea445c3..b3477fba8ae 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -355,6 +355,7 @@ ./services/monitoring/collectd.nix ./services/monitoring/das_watchdog.nix ./services/monitoring/dd-agent/dd-agent.nix + ./services/monitoring/fusion-inventory.nix ./services/monitoring/grafana.nix ./services/monitoring/graphite.nix ./services/monitoring/hdaps.nix diff --git a/nixos/modules/services/monitoring/fusion-inventory.nix b/nixos/modules/services/monitoring/fusion-inventory.nix new file mode 100644 index 00000000000..1c00f3c299e --- /dev/null +++ b/nixos/modules/services/monitoring/fusion-inventory.nix @@ -0,0 +1,66 @@ +# Fusion Inventory daemon. +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.fusionInventory; + + configFile = pkgs.writeText "fusion_inventory.conf" '' + server = ${concatStringsSep ", " cfg.servers} + + logger = stderr + + ${cfg.extraConfig} + ''; + +in { + + ###### interface + + options = { + + services.fusionInventory = { + + enable = mkEnableOption "Fusion Inventory Agent"; + + servers = mkOption { + type = types.listOf types.str; + description = '' + The urls of the OCS/GLPI servers to connect to. + ''; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = '' + Configuration that is injected verbatim into the configuration file. + ''; + }; + }; + }; + + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers = singleton { + name = "fusion-inventory"; + description = "FusionInventory user"; + }; + + systemd.services."fusion-inventory" = { + description = "Fusion Inventory Agent"; + wantedBy = [ "multi-user.target" ]; + + environment = { + OPTIONS = "--no-category=software"; + }; + serviceConfig = { + ExecStart = "${pkgs.fusionInventory}/bin/fusioninventory-agent --conf-file=${configFile} --daemon --no-fork"; + }; + }; + }; +} diff --git a/pkgs/servers/monitoring/fusion-inventory/default.nix b/pkgs/servers/monitoring/fusion-inventory/default.nix new file mode 100644 index 00000000000..2e694ede497 --- /dev/null +++ b/pkgs/servers/monitoring/fusion-inventory/default.nix @@ -0,0 +1,67 @@ +{ stdenv, fetchurl, buildPerlPackage, perlPackages +}: + +buildPerlPackage rec { + version = "2.3.18"; + name = "FusionInventory-Agent-${version}"; + src = fetchurl { + url = "mirror://cpan/authors/id/G/GR/GROUSSE/${name}.tar.gz"; + sha256 = "543d96fa61b8f2a2bc599fe9f694f19d1f2094dc5506bc514d00b8a445bc5401"; + }; + + patches = [ ./remove_software_test.patch ]; + + postPatch = '' + patchShebangs bin + ''; + + buildTools = []; + buildInputs = with perlPackages; [ + CGI + DataStructureUtil + FileCopyRecursive + HTTPProxy + HTTPServerSimple + HTTPServerSimpleAuthen + IOCapture + IOSocketSSL + IPCRun + JSON + LWPProtocolhttps + NetSNMP + TestCompile + TestDeep + TestException + TestMockModule + TestMockObject + TestNoWarnings + ]; + propagatedBuildInputs = with perlPackages; [ + FileWhich + LWP + NetIP + TextTemplate + UNIVERSALrequire + XMLTreePP + ]; + + installPhase = '' + mkdir -p $out + + cp -r bin $out + cp -r lib $out + + for cur in $out/bin/*; do + sed -e "s|./lib|$out/lib|" -i "$cur" + done + ''; + + outputs = [ "out" ]; + + meta = with stdenv.lib; { + homepage = http://www.fusioninventory.org; + description = "FusionInventory unified Agent for UNIX, Linux, Windows and MacOSX"; + license = stdenv.lib.licenses.gpl2; + maintainers = [ maintainers.phile314 ]; + }; +} diff --git a/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch b/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch new file mode 100644 index 00000000000..5449f4d3740 --- /dev/null +++ b/pkgs/servers/monitoring/fusion-inventory/remove_software_test.patch @@ -0,0 +1,54 @@ +diff --git a/t/agent/snmp/live.t b/t/agent/snmp/live.t +index 8ee7ff02c..bd5551ab3 100755 +--- a/t/agent/snmp/live.t ++++ b/t/agent/snmp/live.t +@@ -11,7 +11,7 @@ use Test::More; + use FusionInventory::Agent::XML::Response; + use FusionInventory::Agent::SNMP::Live; + +-plan tests => 12; ++plan tests => 11; + + my $snmp; + throws_ok { +@@ -52,15 +52,6 @@ throws_ok { + } qr/^Unable to resolve the UDP\/IPv4 address "none"/, + 'instanciation: unresolvable host'; + +-throws_ok { +- $snmp = FusionInventory::Agent::SNMP::Live->new( +- version => 1, +- community => 'public', +- hostname => '1.1.1.1' +- ); +-} qr/no response from host 1.1.1.1/, +-'instanciation: unresponding host'; +- + SKIP: { + skip 'live SNMP test disabled', 6 unless $ENV{TEST_LIVE_SNMP}; + +diff --git a/t/apps/agent.t b/t/apps/agent.t +index f417b4106..12207f192 100755 +--- a/t/apps/agent.t ++++ b/t/apps/agent.t +@@ -12,7 +12,7 @@ use XML::TreePP; + use FusionInventory::Agent::Tools; + use FusionInventory::Test::Utils; + +-plan tests => 34; ++plan tests => 33; + + my ($content, $out, $err, $rc); + +@@ -73,11 +73,6 @@ subtest "first inventory execution and content" => sub { + }; + + ok( +- exists $content->{REQUEST}->{CONTENT}->{SOFTWARES}, +- 'inventory has software' +-); +- +-ok( + exists $content->{REQUEST}->{CONTENT}->{ENVS}, + 'inventory has environment variables' + ); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ded5e5d5f94..35665ce6c4a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11373,6 +11373,8 @@ with pkgs; openssl = openssl_1_0_2; }; + fusionInventory = callPackage ../servers/monitoring/fusion-inventory { }; + gatling = callPackage ../servers/http/gatling { }; glabels = callPackage ../applications/graphics/glabels { }; diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix index 2cba7966bb0..14c00504d40 100644 --- a/pkgs/top-level/perl-packages.nix +++ b/pkgs/top-level/perl-packages.nix @@ -549,6 +549,19 @@ let self = _self // overrides; _self = with self; { }; }; + AuthenSimple = buildPerlPackage rec { + name = "Authen-Simple-0.5"; + src = fetchurl { + url = "mirror://cpan/authors/id/C/CH/CHANSEN/${name}.tar.gz"; + sha256 = "02cddab47f8bf1a1cbd4c9bf8d258f6d05111499c33f8315e7244812f72613aa"; + }; + propagatedBuildInputs = [ ClassAccessor ClassDataInheritable CryptPasswdMD5 ParamsValidate ]; + meta = { + description = "Simple Authentication"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + autobox = buildPerlPackage rec { name = "autobox-2.84"; src = fetchurl { @@ -3177,6 +3190,19 @@ let self = _self // overrides; _self = with self; { }; }; + DataStructureUtil = buildPerlPackage rec { + name = "Data-Structure-Util-0.16"; + src = fetchurl { + url = "mirror://cpan/authors/id/A/AN/ANDYA/${name}.tar.gz"; + sha256 = "9cd42a13e65cb15f3a76296eb9a134da220168ec747c568d331a50ae7a2ddbc6"; + }; + buildInputs = [ TestPod ]; + meta = { + description = "Change nature of data within a structure"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + DataTaxi = buildPerlPackage { name = "Data-Taxi-0.96"; propagatedBuildInputs = [DebugShowStuff]; @@ -6824,6 +6850,22 @@ let self = _self // overrides; _self = with self; { buildInputs = [ TestMore ]; }; + HTTPProxy = buildPerlPackage rec { + name = "HTTP-Proxy-0.304"; + src = fetchurl { + url = "mirror://cpan/authors/id/B/BO/BOOK/${name}.tar.gz"; + sha256 = "b05290534ec73625c21a0565fc35170890dab163843d95331c292c23f504c69d"; + }; + buildInputs = [ HTMLParser ]; + propagatedBuildInputs = [ HTTPDaemon HTTPDate HTTPMessage LWP ]; + meta = { + description = "A pure Perl HTTP proxy"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + # tests fail because they require network access + doCheck = false; + }; + HTTPRequestAsCGI = buildPerlPackage rec { name = "HTTP-Request-AsCGI-1.2"; src = fetchurl { @@ -6857,6 +6899,18 @@ let self = _self // overrides; _self = with self; { }; }; + HTTPServerSimpleAuthen = buildPerlPackage rec { + name = "HTTP-Server-Simple-Authen-0.04"; + src = fetchurl { + url = "mirror://cpan/authors/id/M/MI/MIYAGAWA/${name}.tar.gz"; + sha256 = "2dddc8ab9dc8986980151e4ba836a6bbf091f45cf195be1768ebdb4a993ed59b"; + }; + propagatedBuildInputs = [ AuthenSimple HTTPServerSimple ]; + meta = { + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + HTTPServerSimpleMason = buildPerlPackage { name = "HTTP-Server-Simple-Mason-0.14"; src = fetchurl { @@ -6995,6 +7049,17 @@ let self = _self // overrides; _self = with self; { }; }; + IOCapture = buildPerlPackage rec { + name = "IO-Capture-0.05"; + src = fetchurl { + url = "mirror://cpan/authors/id/R/RE/REYNOLDS/${name}.tar.gz"; + sha256 = "c2c15a254ca74fb8c57d25d7b6cbcaff77a3b4fb5695423f1f80bb423abffea9"; + }; + meta = { + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + IOCaptureOutput = buildPerlPackage rec { name = "IO-CaptureOutput-1.1104"; src = fetchurl { @@ -13314,6 +13379,20 @@ let self = _self // overrides; _self = with self; { }; }; + TestCompile = buildPerlPackage rec { + name = "Test-Compile-v1.3.0"; + src = fetchurl { + url = "mirror://cpan/authors/id/E/EG/EGILES/${name}.tar.gz"; + sha256 = "77527e9477ac5260443c756367a7f7bc3d8f6c6ebbc561b0b2fb3f79303bad33"; + }; + buildInputs = [ ModuleBuild ]; + propagatedBuildInputs = [ UNIVERSALrequire ]; + meta = { + description = "Check whether Perl files compile correctly"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + TestCPANMeta = buildPerlPackage { name = "Test-CPAN-Meta-0.23"; src = fetchurl { @@ -15857,6 +15936,19 @@ let self = _self // overrides; _self = with self; { }; }; + XMLTreePP = buildPerlPackage rec { + name = "XML-TreePP-0.43"; + src = fetchurl { + url = "mirror://cpan/authors/id/K/KA/KAWASAKI/${name}.tar.gz"; + sha256 = "7fbe2d6430860059894aeeebf75d4cacf1bf8d7b75294eb87d8e1502f81bd760"; + }; + propagatedBuildInputs = [ LWP ]; + meta = { + description = "Pure Perl implementation for parsing/writing XML documents"; + license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ]; + }; + }; + XMLTwig = buildPerlPackage rec { name = "XML-Twig-3.49"; src = fetchurl {