LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File collectd.spec of Package collectd (Project server:monitoring)

# vim: set sw=4 ts=4 et nu:
#
# spec file for package collectd
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2005-2012 Pascal Bleser <pascal.bleser@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%if 0%{?_with_xmms:1}0
%define xmms 1
%else
%define xmms 0
%endif

%if 0%{?_with_java:1} || 0%{?suse_version} > 1030 && ! 0%{?_without_java:1} && ! 0%{?sles_version}
%define java 1
%else
%define java 0
%endif

%if 0%{?_with_virt:1} || 0%{?suse_version} > 1030
%define virt 1
%else
%define virt 0
%endif

%if ! 0%{?_without_dbi:1}
%define dbi 1
%else
%define dbi 0
%endif

%if 0%{?suse_version} >= 1100 && ! 0%{?_without_memcachec:1}
%define memcachec 1
%define memcached_plugin memcached
%else
%define memcachec 0
%define memcached_plugin %{nil}
%endif

%if 0%{?suse_version} < 1000
%define libnotify 0
%else
%define libnotify 1
%endif

%if 0%{?suse_version} > 1020
%define ipmi   1
%define ascent 1
%define ascent_plugin ascent
%define iptables 1
%define iptables_plugin iptables
%else
%define ipmi   0
%define ascent 0
%define ascent_plugin %{nil}
%define iptables 0
%define iptables_plugin %{nil}
%endif

%define madwifi_plugin madwifi

%if 0%{?suse_version} >= 1130
%define rrdcached_plugin rrdcached
%else
%define rrdcached_plugin %{nil}
%endif

%define snmp       1
%define with_esmtp 1

%if 0%{?suse_version} >= 1000
%define yajl 1
%define curl_json_plugin curl_json
%define curl_xml_plugin  curl_xml
%define with_snmp_plugin 1
%define with_pgsql 1
%define with_mysql 1
%define with_bind  1
%define bind_plugin bind
%define protobuf 1
%define pinba_plugin pinba
%else
%define yajl 0
%define curl_json_plugin %{nil}
%define curl_xml_plugin  %{nil}
%define with_snmp_plugin 0
%define with_pgsql 0
%define with_mysql 0
%define with_bind  0
%define bind_plugin %{nil}
%define protobuf 0
%define pinba_plugin %{nil}
%endif

%define ipvs_plugin ipvs

%define libnetlink_version 2.6.37
%define intree_netlink 1

%define plugins apache apcups battery %{expand:%bind_plugin} curl %{expand:%curl_json_plugin} %{expand:%curl_xml_plugin} conntrack contextswitch cpu cpufreq csv df disk dns email entropy exec filecount fscache hddtemp interface %{expand:%ipvs_plugin} irq load logfile match_empty_counter match_hashed match_regex match_timediff match_value mbmon %{expand:%memcached_plugin} memory multimeter netlink network nfs nginx ntpd olsrd openvpn perl ping protocols powerdns processes rrdtool sensors serial swap syslog table tail target_notification target_replace target_scale target_set target_v5upgrade tcpconns teamspeak2 ted thermal threshold unixsock uptime users uuid vmem vserver wireless write_http %{expand:%ascent_plugin} %{expand:%iptables_plugin} %{expand:%madwifi_plugin} %{expand:%rrdcached_plugin}

