File beats.spec of Package beats
#
# spec file for package beats
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 Klaus Kämpf <kkaempf@suse.de>
#
# 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/
#
%global provider github
%global provider_tld com
%global project elastic
%global repo beats
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
%if 0%{?suse_version} > 1140 || 0%{?fedora_version} > 14
%define has_systemd 1
%else
%define has_systemd 0
%endif
# "backport"
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}
%{!?_rundir: %{expand: %%global _rundir %{_localstatedir}/run}}
# these two are broken on SLE 11... so just "correct" them enough to work...
%{!?_tmpfilesdir: %{expand: %%global _tmpfilesdir %{_prefix}/lib/tmpfiles.d}}
%{!?_sysctldir: %{expand: %%global _sysctldir %{_prefix}/lib/sysctl.d}}
Name: %{repo}
Version: 7.4.0
Release: 0
License: Apache-2.0 and BSD-3-clause
Summary: Lightweight shippers for Elasticsearch & Logstash
Group: Productivity/Databases/Tools
# temporary measure:
ExclusiveArch: x86_64
Source: v%{version}.tar.gz
Source1: beats-packer-build.sh
Patch1: 0001-path.config-defaults-to-etc-beats.patch
Url: https://github.com/elastic/beats
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: git
BuildRequires: go-devel
BuildRequires: go >= 1.12
BuildRequires: golang-packaging
BuildRequires: libpcap-devel
BuildRequires: python3-Jinja2
BuildRequires: python3-PyYAML
BuildRequires: python3-autopep8
BuildRequires: python3-nose
BuildRequires: python3-pip
BuildRequires: python3-redis
BuildRequires: python3-requests
BuildRequires: python3-setuptools
BuildRequires: python3-termcolor
BuildRequires: unzip
BuildRequires: golang(github.com/pierrre/gotestcover)
BuildRequires: golang(github.com/stretchr/testify)
BuildRequires: golang(github.com/pkg/errors)
BuildRequires: golang(golang.org/x/sys/unix)
%{go_nostrip}
%{go_provides}
%if 0%{?has_systemd}
BuildRequires: systemd
%{?systemd_requires}
%endif
Requires: logrotate
# mkdir, chown in %%pre
Requires(pre): coreutils
%description
The Beats are lightweight data shippers, written in Go, that you
install on your servers to capture all sorts of operational data
(think of logs, metrics, or network packet data). The Beats send the
operational data to Elasticsearch, either directly or via Logstash, so
it can be visualized with Kibana.
%package -n auditbeat
Summary: Auditbeat sends audit events to Logstash or directly to Elasticsearch
Group: Productivity/Databases/Tools
%description -n auditbeat
Auditbeat is a lightweight shipper that you can install on your
servers to audit the activities of users and processes on your
systems. For example, you can use Auditbeat to collect and centralize
audit events from the Linux Audit Framework. You can also use
Auditbeat to detect changes to critical files, like binaries and
configuration files, and identify potential security policy violations.
%package -n filebeat
Summary: Filebeat sends log files to Logstash or directly to Elasticsearch
Group: Productivity/Databases/Tools
%description -n filebeat
Filebeat is an open source file harvester, mostly used to fetch logs
files and feed them into logstash. Together with the libbeat
lumberjack output is a replacement for logstash-forwarder.
%package -n heartbeat
Summary: Ping remote services for availability
Group: Productivity/Databases/Tools
%description -n heartbeat
Welcome to Heartbeat.
This is a new EXPERIMENTAL beat for testing service availability using
PING based on ICMP, TCP or higher level protocols.
%package -n metricbeat
Summary: Fetches sets of metrics from the operating system and services
Group: Productivity/Databases/Tools
%description -n metricbeat
Metricbeat fetches a set of metrics on a predefined interval from the
operating system and services such as Apache web server, Redis, and
more and ships them to Elasticsearch or Logstash.
%package -n packetbeat
Summary: Monitors the network and applications by sniffing packets
Group: Productivity/Databases/Tools
%description -n packetbeat
Packetbeat is an open source network packet analyzer that ships the
data to Elasticsearch. Think of it like a distributed real-time
Wireshark with a lot more analytics features.
The Packetbeat shippers sniff the traffic between your application
processes, parse on the fly protocols like HTTP, MySQL, PostgreSQL,
Redis or Thrift and correlate the messages into transactions.
%prep
%setup -q
rm -rf ~/go
mkdir -p ~/go/src/%{provider}.%{provider_tld}/%{project}
ln -s `pwd` ~/go/src/%{provider}.%{provider_tld}/%{project}/%{repo}
%patch1 -p1
%build
%goprep %{import_path}
mkdir build
export BUILD_DIR=`pwd`/build
for i in libbeat auditbeat filebeat heartbeat metricbeat packetbeat
do
(cd $i; SNAPSHOT=NO BUILD_DIR=$BUILD_DIR make)
done
%install
export SNAPSHOT=NO
install -d -m 755 $RPM_BUILD_ROOT%{_sbindir}
install -d -m 755 $RPM_BUILD_ROOT%{_bindir}
install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}
install -d -m 755 $RPM_BUILD_ROOT%{_unitdir}
install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/beats
for i in auditbeat filebeat heartbeat metricbeat packetbeat
do
install -m 755 $i/$i $RPM_BUILD_ROOT%{_bindir}
install -m 644 $i/$i.yml $RPM_BUILD_ROOT%{_sysconfdir}/beats
install -m 644 $i/$i.reference.yml $RPM_BUILD_ROOT%{_sysconfdir}/beats
# install -D -m 644 build/suse-$i-amd64.service $RPM_BUILD_ROOT%{_unitdir}/$i.service
touch $RPM_BUILD_ROOT%{_unitdir}/$i.service
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rc$i
done
#
# logrotate
#%{__install} -D -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/auditbeat
#%{__install} -D -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/filebeat
#%{__install} -D -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/heartbeat
#%{__install} -D -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/metricbeat
#%{__install} -D -m 644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/packetbeat
%pre -n auditbeat
%if 0%{?has_systemd}
%service_add_pre auditbeat.service
%endif
%pre -n filebeat
%if 0%{?has_systemd}
%service_add_pre filebeat.service
%endif
%pre -n heartbeat
%if 0%{?has_systemd}
%service_add_pre heartbeat.service
%endif
%pre -n metricbeat
%if 0%{?has_systemd}
%service_add_pre metricbeat.service
%endif
%pre -n packetbeat
%if 0%{?has_systemd}
%service_add_pre packetbeat.service
%endif
%preun -n auditbeat
%if 0%{?has_systemd}
%service_del_preun auditbeat.service
%else
%stop_on_removal
%endif
%preun -n filebeat
%if 0%{?has_systemd}
%service_del_preun filebeat.service
%else
%stop_on_removal
%endif
%preun -n heartbeat
%if 0%{?has_systemd}
%service_del_preun heartbeat.service
%else
%stop_on_removal
%endif
%preun -n metricbeat
%if 0%{?has_systemd}
%service_del_preun metricbeat.service
%else
%stop_on_removal
%endif
%preun -n packetbeat
%if 0%{?has_systemd}
%service_del_preun packetbeat.service
%else
%stop_on_removal
%endif
%post -n auditbeat
%if 0%{?has_systemd}
%service_add_post auditbeat.service
%else
%{fillup_and_insserv -n -y auditbeat}
%endif
%post -n filebeat
%if 0%{?has_systemd}
%service_add_post filebeat.service
%else
%{fillup_and_insserv -n -y filebeat}
%endif
%post -n heartbeat
%if 0%{?has_systemd}
%service_add_post heartbeat.service
%else
%{fillup_and_insserv -n -y heartbeat}
%endif
%post -n metricbeat
%if 0%{?has_systemd}
%service_add_post metricbeat.service
%else
%{fillup_and_insserv -n -y metricbeat}
%endif
%post -n packetbeat
%if 0%{?has_systemd}
%service_add_post packetbeat.service
%else
%{fillup_and_insserv -n -y packetbeat}
%endif
%postun -n auditbeat
## no auto restart on update
export DISABLE_RESTART_ON_UPDATE=1
%if 0%{?has_systemd}
%service_del_postun auditbeat.service
%else
%insserv_cleanup
%endif
%postun -n filebeat
## no auto restart on update
export DISABLE_RESTART_ON_UPDATE=1
%if 0%{?has_systemd}
%service_del_postun filebeat.service
%else
%insserv_cleanup
%endif
%postun -n heartbeat
## no auto restart on update
export DISABLE_RESTART_ON_UPDATE=1
%if 0%{?has_systemd}
%service_del_postun heartbeat.service
%else
%insserv_cleanup
%endif
%postun -n metricbeat
## no auto restart on update
export DISABLE_RESTART_ON_UPDATE=1
%if 0%{?has_systemd}
%service_del_postun metricbeat.service
%else
%insserv_cleanup
%endif
%postun -n packetbeat
## no auto restart on update
export DISABLE_RESTART_ON_UPDATE=1
%if 0%{?has_systemd}
%service_del_postun packetbeat.service
%else
%insserv_cleanup
%endif
%files -n auditbeat
%defattr(-,root,root)
%doc LICENSE.txt
%doc NOTICE.txt
%doc CHANGELOG.asciidoc
#%config(noreplace) %{_sysconfdir}/logrotate.d/auditbeat
%if 0%{?has_systemd}
%{_unitdir}/auditbeat.service
%else
%attr(755,root,root) %{_initddir}/auditbeat
%dir %{_sysctldir}
%endif
%{_sbindir}/rcauditbeat
%{_bindir}/auditbeat
%dir %{_sysconfdir}/beats
%config %{_sysconfdir}/beats/auditbeat*.yml
%files -n filebeat
%defattr(-,root,root)
%doc filebeat/README.md
%doc LICENSE.txt
%doc NOTICE.txt
%doc CHANGELOG.asciidoc
#%config(noreplace) %{_sysconfdir}/logrotate.d/filebeat
%if 0%{?has_systemd}
%{_unitdir}/filebeat.service
%else
%attr(755,root,root) %{_initddir}/filebeat
%dir %{_sysctldir}
%endif
%{_sbindir}/rcfilebeat
%{_bindir}/filebeat
%dir %{_sysconfdir}/beats
%config %{_sysconfdir}/beats/filebeat*yml
%files -n heartbeat
%defattr(-,root,root)
%doc heartbeat/README.md
%doc LICENSE.txt
%doc NOTICE.txt
%doc CHANGELOG.asciidoc
%if 0%{?has_systemd}
%{_unitdir}/heartbeat.service
%else
%attr(755,root,root) %{_initddir}/heartbeat
%dir %{_sysctldir}
%endif
%{_sbindir}/rcheartbeat
%{_bindir}/heartbeat
%dir %{_sysconfdir}/beats
%config %{_sysconfdir}/beats/heartbeat*.yml
%files -n metricbeat
%defattr(-,root,root)
%doc metricbeat/README.md
%doc LICENSE.txt
%doc NOTICE.txt
%doc CHANGELOG.asciidoc
%if 0%{?has_systemd}
%{_unitdir}/metricbeat.service
%else
%attr(755,root,root) %{_initddir}/metricbeat
%dir %{_sysctldir}
%endif
%{_sbindir}/rcmetricbeat
%{_bindir}/metricbeat
%dir %{_sysconfdir}/beats
%config %{_sysconfdir}/beats/metricbeat*.yml
%files -n packetbeat
%defattr(-,root,root)
%doc packetbeat/README.md
%doc LICENSE.txt
%doc NOTICE.txt
%doc CHANGELOG.asciidoc
%if 0%{?has_systemd}
%{_unitdir}/packetbeat.service
%else
%attr(755,root,root) %{_initddir}/packetbeat
%dir %{_sysctldir}
%endif
%{_sbindir}/rcpacketbeat
%{_bindir}/packetbeat
%dir %{_sysconfdir}/beats
%config %{_sysconfdir}/beats/packetbeat*.yml
%changelog