dev-python/click-default-group: arm64 keyworded (bug #700918)
[gentoo.git] / app-metrics / collectd / collectd-5.11.0-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 JAVA_PKG_OPT_USE="collectd_plugins_java"
8
9 inherit autotools fcaps flag-o-matic java-pkg-opt-2 linux-info multilib perl-functions python-single-r1 systemd tmpfiles user
10
11 DESCRIPTION="Collects system statistics and provides mechanisms to store the values"
12
13 HOMEPAGE="https://collectd.org/"
14 SRC_URI="https://github.com/${PN}/${PN}/releases/download/${P}/${P}.tar.bz2"
15
16 LICENSE="MIT GPL-2 GPL-2+ GPL-3 GPL-3+"
17 SLOT="0"
18 KEYWORDS="~alpha ~amd64 ~arm ~x86"
19 IUSE="contrib debug java kernel_Darwin kernel_FreeBSD kernel_linux perl selinux static-libs udev xfs"
20
21 # The plugin lists have to follow here since they extend IUSE
22
23 # Plugins that don't build (e.g. dependencies not in Gentoo)
24 # apple_sensors:  Requires libIOKit
25 # amqp1:          Requires libqpid-proton
26 # aquaero:        Requires aerotools-ng/libaquaero5
27 # barometer:      Requires libi2c (i2c_smbus_read_i2c_block_data)
28 # dpdkevents:     Requires dpdk
29 # dpdkstat:       Requires dpdk
30 # dpdk_telemetry: Requires dpdk
31 # grpc:           Requires libgrpc
32 # intel_pmu:      Requires libjevents (pmu-tools)
33 # intel_rdt:      Requires libpqos from intel-cmt-cat project
34 # lpar:           Requires libperfstat (AIX only)
35 # mic:            Requires Intel Many Integrated Core Architecture API
36 #                 (part of Intel's  Xeon Phi software)
37 # netapp:         Requires libnetapp (http://communities.netapp.com/docs/DOC-1110)
38 # pf:             Requires BSD packet filter
39 # pinba:          Requires MySQL Pinba engine (http://pinba.org/)
40 # redfish:        Requires libredfish
41 # tape:           Requires libkstat (Solaris only)
42 # tokyotyrant:    Requires tokyotyrant
43 # write_riemann:  Requires riemann-c-client
44 # xmms:           Requires libxmms (v1)
45 # zone:           Solaris only...
46 COLLECTD_IMPOSSIBLE_PLUGINS="apple_sensors amqp1 aquaero barometer
47         dpdkevents dpdkstat dpdk_telemetry grpc intel_pmu intel_rdt lpar
48         mic netapp pf pinba redfish tape tokyotyrant write_riemann xmms zone"
49
50 # Plugins that have been (compile) tested and can be enabled via COLLECTD_PLUGINS
51 COLLECTD_TESTED_PLUGINS="aggregation amqp apache apcups ascent battery bind
52         buddyinfo capabilities ceph cgroups check_uptime chrony connectivity
53         conntrack contextswitch cpu cpufreq cpusleep csv curl curl_json
54         curl_xml dbi df disk dns drbd email entropy ethstat exec fhcount
55         filecount fscache gmond gps hddtemp hugepages interface ipc ipmi
56         iptables ipvs irq java lua load logfile logparser log_logstash
57         madwifi match_empty_counter match_hashed match_regex match_timediff
58         match_value mbmon mcelog md memcachec memcached memory modbus mqtt
59         multimeter mysql netlink network network nfs nginx notify_desktop
60         notify_email notify_nagios ntpd numa nut olsrd onewire openldap
61         openvpn oracle ovs_events ovs_stats pcie_errors perl ping postgresql
62         powerdns procevent processes protocols python python redis routeros
63         rrdcached rrdtool sensors serial sigrok slurm smart snmp snmp_agent
64         statsd swap synproxy sysevent syslog table tail tail_csv
65         target_notification target_replace target_scale target_set tcpconns
66         teamspeak2 ted thermal threshold turbostat ubi unixsock uptime users
67         uuid varnish virt vmem vserver wireless write_graphite write_http
68         write_influxdb_udp write_kafka write_log write_mongodb write_prometheus
69         write_redis write_sensu write_stackdriver write_syslog write_tsdb
70         xencpu zfs_arc zookeeper"
71
72 COLLECTD_DISABLED_PLUGINS="${COLLECTD_IMPOSSIBLE_PLUGINS}"
73
74 COLLECTD_ALL_PLUGINS=${COLLECTD_TESTED_PLUGINS}
75
76 for plugin in ${COLLECTD_ALL_PLUGINS}; do
77         IUSE="${IUSE} collectd_plugins_${plugin}"
78 done
79 unset plugin
80
81 # Now come the dependencies.
82
83 COMMON_DEPEND="
84         dev-libs/libgcrypt:=
85         dev-libs/libltdl:0=
86         sys-libs/libcap
87         perl?                                   ( dev-lang/perl:=[ithreads] )
88         udev?                                   ( virtual/udev )
89         xfs?                                    ( sys-fs/xfsprogs )
90         collectd_plugins_amqp?                  ( net-libs/rabbitmq-c )
91         collectd_plugins_apache?                ( net-misc/curl:0= )
92         collectd_plugins_ascent?                ( net-misc/curl:0= dev-libs/libxml2:2= )
93         collectd_plugins_bind?                  ( net-misc/curl:0= dev-libs/libxml2:2= )
94         collectd_plugins_ceph?                  ( dev-libs/yajl:= )
95         collectd_plugins_capabilities?          ( dev-libs/jansson net-libs/libmicrohttpd:= )
96         collectd_plugins_connectivity?          ( dev-libs/yajl:= net-libs/libmnl )
97         collectd_plugins_curl?                  ( net-misc/curl:0= )
98         collectd_plugins_curl_json?             ( net-misc/curl:0= dev-libs/yajl:= )
99         collectd_plugins_curl_xml?              ( net-misc/curl:0= dev-libs/libxml2:2= )
100         collectd_plugins_dbi?                   ( dev-db/libdbi )
101         collectd_plugins_dns?                   ( net-libs/libpcap )
102         collectd_plugins_gmond?                 ( sys-cluster/ganglia )
103         collectd_plugins_gps?                   ( sci-geosciences/gpsd:= )
104         collectd_plugins_ipmi?                  ( >=sys-libs/openipmi-2.0.16-r1 )
105         collectd_plugins_iptables?              ( >=net-firewall/iptables-1.4.13:0= )
106         collectd_plugins_log_logstash?          ( dev-libs/yajl:= )
107         collectd_plugins_lua?                   ( dev-lang/lua:0= )
108         collectd_plugins_memcachec?             ( dev-libs/libmemcached )
109         collectd_plugins_modbus?                ( dev-libs/libmodbus )
110         collectd_plugins_mqtt?                  ( app-misc/mosquitto )
111         collectd_plugins_mysql?                 ( dev-db/mysql-connector-c:= )
112         collectd_plugins_netlink?               ( net-libs/libmnl )
113         collectd_plugins_nginx?                 ( net-misc/curl:0= )
114         collectd_plugins_notify_desktop?        ( x11-libs/libnotify )
115         collectd_plugins_notify_email?          ( net-libs/libesmtp )
116         collectd_plugins_nut?                   ( >=sys-power/nut-2.7.2-r2 )
117         collectd_plugins_openldap?              ( net-nds/openldap )
118         collectd_plugins_onewire?               ( >=sys-fs/owfs-3.1:= )
119         collectd_plugins_oracle?                ( dev-db/oracle-instantclient-basic )
120         collectd_plugins_ovs_events?            ( dev-libs/yajl:= )
121         collectd_plugins_ovs_stats?             ( dev-libs/yajl:= )
122         collectd_plugins_perl?                  ( dev-lang/perl:=[ithreads] )
123         collectd_plugins_ping?                  ( net-libs/liboping )
124         collectd_plugins_postgresql?            ( dev-db/postgresql:= )
125         collectd_plugins_procevent?             ( dev-libs/yajl:= )
126         collectd_plugins_python?                ( ${PYTHON_DEPS} )
127         collectd_plugins_redis?                 ( dev-libs/hiredis:= )
128         collectd_plugins_routeros?              ( net-libs/librouteros )
129         collectd_plugins_rrdcached?             ( net-analyzer/rrdtool:= )
130         collectd_plugins_rrdtool?               ( net-analyzer/rrdtool:= )
131         collectd_plugins_sensors?               ( sys-apps/lm-sensors:= )
132         collectd_plugins_sigrok?                ( <sci-libs/libsigrok-0.4:= dev-libs/glib:2 )
133         collectd_plugins_slurm?                 ( sys-cluster/slurm )
134         collectd_plugins_smart?                 ( dev-libs/libatasmart:0= )
135         collectd_plugins_snmp?                  ( net-analyzer/net-snmp )
136         collectd_plugins_snmp_agent?            ( net-analyzer/net-snmp )
137         collectd_plugins_sysevent?              ( dev-libs/yajl:= )
138         collectd_plugins_varnish?               ( www-servers/varnish:= )
139         collectd_plugins_virt?                  ( app-emulation/libvirt:= dev-libs/libxml2:2= )
140         collectd_plugins_write_http?            ( net-misc/curl:0= dev-libs/yajl:= )
141         collectd_plugins_write_kafka?           ( >=dev-libs/librdkafka-0.9.0.99:= dev-libs/yajl:= )
142         collectd_plugins_write_mongodb?         ( >=dev-libs/mongo-c-driver-1.8.2:= )
143         collectd_plugins_write_prometheus?      ( >=dev-libs/protobuf-c-1.2.1-r1:= net-libs/libmicrohttpd:= )
144         collectd_plugins_write_redis?           ( dev-libs/hiredis:= )
145         collectd_plugins_write_stackdriver?     ( net-misc/curl:0= dev-libs/yajl:= )
146         collectd_plugins_xencpu?                ( app-emulation/xen-tools:= )
147
148         kernel_FreeBSD? (
149                 collectd_plugins_disk?          ( sys-libs/libstatgrab:= )
150                 collectd_plugins_interface?     ( sys-libs/libstatgrab:= )
151                 collectd_plugins_load?          ( sys-libs/libstatgrab:= )
152                 collectd_plugins_memory?        ( sys-libs/libstatgrab:= )
153                 collectd_plugins_swap?          ( sys-libs/libstatgrab:= )
154                 collectd_plugins_users?         ( sys-libs/libstatgrab:= )
155         )"
156
157 # Enforcing !=sys-kernel/linux-headers-4.5 > due to #577846
158 DEPEND="${COMMON_DEPEND}
159         collectd_plugins_iptables?              ( || ( <=sys-kernel/linux-headers-4.4 >=sys-kernel/linux-headers-4.6 ) )
160         collectd_plugins_java?                  ( >=virtual/jdk-1.6 )
161         virtual/pkgconfig"
162
163 RDEPEND="${COMMON_DEPEND}
164         collectd_plugins_java?                  ( >=virtual/jre-1.6 )
165         collectd_plugins_syslog?                ( virtual/logger )
166         selinux?                                ( sec-policy/selinux-collectd )"
167
168 REQUIRED_USE="
169         collectd_plugins_python?                ( ${PYTHON_REQUIRED_USE} )
170         collectd_plugins_smart?                 ( udev )
171         contrib?                                ( perl )"
172
173 # @FUNCTION: collectd_plugin_kernel_linux
174 # @DESCRIPTION:
175 # USAGE: <plugin name> <kernel_options> <severity>
176 # kernel_options is a list of kernel configurations options; the check tests whether at least
177 #   one of them is enabled. If no, depending on the third argument an elog, ewarn, or eerror message
178 #   is emitted.
179 collectd_plugin_kernel_linux() {
180         local multi_opt opt
181         if has ${1} ${COLLECTD_ALL_PLUGINS}; then
182                 if use collectd_plugins_${1}; then
183                         for opt in ${2}; do
184                                 if linux_chkconfig_present ${opt}; then
185                                         return 0;
186                                 fi
187                         done
188                         multi_opt=${2//\ /\ or\ }
189                         case ${3} in
190                                 (info)
191                                         elog "The ${1} plugin can use kernel features that are disabled now; enable ${multi_opt} in your kernel"
192                                 ;;
193                                 (warn)
194                                         ewarn "The ${1} plugin uses kernel features that are disabled now; enable ${multi_opt} in your kernel"
195                                 ;;
196                                 (error)
197                                         eerror "The ${1} plugin needs kernel features that are disabled now; enable ${multi_opt} in your kernel"
198                                 ;;
199                                 (*)
200                                         die "function collectd_plugin_kernel_linux called with invalid third argument"
201                                 ;;
202                         esac
203                 fi
204         fi
205 }
206
207 collectd_linux_kernel_checks() {
208         if ! linux_chkconfig_present PROC_FS; then
209                 ewarn "/proc file system support is disabled, many plugins will not be able to read any statistics from your system unless you enable PROC_FS in your kernel"
210         fi
211
212         if ! linux_chkconfig_present SYSFS; then
213                 ewarn "/sys file system support is disabled, many plugins will not be able to read any statistics from your system unless you enable SYSFS in your kernel"
214         fi
215
216         # battery.c: /proc/pmu/battery_%i
217         # battery.c: /proc/acpi/battery
218         collectd_plugin_kernel_linux battery ACPI_BATTERY warn
219
220         # cgroups.c: /sys/fs/cgroup/
221         collectd_plugin_kernel_linux cgroups CGROUPS warn
222
223         # cpufreq.c: /sys/devices/system/cpu/cpu%d/cpufreq/
224         collectd_plugin_kernel_linux cpufreq SYSFS warn
225         collectd_plugin_kernel_linux cpufreq CPU_FREQ_STAT warn
226
227         # drbd.c: /proc/drbd
228         collectd_plugin_kernel_linux drbd BLK_DEV_DRBD warn
229
230         # conntrack.c: /proc/sys/net/netfilter/*
231         collectd_plugin_kernel_linux conntrack NETFILTER warn
232
233         # fscache.c: /proc/fs/fscache/stats
234         collectd_plugin_kernel_linux fscache FSCACHE warn
235
236         # nfs.c: /proc/net/rpc/nfs
237         # nfs.c: /proc/net/rpc/nfsd
238         collectd_plugin_kernel_linux nfs NFS_COMMON warn
239
240         # serial.c: /proc/tty/driver/serial
241         # serial.c: /proc/tty/driver/ttyS
242         collectd_plugin_kernel_linux serial SERIAL_CORE warn
243
244         # swap.c: /proc/meminfo
245         collectd_plugin_kernel_linux swap SWAP warn
246
247         # thermal.c: /proc/acpi/thermal_zone
248         # thermal.c: /sys/class/thermal
249         collectd_plugin_kernel_linux thermal ACPI_THERMAL warn
250
251         # turbostat.c: /dev/cpu/%d/msr
252         collectd_plugin_kernel_linux turbostat X86_MSR warn
253
254         # vmem.c: /proc/vmstat
255         collectd_plugin_kernel_linux vmem VM_EVENT_COUNTERS warn
256
257         # vserver.c: /proc/virtual
258         collectd_plugin_kernel_linux vserver VSERVER warn
259
260         # uuid.c: /sys/hypervisor/uuid
261         collectd_plugin_kernel_linux uuid SYSFS info
262
263         # wireless.c: /proc/net/wireless
264         collectd_plugin_kernel_linux wireless "WIRELESS MAC80211 IEEE80211" warn
265
266         # zfs_arc.c: /proc/spl/kstat/zfs/arcstats
267         collectd_plugin_kernel_linux zfs_arc "SPL ZFS" warn
268 }
269
270 pkg_setup() {
271         if use kernel_linux; then
272                 linux-info_pkg_setup
273
274                 if linux_config_exists; then
275                         einfo "Checking your linux kernel configuration:"
276                         collectd_linux_kernel_checks
277                 else
278                         elog "Cannot find a linux kernel configuration. Continuing anyway."
279                 fi
280         fi
281
282         if use collectd_plugins_java; then
283                 java-pkg-opt-2_pkg_setup
284         fi
285
286         use collectd_plugins_python && python-single-r1_pkg_setup
287
288         enewgroup collectd
289         enewuser collectd -1 -1 /var/lib/collectd collectd
290 }
291
292 src_prepare() {
293         default
294
295         # There's some strange prefix handling in the default config file, resulting in
296         # paths like "/usr/var/..."
297         sed -i -e "s:@prefix@/var:/var:g" src/collectd.conf.in || die
298
299         # Adjust upstream's systemd unit
300         #   - Get rid of EnvironmentFile directive; These files don't exist on Gentoo!
301         #   - Add User=collectd to run collectd as user "collectd" per default
302         sed -i \
303                 -e '/^EnvironmentFile=.*/d' \
304                 -e '/^\[Service\]/aUser=collectd' \
305                 contrib/systemd.${PN}.service || die
306
307         eautoreconf
308 }
309
310 src_configure() {
311         # Now come the lists of os-dependent plugins. Any plugin that is not listed anywhere here
312         # should work independent of the operating system.
313
314         local linux_plugins="barometer battery cpu cpufreq disk
315                 drbd entropy ethstat hugepages interface iptables
316                 ipvs irq ipc load memory md netlink nfs numa processes
317                 serial swap tcpconns thermal turbostat users vmem wireless
318                 zfc_arc"
319
320         local need_libstatgrab=0
321         local libstatgrab_plugins="cpu disk interface load memory swap users"
322         local bsd_plugins="cpu tcpconns ${libstatgrab_plugins} zfc_arc"
323
324         local darwin_plugins="apple_sensors battery cpu disk interface memory processes tcpconns"
325
326         local osdependent_plugins="${linux_plugins} ${bsd_plugins} ${darwin_plugins}"
327         local myos_plugins=""
328         if use kernel_linux; then
329                 einfo "Enabling Linux plugins."
330                 myos_plugins=${linux_plugins}
331         elif use kernel_FreeBSD; then
332                 einfo "Enabling FreeBSD plugins."
333                 myos_plugins=${bsd_plugins}
334         elif use kernel_Darwin; then
335                 einfo "Enabling Darwin plugins."
336                 myos_plugins=${darwin_plugins}
337         fi
338
339         local myconf="--disable-werror"
340
341         # Do we debug?
342         myconf+=" $(use_enable debug)"
343
344         # udev support?
345         # Required for smart plugin via REQUIRED_USE; Optional for disk plugin
346         if use udev; then
347                 myconf+=" --with-libudev"
348         else
349                 myconf+=" --without-libudev"
350         fi
351
352         local plugin
353
354         # Disable what needs to be disabled.
355         for plugin in ${COLLECTD_DISABLED_PLUGINS}; do
356                 if [[ "${plugin}" == 'dpdkstat' ]]; then
357                         myconf+=" --without-libdpdk"
358                 else
359                         myconf+=" --disable-${plugin}"
360                 fi
361         done
362
363         # Set enable/disable for each single plugin.
364         for plugin in ${COLLECTD_ALL_PLUGINS}; do
365                 if has ${plugin} ${osdependent_plugins}; then
366                         # plugin is os-dependent ...
367                         if has ${plugin} ${myos_plugins}; then
368                                 # ... and available in this os
369                                 myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
370                                 # ... must we link against libstatgrab? Bug #541518
371                                 if use kernel_FreeBSD && has ${plugin} ${libstatgrab_plugins}; then
372                                         einfo "We must link against libstatgrab due to plugin \"${plugin}\" ..."
373                                         need_libstatgrab=1
374                                 fi
375                         else
376                                 # ... and NOT available in this os
377                                 if use collectd_plugins_${plugin}; then
378                                         ewarn "You try to enable the ${plugin} plugin, but it is not available for this"
379                                         ewarn "kernel. Disabling it automatically."
380                                 fi
381                                 myconf+=" --disable-${plugin}"
382                         fi
383                 elif [[ "${plugin}" = "collectd_plugins_perl" ]]; then
384                         if use collectd_plugins_perl && ! use perl; then
385                                 ewarn "Perl plugin disabled as perl bindings disabled by -perl use flag"
386                                 myconf+= --disable-perl
387                         else
388                                 myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
389                         fi
390                 else
391                         myconf+=" $(use_enable collectd_plugins_${plugin} ${plugin})"
392                 fi
393         done
394
395         if [ "${need_libstatgrab}" -eq 1 ]; then
396                 myconf+=" --with-libstatgrab"
397         else
398                 myconf+=" --without-libstatgrab"
399         fi
400
401         # JAVA_HOME is set by eclasses.
402         if use collectd_plugins_java; then
403                 myconf+=" --with-java"
404         fi
405
406         # Need libiptc ONLY for iptables. If we try to use it otherwise bug 340109 happens.
407         # lots of libs are only needed for plugins, if they are disabled, also disable the lib
408         use collectd_plugins_iptables || myconf+=" --with-libiptc=no"
409         use collectd_plugins_openldap || myconf+=" --with-libldap=no"
410         use collectd_plugins_redis    || use collectd_plugins_write_redis || myconf+=" --with-libhiredis=no"
411         use collectd_plugins_smart    || myconf+=" --with-libatasmart=no"
412         use collectd_plugins_gps      || myconf+=" --with-libgps=no"
413
414         if use perl; then
415                 myconf+=" --with-perl-bindings=INSTALLDIRS=vendor"
416         else
417                 myconf+=" --without-perl-bindings"
418         fi
419
420         # No need for v5upgrade
421         myconf+=" --disable-target_v5upgrade"
422
423         # Python
424         if use collectd_plugins_python; then
425                 myconf+=" --with-libpython=yes"
426                 export PYTHON_CONFIG=$(python_get_PYTHON_CONFIG)
427         else
428                 myconf+=" --with-libpython=no"
429         fi
430
431         # XFS support
432         myconf+=" $(use_enable xfs)"
433
434         # Finally, run econf.
435         KERNEL_DIR="${KERNEL_DIR}" econf --config-cache \
436                 $(use_enable static-libs static) \
437                 --localstatedir=/var ${myconf}
438 }
439
440 src_install() {
441         emake DESTDIR="${D%/}" install
442
443         perl_delete_localpod
444
445         find "${ED}"usr/ -name "*.la" -delete || die
446
447         if use collectd_plugins_java; then
448                 java-pkg_regjar "${ED}"usr/share/${PN}/java/*.jar
449         fi
450
451         fowners root:collectd /etc/collectd.conf
452         fperms u=rw,g=r,o= /etc/collectd.conf
453
454         dodoc AUTHORS ChangeLog README
455
456         if use contrib ; then
457                 insinto /usr/share/${PN}
458                 doins -r contrib
459         fi
460
461         keepdir /var/lib/${PN}
462         fowners collectd:collectd /var/lib/${PN}
463
464         newinitd "${FILESDIR}/${PN}.initd-r2" ${PN}
465         newconfd "${FILESDIR}/${PN}.confd-r2" ${PN}
466         systemd_newunit "contrib/systemd.${PN}.service" ${PN}.service
467
468         insinto /etc/logrotate.d
469         newins "${FILESDIR}/${PN}.logrotate" ${PN}
470
471         newtmpfiles "${FILESDIR}"/${PN}.tmpfile ${PN}.conf
472
473         sed -i -e 's:^.*PIDFile     "/var/run/collectd.pid":#PIDFile     "/run/collectd.pid":' "${ED}"etc/collectd.conf || die
474         sed -i -e 's:^# SocketFile "/var/run/collectd-unixsock":#       SocketFile "/run/collectd/collectd.socket":' "${ED}"etc/collectd.conf || die
475         sed -i -e 's:^.*LoadPlugin perl$:# The new, correct way to load the perl plugin -- \n# <LoadPlugin perl>\n#   Globals true\n# </LoadPlugin>:' "${ED}"etc/collectd.conf || die
476         sed -i -e 's:^.*LoadPlugin python$:# The new, correct way to load the python plugin -- \n# <LoadPlugin python>\n#   Globals true\n# </LoadPlugin>:' "${ED}"etc/collectd.conf || die
477 }
478
479 pkg_postinst() {
480         tmpfiles_process "${PN}.conf"
481
482         if use filecaps; then
483                 local caps=()
484                 use collectd_plugins_ceph      && caps+=('CAP_DAC_OVERRIDE')
485                 use collectd_plugins_exec      && caps+=('CAP_SETUID' 'CAP_SETGID')
486                 use collectd_plugins_iptables  && caps+=('CAP_NET_ADMIN')
487                 use collectd_plugins_filecount && caps+=('CAP_DAC_READ_SEARCH')
488
489                 if use collectd_plugins_dns || use collectd_plugins_ping; then
490                         caps+=('CAP_NET_RAW')
491                 fi
492
493                 if use collectd_plugins_turbostat || use collectd_plugins_smart; then
494                         caps+=('CAP_SYS_RAWIO')
495                 fi
496
497                 if [ ${#caps[@]} -gt 0 ]; then
498                         local caps_str=$(IFS=","; echo "${caps[*]}")
499                         fcaps ${caps_str} usr/sbin/collectd
500                         elog "Capabilities for ${EROOT}usr/sbin/collectd set to:"
501                         elog "  ${caps_str}+EP"
502                         elog
503
504                         local systemd_unit="$(systemd_get_systemunitdir)/collectd.service"
505                         if [[ -e "${systemd_unit}" ]]; then
506                                 caps_str="${caps[*]}"
507                                 sed -i -e "s:^CapabilityBoundingSet=.*:CapabilityBoundingSet=${caps_str}:" "${systemd_unit}" || \
508                                         die "Failed to set CapabilityBoundingSet in '${systemd_unit}'"
509
510                                 elog "CapabilityBoundingSet in '${systemd_unit}'"
511                                 elog "updated to match capabilities set above."
512                                 elog
513                         else
514                                 if has_version "sys-apps/systemd"; then
515                                         # Bug 596852
516                                         ewarn "Failed to update CapabilityBoundingSet in '${systemd_unit}'"
517                                         ewarn "because unit was not found. Please file a bug about this."
518                                 fi
519                         fi
520                 fi
521         fi
522
523         elog "Note: Collectd is only the collector."
524         elog "      You need to install 'data' sources (applications) locally or"
525         elog "      remotely on your own."
526
527         elog
528         elog "Collectd is configured to run as unprivileged user by default."
529         elog "You may want to revisit the configuration."
530         elog
531
532         if use collectd_plugins_email; then
533                 ewarn "The email plug-in is deprecated. To submit statistics please use the unixsock plugin."
534         fi
535
536         if use collectd_plugins_smart; then
537                 elog ""
538                 elog "If you are using smart plugin and don't run collectd as root make sure"
539                 elog "that the collectd user is allowed to access the disk you want to monitor"
540                 elog "(can be done via udev rule for example) and that collectd has the required"
541                 elog "capabilities set (which is the default when package was emerged with"
542                 elog "'filecaps' USE flag set)."
543         fi
544
545         if use contrib; then
546                 elog "The scripts in /usr/share/doc/${PF}/collection3 for generating graphs need dev-perl/HTML-Parser,"
547                 elog "dev-perl/CGI, dev-perl/Config-General and net-analyzer/rrdtool[perl] to be installed."
548         fi
549 }