Name:           collectd
Version:        5.0.4
Release:        0
Summary:        Statistics Collection Daemon for filling RRD Files
License:        GPL-2.0
Group:          System/Monitoring
Source:         http://collectd.org/files/collectd-%{version}.tar.bz2
Source1:        collectd.suse.init
Source2:        collectd.apache2.conf
Source3:        collectd-js.apache2.conf
# bundled/in-tree libnetlink.a, see http://mailman.verplant.org/pipermail/collectd/2007-October/001210.html
Source10:       http://devresources.linux-foundation.org/dev/iproute2/download/iproute2-%{libnetlink_version}.tar.bz2
# workaround for missing pthread.pc on openSUSE, required by OpenIPMIpthread.pc
# see https://bugzilla.novell.com/show_bug.cgi?id=388026
Source20:       collectd-pthread.pc
Source99:       collectd-rpmlintrc
Source100:      collectd.service
Patch4:         collectd-lib64.patch
Patch7:         collectd-fix-config.patch
Patch9:         collectd-version.patch
Patch10:        collectd-perl-vendor.patch
# see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467072
Patch11:        collectd-fix_broken_perl-5.10.patch
Patch12:        collectd-fix-warnings.patch
Patch14:        collectd-iproute2-HZ.patch
Patch16:        iproute2-optflags.patch
Patch17:        collectd-fix_libltdl_autoreconf.patch
Patch18:        collectd-fix_collection_cgi.patch
Patch19:        collectd-fix_spamassassin_doc.patch
Patch20:        collectd-split_README.patch
Patch21:        collectd-fix_collectd_config_path_in_snmp_probe.patch
Patch22:        collectd-collection3.patch
Patch23:        collectd-javac_target.patch
Patch24:        collectd-pkgconfig_libnotify_add_gtk.patch
Patch25:        collectd-df-remove-duplicates.patch
Patch26:        collectd-fix_own_iptc.patch
Url:            http://collectd.org/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       rrdtool
Requires:       sensors
BuildConflicts: libnetlink-devel
BuildRequires:  bind-devel
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  gettext
BuildRequires:  gettext-devel
BuildRequires:  intltool
#BuildRequires:  libmodbus-devel
BuildRequires:  libpng-devel
BuildRequires:  libstatgrab-devel
BuildRequires:  perl
BuildRequires:  rrdtool
BuildRequires:  sensors
BuildRequires:  zlib-devel
%if 0%{?suse_version} > 1020
BuildRequires:  libdb-4_5-devel
%else
BuildRequires:  db-devel
%endif
%if 0%{?suse_version} > 910
BuildRequires:  libgcrypt-devel
%else
BuildRequires:  libgcrypt
%endif
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  freetype2-devel
BuildRequires:  gcc
BuildRequires:  libart_lgpl-devel
BuildRequires:  liboping-devel
BuildRequires:  libtool
BuildRequires:  make
BuildRequires:  pkgconfig
BuildRequires:  python-devel
%if %libnotify
BuildRequires:  gtk2-devel
BuildRequires:  libnotify-devel
%endif
%if %java
BuildRequires:  java-devel
%endif #java
# for /etc/apache2/... ownership (rpmlint):
BuildRequires:  apache2
%if %with_esmtp
BuildRequires:  libesmtp-devel
%endif
BuildRequires:  xfsprogs-devel
%if %with_mysql
BuildRequires:  mysql-devel >= 4.1.0
%endif
%if %with_pgsql
BuildRequires:  postgresql-devel
%endif
%if %yajl
BuildRequires:  libyajl-devel
%endif
%if %suse_version >= 1030
BuildRequires:  rrdtool-devel
%endif
%if %suse_version >= 1030
BuildRequires:  libcurl-devel
%else
BuildRequires:  curl-devel
%endif
BuildRequires:  libxml2-devel
%if %ipmi
# for ipmi:
BuildRequires:  OpenIPMI-devel
BuildRequires:  gdbm-devel
%endif #ipmi
%if %snmp
# for snmp:
BuildRequires:  net-snmp-devel
%endif #snmp
# for ipvs and madwifi:
BuildRequires:  kernel-source
BuildRequires:  linux-kernel-headers
%if %suse_version >= 1030
BuildRequires:  libpcap-devel
%endif
BuildRequires:  libpcap
%if %xmms
# for xmms:
BuildRequires:  xmms-devel
%endif
%if %virt
# for libvirt:
BuildRequires:  libvirt-devel
%endif
%if %dbi
BuildRequires:  libdbi-devel
%endif
%if %memcachec
BuildRequires:  libmemcached-devel
%endif
%if %protobuf
BuildRequires:  protobuf-c
%endif
%if %suse_version < 1220
%if %suse_version > 1020
BuildRequires:  iptables-devel
%endif
%else
BuildRequires:  libiptc-devel
BuildRequires:  libxtables-devel
%endif
%if %suse_version >= 1210
%{perl_requires}
BuildRequires:  systemd
%{?systemd_requires}
%define has_systemd 1
%endif
# in case we'd like to split it later:
Provides:       collectd-perl = %{version}-%{release}
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq
# play nice with collectd-beta:
Obsoletes:      collectd-beta < %{version}
Provides:       collectd-beta = %{version}-%{release}

