From b102c5f715ff3e92552a3a26ef4840546b49a88e Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 16 Aug 2021 21:51:08 +0200 Subject: [PATCH 1/5] collectd: add dependencies for plugins notify_email, openldap, openipmi, xencpu --- pkgs/tools/system/collectd/plugins.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index dd578cd6393b..edda0e8fadfb 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -6,6 +6,7 @@ , jdk , libatasmart , libdbi +, libesmtp , libgcrypt , libmemcached, cyrus_sasl , libmodbus @@ -19,12 +20,14 @@ , libvirt , libxml2 , libapparmor, libcap_ng, numactl -, lvm2 , lua +, lvm2 , lm_sensors , mongoc , mosquitto , net-snmp +, openldap +, openipmi , perl , postgresql , protobufc @@ -35,6 +38,7 @@ , rrdtool , udev , varnish +, xen , yajl # Defaults to `null` for all supported plugins, # list of plugin names for a custom build @@ -122,7 +126,9 @@ let intel_rdt = {}; interface = {}; ipc = {}; - ipmi = {}; + ipmi = { + buildInputs = [ openipmi ]; + }; iptables = { buildInputs = [ libpcap @@ -200,6 +206,12 @@ let openldap = {}; openvpn = {}; oracle = {}; + notify_email = { + buildInputs = [ libesmtp ]; + }; + openldap = { + buildInputs = [ openldap ]; + }; ovs_events = { buildInputs = [ yajl ]; }; @@ -318,6 +330,9 @@ let zfs_arc = {}; zone = {}; zookeeper = {}; + xencpu = { + buildInputs = [ xen ]; + }; }; configureFlags = From a064c4d533f8490ab5ab99388e154ff3ce0be10b Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 16 Aug 2021 21:52:03 +0200 Subject: [PATCH 2/5] collectd: remove virt plugin dependencies that are no longer used --- pkgs/tools/system/collectd/plugins.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index edda0e8fadfb..ecafa587eddc 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -292,11 +292,7 @@ let }; virt = { buildInputs = [ libvirt libxml2 yajl ] ++ - lib.optionals stdenv.isLinux [ lvm2 udev - # those might be no longer required when https://github.com/NixOS/nixpkgs/pull/51767 - # is merged - libapparmor numactl libcap_ng - ]; + lib.optionals stdenv.isLinux [ lvm2 udev ]; }; vmem = {}; vserver = {}; From 39adcbca307cf8f0c7bedf457676d629d3a60754 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 16 Aug 2021 21:54:05 +0200 Subject: [PATCH 3/5] collectd: reduce plugin configuration by configuring --disable-all-plugins --- pkgs/tools/system/collectd/plugins.nix | 131 ++----------------------- 1 file changed, 7 insertions(+), 124 deletions(-) diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index ecafa587eddc..3ed2ff70998c 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -47,10 +47,9 @@ }: let - # All plugins and their dependencies. - # Please help complete this! + # Plugins that have dependencies. + # Please help to extend these! plugins = { - aggregation = {}; amqp = { buildInputs = [ yajl ] ++ lib.optionals stdenv.isLinux [ rabbitmq-c ]; @@ -58,13 +57,9 @@ let apache = { buildInputs = [ curl ]; }; - apcups = {}; - apple_sensors = {}; - aquaero = {}; ascent = { buildInputs = [ curl libxml2 ]; }; - barometer = {}; battery = { buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.IOKit @@ -76,14 +71,6 @@ let ceph = { buildInputs = [ yajl ]; }; - cgroups = {}; - chrony = {}; - conntrack = {}; - contextswitch = {}; - cpu = {}; - cpufreq = {}; - cpusleep = {}; - csv = {}; curl = { buildInputs = [ curl ]; }; @@ -96,7 +83,6 @@ let dbi = { buildInputs = [ libdbi ]; }; - df = {}; disk = { buildInputs = lib.optionals stdenv.isLinux [ udev @@ -107,25 +93,6 @@ let dns = { buildInputs = [ libpcap ]; }; - dpdkevents = {}; - dpdkstat = {}; - drbd = {}; - email = {}; - entropy = {}; - ethstat = {}; - exec = {}; - fhcount = {}; - filecount = {}; - fscache = {}; - gmond = {}; - gps = {}; - grpc = {}; - hddtemp = {}; - hugepages = {}; - intel_pmu = {}; - intel_rdt = {}; - interface = {}; - ipc = {}; ipmi = { buildInputs = [ openipmi ]; }; @@ -136,49 +103,29 @@ let iptables libmnl ]; }; - ipvs = {}; - irq = {}; java = { buildInputs = [ jdk libgcrypt libxml2 ]; }; - load = {}; - logfile = {}; log_logstash = { buildInputs = [ yajl ]; }; - lpar = {}; lua = { buildInputs = [ lua ]; }; - lvm = {}; - madwifi = {}; - match_empty_counter = {}; - match_hashed = {}; - match_regex = {}; - match_timediff = {}; - match_value = {}; - mbmon = {}; - mcelog = {}; - md = {}; memcachec = { buildInputs = [ libmemcached cyrus_sasl ]; }; - memcached = {}; - memory = {}; - mic = {}; modbus = { buildInputs = lib.optionals stdenv.isLinux [ libmodbus ]; }; mqtt = { buildInputs = [ mosquitto ]; }; - multimeter = {}; mysql = { buildInputs = lib.optionals (libmysqlclient != null) [ libmysqlclient ]; }; - netapp = {}; netlink = { buildInputs = [ libpcap @@ -189,23 +136,12 @@ let network = { buildInputs = [ libgcrypt ]; }; - nfs = {}; nginx = { buildInputs = [ curl ]; }; notify_desktop = { buildInputs = [ libnotify gdk-pixbuf ]; }; - notify_email = {}; - notify_nagios = {}; - ntpd = {}; - numa = {}; - nut = {}; - olsrd = {}; - onewire = {}; - openldap = {}; - openvpn = {}; - oracle = {}; notify_email = { buildInputs = [ libesmtp ]; }; @@ -221,7 +157,6 @@ let perl = { buildInputs = [ perl ]; }; - pf = {}; pinba = { buildInputs = [ protobufc ]; }; @@ -231,16 +166,12 @@ let postgresql = { buildInputs = [ postgresql ]; }; - powerdns = {}; - processes = {}; - protocols = {}; python = { buildInputs = [ python ]; }; redis = { buildInputs = [ hiredis ]; }; - routeros = {}; rrdcached = { buildInputs = [ rrdtool libxml2 ]; }; @@ -250,7 +181,6 @@ let sensors = { buildInputs = lib.optionals stdenv.isLinux [ lm_sensors ]; }; - serial = {}; sigrok = { buildInputs = lib.optionals stdenv.isLinux [ libsigrok udev ]; }; @@ -263,30 +193,6 @@ let snmp_agent = { buildInputs = lib.optionals stdenv.isLinux [ net-snmp ]; }; - statsd = {}; - swap = {}; - synproxy = {}; - syslog = {}; - table = {}; - tail_csv = {}; - tail = {}; - tape = {}; - target_notification = {}; - target_replace = {}; - target_scale = {}; - target_set = {}; - target_v5upgrade = {}; - tcpconns = {}; - teamspeak2 = {}; - ted = {}; - thermal = {}; - threshold = {}; - tokyotyrant = {}; - turbostat = {}; - unixsock = {}; - uptime = {}; - users = {}; - uuid = {}; varnish = { buildInputs = [ curl varnish ]; }; @@ -294,10 +200,6 @@ let buildInputs = [ libvirt libxml2 yajl ] ++ lib.optionals stdenv.isLinux [ lvm2 udev ]; }; - vmem = {}; - vserver = {}; - wireless = {}; - write_graphite = {}; write_http = { buildInputs = [ curl yajl ]; }; @@ -319,37 +221,18 @@ let write_riemann = { buildInputs = [ protobufc riemann_c_client ]; }; - write_sensu = {}; - write_tsdb = {}; - xencpu = {}; - xmms = {}; - zfs_arc = {}; - zone = {}; - zookeeper = {}; xencpu = { buildInputs = [ xen ]; }; }; - configureFlags = - if enabledPlugins == null - then [] - else (map (plugin: "--enable-${plugin}") enabledPlugins) ++ - (map (plugin: "--disable-${plugin}") - (builtins.filter (plugin: ! builtins.elem plugin enabledPlugins) - (builtins.attrNames plugins)) - ); + configureFlags = lib.optionals (enabledPlugins != null) ( + [ "--disable-all-plugins" ] + ++ (map (plugin: "--enable-${plugin}") enabledPlugins)); pluginBuildInputs = plugin: - if ! builtins.hasAttr plugin plugins - then throw "Unknown collectd plugin: ${plugin}" - else - let - pluginAttrs = builtins.getAttr plugin plugins; - in - if pluginAttrs ? "buildInputs" - then pluginAttrs.buildInputs - else []; + lib.optionals (plugins ? ${plugin} && plugins.${plugin} ? buildInputs) + plugins.${plugin}.buildInputs; buildInputs = if enabledPlugins == null From 11a144c6f3ae206cabba6cf6d875eeccdf2d25f4 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 16 Aug 2021 21:58:21 +0200 Subject: [PATCH 4/5] collectd: shorten plugins buildInputs definition --- pkgs/tools/system/collectd/plugins.nix | 248 ++++++++----------------- 1 file changed, 74 insertions(+), 174 deletions(-) diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index 3ed2ff70998c..df99c60c3ef0 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -47,183 +47,83 @@ }: let + inherit (darwin.apple_sdk.frameworks) IOKit; + # Plugins that have dependencies. # Please help to extend these! plugins = { - amqp = { - buildInputs = [ yajl ] ++ - lib.optionals stdenv.isLinux [ rabbitmq-c ]; - }; - apache = { - buildInputs = [ curl ]; - }; - ascent = { - buildInputs = [ curl libxml2 ]; - }; - battery = { - buildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.IOKit - ]; - }; - bind = { - buildInputs = [ curl libxml2 ]; - }; - ceph = { - buildInputs = [ yajl ]; - }; - curl = { - buildInputs = [ curl ]; - }; - curl_json = { - buildInputs = [ curl yajl ]; - }; - curl_xml = { - buildInputs = [ curl libxml2 ]; - }; - dbi = { - buildInputs = [ libdbi ]; - }; - disk = { - buildInputs = lib.optionals stdenv.isLinux [ - udev - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.IOKit - ]; - }; - dns = { - buildInputs = [ libpcap ]; - }; - ipmi = { - buildInputs = [ openipmi ]; - }; - iptables = { - buildInputs = [ - libpcap - ] ++ lib.optionals stdenv.isLinux [ - iptables libmnl - ]; - }; - java = { - buildInputs = [ jdk libgcrypt libxml2 ]; - }; - log_logstash = { - buildInputs = [ yajl ]; - }; - lua = { - buildInputs = [ lua ]; - }; - memcachec = { - buildInputs = [ libmemcached cyrus_sasl ]; - }; - modbus = { - buildInputs = lib.optionals stdenv.isLinux [ libmodbus ]; - }; - mqtt = { - buildInputs = [ mosquitto ]; - }; - mysql = { - buildInputs = lib.optionals (libmysqlclient != null) [ - libmysqlclient - ]; - }; - netlink = { - buildInputs = [ - libpcap - ] ++ lib.optionals stdenv.isLinux [ - libmnl - ]; - }; - network = { - buildInputs = [ libgcrypt ]; - }; - nginx = { - buildInputs = [ curl ]; - }; - notify_desktop = { - buildInputs = [ libnotify gdk-pixbuf ]; - }; - notify_email = { - buildInputs = [ libesmtp ]; - }; - openldap = { - buildInputs = [ openldap ]; - }; - ovs_events = { - buildInputs = [ yajl ]; - }; - ovs_stats = { - buildInputs = [ yajl ]; - }; - perl = { - buildInputs = [ perl ]; - }; - pinba = { - buildInputs = [ protobufc ]; - }; - ping = { - buildInputs = [ liboping ]; - }; - postgresql = { - buildInputs = [ postgresql ]; - }; - python = { - buildInputs = [ python ]; - }; - redis = { - buildInputs = [ hiredis ]; - }; - rrdcached = { - buildInputs = [ rrdtool libxml2 ]; - }; - rrdtool = { - buildInputs = [ rrdtool libxml2 ]; - }; - sensors = { - buildInputs = lib.optionals stdenv.isLinux [ lm_sensors ]; - }; - sigrok = { - buildInputs = lib.optionals stdenv.isLinux [ libsigrok udev ]; - }; - smart = { - buildInputs = lib.optionals stdenv.isLinux [ libatasmart udev ]; - }; - snmp = { - buildInputs = lib.optionals stdenv.isLinux [ net-snmp ]; - }; - snmp_agent = { - buildInputs = lib.optionals stdenv.isLinux [ net-snmp ]; - }; - varnish = { - buildInputs = [ curl varnish ]; - }; - virt = { - buildInputs = [ libvirt libxml2 yajl ] ++ - lib.optionals stdenv.isLinux [ lvm2 udev ]; - }; - write_http = { - buildInputs = [ curl yajl ]; - }; - write_kafka = { - buildInputs = [ yajl rdkafka ]; - }; - write_log = { - buildInputs = [ yajl ]; - }; - write_mongodb = { - buildInputs = [ mongoc ]; - }; - write_prometheus = { - buildInputs = [ protobufc libmicrohttpd ]; - }; - write_redis = { - buildInputs = [ hiredis ]; - }; - write_riemann = { - buildInputs = [ protobufc riemann_c_client ]; - }; - xencpu = { - buildInputs = [ xen ]; - }; + amqp.buildInputs = [ + yajl + ] ++ lib.optionals stdenv.isLinux [ rabbitmq-c ]; + apache.buildInputs = [ curl ]; + ascent.buildInputs = [ curl libxml2 ]; + battery.buildInputs = lib.optionals stdenv.isDarwin [ + IOKit + ]; + bind.buildInputs = [ curl libxml2 ]; + ceph.buildInputs = [ yajl ]; + curl.buildInputs = [ curl ]; + curl_json.buildInputs = [ curl yajl ]; + curl_xml.buildInputs = [ curl libxml2 ]; + dbi.buildInputs = [ libdbi ]; + disk.buildInputs = lib.optionals stdenv.isLinux [ + udev + ] ++ lib.optionals stdenv.isDarwin [ + IOKit + ]; + dns.buildInputs = [ libpcap ]; + ipmi.buildInputs = [ openipmi ]; + iptables.buildInputs = [ + libpcap + ] ++ lib.optionals stdenv.isLinux [ + iptables libmnl + ]; + java.buildInputs = [ jdk libgcrypt libxml2 ]; + log_logstash.buildInputs = [ yajl ]; + lua.buildInputs = [ lua ]; + memcachec.buildInputs = [ libmemcached cyrus_sasl ]; + modbus.buildInputs = lib.optionals stdenv.isLinux [ libmodbus ]; + mqtt.buildInputs = [ mosquitto ]; + mysql.buildInputs = lib.optionals (libmysqlclient != null) [ + libmysqlclient + ]; + netlink.buildInputs = [ + libpcap + ] ++ lib.optionals stdenv.isLinux [ + libmnl + ]; + network.buildInputs = [ libgcrypt ]; + nginx.buildInputs = [ curl ]; + notify_desktop.buildInputs = [ libnotify gdk-pixbuf ]; + notify_email.buildInputs = [ libesmtp ]; + openldap.buildInputs = [ openldap ]; + ovs_events.buildInputs = [ yajl ]; + ovs_stats.buildInputs = [ yajl ]; + perl.buildInputs = [ perl ]; + pinba.buildInputs = [ protobufc ]; + ping.buildInputs = [ liboping ]; + postgresql.buildInputs = [ postgresql ]; + python.buildInputs = [ python ]; + redis.buildInputs = [ hiredis ]; + rrdcached.buildInputs = [ rrdtool libxml2 ]; + rrdtool.buildInputs = [ rrdtool libxml2 ]; + sensors.buildInputs = lib.optionals stdenv.isLinux [ lm_sensors ]; + sigrok.buildInputs = lib.optionals stdenv.isLinux [ libsigrok udev ]; + smart.buildInputs = lib.optionals stdenv.isLinux [ libatasmart udev ]; + snmp.buildInputs = lib.optionals stdenv.isLinux [ net-snmp ]; + snmp_agent.buildInputs = lib.optionals stdenv.isLinux [ net-snmp ]; + varnish.buildInputs = [ curl varnish ]; + virt.buildInputs = [ + libvirt libxml2 yajl + ] ++ lib.optionals stdenv.isLinux [ lvm2 udev ]; + write_http.buildInputs = [ curl yajl ]; + write_kafka.buildInputs = [ yajl rdkafka ]; + write_log.buildInputs = [ yajl ]; + write_mongodb.buildInputs = [ mongoc ]; + write_prometheus.buildInputs = [ protobufc libmicrohttpd ]; + write_redis.buildInputs = [ hiredis ]; + write_riemann.buildInputs = [ protobufc riemann_c_client ]; + xencpu.buildInputs = [ xen ]; }; configureFlags = lib.optionals (enabledPlugins != null) ( From 4dacd7461fa6f5bd0f4cb15e1f996e79e8379f42 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 21 Aug 2021 01:40:32 +0200 Subject: [PATCH 5/5] collectd: move IOKit input to all-packages.nix --- pkgs/tools/system/collectd/plugins.nix | 3 +-- pkgs/top-level/all-packages.nix | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index df99c60c3ef0..6438a545a485 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -40,6 +40,7 @@ , varnish , xen , yajl +, IOKit # Defaults to `null` for all supported plugins, # list of plugin names for a custom build , enabledPlugins ? null @@ -47,8 +48,6 @@ }: let - inherit (darwin.apple_sdk.frameworks) IOKit; - # Plugins that have dependencies. # Please help to extend these! plugins = { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 982122bf59ed..0f5dc92affed 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3788,6 +3788,7 @@ with pkgs; collectd = callPackage ../tools/system/collectd { libsigrok = libsigrok_0_3; # not compatible with >= 0.4.0 yet jdk = jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731 + inherit (darwin.apple_sdk.frameworks) IOKit; }; collectd-data = callPackage ../tools/system/collectd/data.nix { };