%description
collectd is a small daemon written in C for performance.  It reads various
system  statistics  and updates  RRD files,  creating  them if necessary.
Since the daemon doesn't need to startup every time it wants to update the
files it's very fast and easy on the system. Also, the statistics are very
fine grained since the files are updated every 10 seconds.

%package web
Summary:        Web Frontend for watching the %{name} Statistics
Group:          System/Monitoring
Requires:       apache2
Requires:       perl
Requires:       rrdtool
Requires:       rrdtool
Requires:       perl(CGI)
Requires:       perl(Data::Dumper)
Requires:       perl(HTML::Entities)
Requires:       perl(URI::Escape)

%description web
Web frontend CGI for watching %{name} statistics from a browser.

Please look at /etc/apache2/conf.d/%{name}.conf on how to enable.

%package web-js
Summary:        Web/JavaScript Frontend for watching %{name} Statistics
Group:          System/Monitoring
Requires:       apache2
Requires:       perl
Requires:       rrdtool
Requires:       perl(CGI)
Requires:       perl(Config::General)
Requires:       perl(Data::Dumper)
Requires:       perl(HTML::Entities)
Requires:       perl(JSON)
Requires:       perl(RRDs)

%description web-js
Web/JavaScript frontend CGI for watching %{name} statistics from
a browser.

Please look at /etc/apache2/conf.d/%{name}-js.conf on how to
enable.

%if %libnotify

%package plugin-notify-desktop
Summary:        Desktop Notification Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-notify-desktop
Desktop Notification Support for %{name}
%endif #libnotify

%if %ipmi

%package plugin-ipmi
Summary:        OpenIPMI Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-ipmi
Optional %{name} plugin to monitor sensors using the OpenIPMI
library, for IPMI enabled systems.
%endif #ipmi

%if %snmp

%package plugin-snmp
Summary:        SNMP Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}
Requires:       perl(Config::General)
Requires:       perl(SNMP)
Requires:       perl(Socket6)

%description plugin-snmp
Optional %{name} plugin to monitor devices using SNMP.
%endif #snmp

%if %with_mysql

%package plugin-mysql
Summary:        MySQL Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-mysql
Optional %{name} plugin to monitor MySQL server instances.
%endif #with_mysql

%if %with_pgsql

%package plugin-postgresql
Summary:        PostgreSQL Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-postgresql
Optional %{name} plugin to monitor PostgreSQL server instances.
%endif #with_pgsql

%package plugin-python
Summary:        Python API for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-python
Optional %{name} Python API in order to write %{name} plugins in
Python.

%if %java

%package plugin-java
Summary:        Java API for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-java
Optional %{name} Java API in order to write %{name} plugins in
Java.
%endif #java

%if %virt

%package plugin-virt
Summary:        Virtual Machine Statistics Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-virt
Optional %{name} plugin to gather statistics from virtual
machines using libvirt.
%endif

%if %xmms

%package plugin-xmms
Summary:        XMMS Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-xmms
Optional %{name} plugin to gather sampling frequencies and file
bitrates of files played with XMMS.
%endif #xmms

%if %dbi

%package plugin-dbi
Summary:        DBI Storage Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-dbi
Optional %{name} plugin to store sampling results into
various databases as supported by libdbi.
%endif #dbi

%if %memcachec

%package plugin-memcachec
Summary:        Memcache Daemon Monitoring Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-memcachec
Optional %{name} plugin to sample memcached statistics.
%endif #memcachec

%if %protobuf

%package plugin-pinba
Summary:        Pinba Collector Plugin for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}

%description plugin-pinba
Optional %{name} plugin to receive and dispatch timing values from Pinba, a
profiling extension for PHP.
%endif #protobuf

%package plugins-all
Summary:        All Monitoring Plugins for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}
%if %ipmi
Requires:       %{name}-plugin-ipmi = %{version}-%{release}
%endif #ipmi
%if %snmp
Requires:       %{name}-plugin-snmp = %{version}-%{release}
%endif #snmp
%if %with_mysql
Requires:       %{name}-plugin-mysql = %{version}-%{release}
%endif #with_mysql
%if %with_pgsql
Requires:       %{name}-plugin-postgresql = %{version}-%{release}
%endif
%if %java
Requires:       %{name}-plugin-java = %{version}-%{release}
%endif #java
%if %virt
Requires:       %{name}-plugin-virt = %{version}-%{release}
%endif #virt
Requires:       %{name}-web = %{version}-%{release}
Requires:       %{name}-web-js = %{version}-%{release}
%if %libnotify
Requires:       %{name}-plugin-notify-desktop = %{version}-%{release}
%endif #libnotify
Requires:       %{name}-plugin-python = %{version}-%{release}
%if %dbi
Requires:       %{name}-plugin-dbi = %{version}-%{release}
%endif #dbi
%if %memcachec
Requires:       %{name}-plugin-memcachec = %{version}-%{release}
%endif #memcachec
%if %protobuf
Requires:       %{name}-plugin-pinba = %{version}-%{release}
%endif #protobuf

%description plugins-all
Metapackage that installs %{name} and all the available
monitoring plugin subpackages, except %{name}-plugin-xmms

%package spamassassin
Summary:        Spamassassin Monitoring for %{name}
Group:          System/Monitoring
Requires:       %{name} = %{version}-%{release}
Requires:       perl-spamassassin

%description spamassassin
Plugin for filling %{name} with statistics from the
SpamAsssassin anti-spam engine.

%package -n libcollectdclient0
Summary:        Library for %{name} clients
Group:          System/Monitoring
Provides:       libcollectdclient = %{version}-%{release}

%description -n libcollectdclient0
Library which abstracts communication with the %{name}
unixsock plugin for clients.

%package -n libcollectdclient-devel
Summary:        Development Environment for %{name} clients
Group:          Development/Libraries/C and C++
Requires:       libcollectdclient0 = %{version}-%{release}

%description -n libcollectdclient-devel
Library which abstracts communication with the %{name}
unixsock plugin for clients.
This package contains the required development environment
to write %{name} unixsock clients.

%prep
%setup -q -n "collectd-%{version}" -a 10
%if "%{_lib}"=="lib64"
%patch4
%endif
%patch7
%patch9
%patch10
%patch11
%patch12
%patch17
pushd "iproute2-%{libnetlink_version}"
%patch14
%patch16
popd #iproute2
%patch18
%patch19
%patch20
%patch21
%patch22
%patch23
%patch24
%patch25
%patch26

%__sed -i 's|@@VERSION@@|%{version}|g' configure.in

# workaround for missing pthread.pc on openSUSE, required by OpenIPMIpthread.pc
%__install -D -m0644 "%{SOURCE20}" pkgconfig/pthread.pc
%__sed 's|@@LIB@@|%{_lib}|g' pkgconfig/pthread.pc

%__perl -p -i -e 's|(-L\$withval/lib)\b|${1}64|g' configure.in configure

# unneeded files:
%__rm -fr \
     contrib/fedora \
     contrib/solaris-smf \
     contrib/redhat \
     contrib/sles*

# remove -Werror everywhere
find . -name 'configure*' -o -name 'Makefile*' -exec %__sed -i 's|-Werror||g' {} \;

%build
export SUSE_ASNEEDED=0

%if %intree_netlink
# build in-tree libnetlink.a
pushd "iproute2-%{libnetlink_version}"
LIBNETLINK_CFLAGS="%{optflags}"
%ifarch x86_64 ia64 ppc64 ppc64 s390x
# only add -fPIC on 64bit, to avoid performance drawback on non-64bit archs:
LIBNETLINK_CFLAGS="$LIBNETLINK_CFLAGS -fPIC"
%endif
%__make %{?jobs:-j%{jobs}} \
        SUBDIRS="lib" \
    	  CC="%__cc" \
        OPTFLAGS="$LIBNETLINK_CFLAGS"
%__rm -f lib/*.so.* lib/*.so
%__ln_s lib lib64
popd #iproute2
%endif #%intree_netlink

autoreconf -fiv

# set JAVA_HOME properly
[ -n "$JAVA_HOME" -a -d "$JAVA_HOME" ] || export JAVA_HOME="%{_usr}/%{_lib}/jvm/java"
[ -n "$JDK_HOME"  -a -d "$JDK_HOME"  ] || export JDK_HOME="$JAVA_HOME"
[ -n "$JRE_HOME"  -a -d "$JRE_HOME"  ] || export JRE_HOME="$JAVA_HOME"
export PATH="$JDK_HOME/bin:$JRE_HOME/bin:$JAVA_HOME/bin:$PATH"

# add /usr/src/linux to include path to find net/ip_vs.h:
#export CFLAGS="%{optflags} -I$PWD/iproute2-%{libnetlink_version}/include/ -fno-strict-aliasing"
export CFLAGS="%{optflags} -fno-strict-aliasing"
export CXXFLAGS="$CFLAGS"
# workaround for missing pthread.pc on openSUSE, required by OpenIPMIpthread.pc
export PKG_CONFIG_PATH="$PWD/pkgconfig:$PKG_CONFIG_PATH"
export KERNEL_DIR=/usr/src/linux
%configure \
    --with-libstatgrab \
    --with-rrdtool \
    --disable-static \
    --enable-dns \
    --disable-nut \
    --enable-netlink \
    --enable-python \
    --with-librrd \
%if %iptables
    --enable-iptables \
    --with-libiptc=shipped \
%else
    --disable-iptables \
    --without-iptc \
%endif #iptables
%if %ascent
    --enable-ascent \
%else
    --disable-ascent \
%endif #ascent
%if %ipmi
    --enable-ipmi \
%else
    --disable-ipmi \
%endif #ipmi
%if %java
    --enable-java \
    --with-java="$JAVA_HOME/" \
%else
    --disable-java \
%endif #java
%if %dbi
    --enable-dbi \
%else
    --disable-dbi \
%endif #dbi
%if %memcachec
    --enable-memcached \
%else
    --disable-memcached \
%endif #memcachec
%if %intree_netlink
    --with-libnetlink="$PWD/iproute2-%{libnetlink_version}/" \
%endif
%if %suse_version < 930
    --disable-mysql \
%endif
%ifos linux
    --enable-serial
%else
    --disable-serial
%endif #os linux

%__make %{?_smp_flags} \
%if 0%{?suse_version} < 1120
     JAVAC_TARGET="-source 1.5 -target 1.5"
%else
     JAVAC_TARGET="-source 1.5 -target 1.6"
%endif

%install
%makeinstall

# delete .la files
%__rm -f "%{buildroot}%{_libdir}"/*.{a,la}
%__rm -f "%{buildroot}%{_libdir}/collectd"/*.a

%__sed -i '/^dependency_libs=/ s|-L'"${RPM_BUILD_DIR}/%{name}-%{version}"'/src||g' "%{buildroot}%{_libdir}/collectd/python.la"

# delete if it exists (not packaged any more on openSUSE):
%__rm -rf "%{buildroot}/var/adm/perl-modules/%{name}"

%if !%java
%__rm -f "%{buildroot}%{_mandir}/man5"/collectd-java.5*
%__rm -rf "%{buildroot}%{_datadir}/collectd/java"
%endif #!java
%__mkdir_p _rpmdoc_/java
%__mv contrib/GenericJMX.conf _rpmdoc_/java/

# fix bogus dependency in netlink.la, as it has been built against
# a static netlink library:
%if %intree_netlink
%__sed -i "/^dependency_libs=/s/=.*/=''/" \
    	 "%{buildroot}%{_libdir}/collectd/netlink.la"
%endif

# fix permissions:
%__chmod 0755 "%{buildroot}%{_libdir}/collectd"/*.so
%__chmod 0644 "%{buildroot}%{_libdir}/collectd"/*.la

# create /var/lib/collectd to add it to the %files section:
%__install -d -m 0755 "%{buildroot}%{_localstatedir}/lib/collectd"

# init script:
%__install -D -m 0755 "%{SOURCE1}" "%{buildroot}/etc/init.d/collectd"
%__install -d -m 0755 "%{buildroot}/usr/sbin"
%__ln_s "../../etc/init.d/collectd" "%{buildroot}/usr/sbin/rccollectd"

# Apache2 configuration for the CGI frontend:
%__install -D -m 0644 "%{SOURCE2}" "%{buildroot}/etc/apache2/conf.d/%{name}.conf"
%__install -D -m 0755 contrib/collection.cgi "%{buildroot}/srv/www/collectd/collection.cgi"
%__install -D -m 0644 contrib/collection.conf "%{buildroot}%{_sysconfdir}/collectd/collection.conf"
%__sed -i 's|@@LIBDIR@@|%{_libdir}|g' "%{buildroot}%{_sysconfdir}/collectd/collection.conf"
# remove it from contrib, to avoid having it end up in the main package as well:
%__rm contrib/collection.cgi contrib/collection.conf

%perl_process_packlist
%__rm -rf "%{buildroot}/var/adm/perl-modules"/*

# web-js CGI frontend (_must_ be installed _after_ perl_process_packlist)
%__install -d "%{buildroot}/srv/www/collectd-js"
%__mkdir_p _rpmdoc_/web-js
%__mv contrib/collection3/README _rpmdoc_/web-js/README
find contrib/collection3/ -name .htaccess -exec %__rm {} \;
%__cp -a \
     contrib/collection3/bin/* \
     contrib/collection3/share/* \
     "%{buildroot}/srv/www/collectd-js/"
%__mkdir_p "%{buildroot}%{_usr}/lib/collectd-js"
%__mv contrib/collection3/lib/* "%{buildroot}%{_usr}/lib/collectd-js/"

%__install -D -m 0644 contrib/collection3/etc/collection.conf \
     "%{buildroot}%{_sysconfdir}/collectd/collection-js.conf"
%__rm -fr contrib/collection3/etc
%__install -D -m 0644 "%{SOURCE3}" "%{buildroot}/etc/apache2/conf.d/%{name}-js.conf"

# spamassassin (_must_ be installed _after_ perl_process_packlist)
%__install -D -m0644 contrib/SpamAssassin/example.cf \
     "%{buildroot}%{_datadir}/spamassassin/99_%{name}.cf"
%__install -D -m0644 contrib/SpamAssassin/Collectd.pm \
     "%{buildroot}%{perl_vendorlib}/Mail/SpamAssassin/Plugin/Collectd.pm"
pod2man \
     contrib/SpamAssassin/Collectd.pm \
     > "%{buildroot}%{perl_man3dir}/Mail::SpamAssassin::Plugin::Collectd.%{perl_man3ext}"
%__rm -rf contrib/SpamAssassin

# cussh script from contrib:
%__install -m0755 contrib/cussh.pl "%{buildroot}%{_bindir}/cussh"
%__install -d "%{buildroot}%{_mandir}/man1"
pod2man \
     -c "Collectd UNIX Socket Shell" \
     -n "CUSSH" \
     -s 1 \
     contrib/cussh.pl > "%{buildroot}%{_mandir}/man1/cussh.1"
%__rm contrib/cussh.pl

# snmp:
%__mkdir_p _rpmdoc_/snmp
%__sed -n '/^snmp-data\.conf/,$ p' contrib/README > _rpmdoc_/snmp/README
%__sed -i '/^snmp-data\.conf/,$ d' contrib/README
%__mv contrib/snmp-data.conf _rpmdoc_/snmp/
%__sed -i 's|\(\./\)snmp-probe-host\.px|collectd-snmp-probe-host|g' contrib/snmp-probe-host.px
pod2man \
     -c "Collectd SNMP Host Probe" \
     -n "COLLECTD-SNMP-PROBE-HOST" \
     -s 1 \
     contrib/snmp-probe-host.px \
     > "%{buildroot}%{_mandir}/man1/collectd-snmp-probe-host.1"
%__install -D -m0755 contrib/snmp-probe-host.px "%{buildroot}%{_bindir}/collectd-snmp-probe-host"
%__rm contrib/snmp-probe-host.px
%__install -d "%{buildroot}%{_mandir}/man1"

find contrib/ -name '*.orig' -exec %__rm {} \;

%if !%with_pgsql
%__rm -f "%{buildroot}%{_datadir}/collectd/postgresql_default.conf"
%endif

%if !%with_snmp_plugin
%__rm -f "%{buildroot}%{_mandir}/man5/collectd-snmp.5"
%endif

# plugin list:
echo -n > plugins.lst
for plugin in %{plugins}; do
     for ext in so la; do
     	 echo "%{_libdir}/collectd/${plugin}.${ext}" >> plugins.lst
     done
done

cat<<EOF >README.plugins-all
This package is empty but depends on all collectd plugin subpackages.
EOF

%if 0%{?has_systemd} 
%__install -D -m0644 %{SOURCE100} %{buildroot}%{_unitdir}/collectd.service
%endif

%preun
%stop_on_removal collectd

%if 0%{?has_systemd}
%service_del_preun %{name}.service
%endif

%postun
%restart_on_update collectd
%insserv_cleanup

%if 0%{?has_systemd}
%service_del_postun %{name}.service
%endif

%pre

%if 0%{?has_systemd}
%service_add_pre %{name}.service
%endif

%post
%{fillup_only collectd}

%if 0%{?has_systemd}
%service_add_post %{name}.service
%endif

%post   -n libcollectdclient0 -p /sbin/ldconfig

%postun -n libcollectdclient0 -p /sbin/ldconfig

%clean
%{?buildroot:%__rm -rf "%{buildroot}"}

%files -f plugins.lst
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING README
%doc contrib
%config(noreplace) %{_sysconfdir}/collectd.conf
%dir %{_sysconfdir}/collectd
%{_bindir}/collectd-nagios
%{_bindir}/collectdctl
%{_bindir}/cussh
%{_sbindir}/collectd
%{_sbindir}/collectdmon
%dir %{_libdir}/collectd
%if %with_esmtp
%{_libdir}/collectd/notify_email.so
%{_libdir}/collectd/notify_email.la
%endif #with_esmtp
%dir %{_datadir}/collectd
%{_datadir}/collectd/types.db
%{perl_vendorlib}/Collectd.pm
%dir %{perl_vendorlib}/Collectd
%{perl_vendorlib}/Collectd/*
%{perl_vendorarch}/auto/Collectd
%doc %{_mandir}/man1/collectd.1%{ext_man}
%doc %{_mandir}/man1/collectdctl.1%{ext_man}
%doc %{_mandir}/man1/collectdmon.1%{ext_man}
%doc %{_mandir}/man1/collectd-nagios.1%{ext_man}
%doc %{_mandir}/man1/cussh.1%{ext_man}
%doc %{_mandir}/man5/collectd.conf.5%{ext_man}
%doc %{_mandir}/man5/collectd-email.5%{ext_man}
%doc %{_mandir}/man5/collectd-exec.5%{ext_man}
%doc %{_mandir}/man5/collectd-perl.5%{ext_man}
%doc %{_mandir}/man5/collectd-threshold.5%{ext_man}
%doc %{_mandir}/man5/collectd-unixsock.5%{ext_man}
%doc %{_mandir}/man5/types.db.5%{ext_man}
%doc %{perl_man3dir}/Collectd::Unixsock.%{perl_man3ext}%{ext_man}
%dir %{_localstatedir}/lib/collectd
/etc/init.d/collectd
/usr/sbin/rccollectd
%if 0%{?has_systemd}
%{_unitdir}/collectd.service
%endif

%files web
%defattr(-,root,root)
%config(noreplace) /etc/apache2/conf.d/%{name}.conf
%dir %{_sysconfdir}/collectd
%config(noreplace) %{_sysconfdir}/collectd/collection.conf
/srv/www/collectd

%files web-js
%defattr(-,root,root)
%doc _rpmdoc_/web-js/README
%config(noreplace) /etc/apache2/conf.d/%{name}-js.conf
%dir %{_sysconfdir}/collectd
%config(noreplace) %{_sysconfdir}/collectd/collection-js.conf
/srv/www/collectd-js
%{_usr}/lib/collectd-js

%if %libnotify

%files plugin-notify-desktop
%defattr(-,root,root)
%{_libdir}/collectd/notify_desktop.so
%{_libdir}/collectd/notify_desktop.la
%endif #libnotify

%if %ipmi

%files plugin-ipmi
%defattr(-,root,root)
%{_libdir}/collectd/ipmi.so
%{_libdir}/collectd/ipmi.la
%endif #ipmi

%if %snmp

%files plugin-snmp
%defattr(-,root,root)
%doc _rpmdoc_/snmp/*
%{_bindir}/collectd-snmp-probe-host
%doc %{_mandir}/man1/collectd-snmp-probe-host.1%{ext_man}
%if %with_snmp_plugin
%{_libdir}/collectd/snmp.so
%{_libdir}/collectd/snmp.la
%doc %{_mandir}/man5/collectd-snmp.5%{ext_man}
%endif #with_snmp_plugin
%endif #snmp

%if %protobuf

%files plugin-pinba
%defattr(-,root,root)
%{_libdir}/collectd/pinba.so
%{_libdir}/collectd/pinba.la
%endif #protobuf

%if %suse_version >= 930

%files plugin-mysql
%defattr(-,root,root)
%{_libdir}/collectd/mysql.so
%{_libdir}/collectd/mysql.la
%endif

%if %with_pgsql

%files plugin-postgresql
%defattr(-,root,root)
%{_libdir}/collectd/postgresql.so
%{_libdir}/collectd/postgresql.la
%config %{_datadir}/collectd/postgresql_default.conf
%endif #with_pgsql

%files plugin-python
%defattr(-,root,root)
%{_libdir}/collectd/python.so
%{_libdir}/collectd/python.la
%doc %{_mandir}/man5/collectd-python.5%{ext_man}

%if %java

%files plugin-java
%defattr(-,root,root)
%doc _rpmdoc_/java/GenericJMX.conf
%{_libdir}/collectd/java.so
%{_libdir}/collectd/java.la
%{_datadir}/collectd/java
%doc %{_mandir}/man5/collectd-java.5%{ext_man}
%endif #java

%if %virt

%files plugin-virt
%defattr(-,root,root)
%{_libdir}/collectd/libvirt.so
%{_libdir}/collectd/libvirt.la
%endif #virt

%if %xmms

%files plugin-xmms
%defattr(-,root,root)
%{_libdir}/collectd/xmms.so
%{_libdir}/collectd/xmms.la
%endif #xmms

%if %dbi

%files plugin-dbi
%defattr(-,root,root)
%{_libdir}/collectd/dbi.so
%{_libdir}/collectd/dbi.la
%endif #dbi

%if %memcachec

%files plugin-memcachec
%defattr(-,root,root)
%{_libdir}/collectd/memcachec.so
%{_libdir}/collectd/memcachec.la
%endif #memcachec

%files spamassassin
%defattr(-,root,root)
%dir %{_datadir}/spamassassin
%config(noreplace) %{_datadir}/spamassassin/99_%{name}.cf
%dir %{perl_vendorlib}/Mail
%dir %{perl_vendorlib}/Mail/SpamAssassin
%dir %{perl_vendorlib}/Mail/SpamAssassin/Plugin
%{perl_vendorlib}/Mail/SpamAssassin/Plugin/Collectd.pm
%doc %{perl_man3dir}/Mail::SpamAssassin::Plugin::Collectd.%{perl_man3ext}%{ext_man}

%files plugins-all
%defattr(-,root,root)
%doc README.plugins-all

%files -n libcollectdclient0
%defattr(-,root,root)
%{_libdir}/libcollectdclient.so.0
%{_libdir}/libcollectdclient.so.0.*.*

%files -n libcollectdclient-devel
%defattr(-,root,root)
%{_includedir}/collectd
%{_libdir}/libcollectdclient.so
%{_libdir}/pkgconfig/libcollectdclient.pc

%changelog