File pandorafms_server.spec of Package pandorafms_server

# spec file for package pandorafms_server
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# 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

# User and Group under which Apache is running
%define httpd_user  wwwrun
%define httpd_group www
%define httpd_root  /srv/www

Name:           pandorafms_server
Version:        6.0SP5
Release:        0
Summary:        Pandora FMS Server
License:        GPL-2.0
Group:          System/Monitoring
Source0:        %{name}-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  fdupes
BuildArch:      noarch
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         %fillup_prereq %insserv_prereq %{_bindir}/sed %{_bindir}/grep
Requires(pre):  shadow
Requires:       net-snmp
Requires:       net-tools
Requires:       nmap
Requires:       perl-DBD-mysql
Requires:       perl-DBI
Requires:       perl-Encode-Locale
Requires:       perl-HTML-Tree
Requires:       perl-IO-Socket-INET6
Requires:       perl-JSON
Requires:       perl-Net-Telnet
Requires:       perl-NetAddr-IP
Requires:       perl-Socket6
Requires:       perl-XML-Simple
Requires:       perl-XML-Twig
Requires:       perl-libwww-perl
Requires:       snmp-mibs
Requires:       sudo
Requires:       wmic

# 2017-03: we got an old package with this name
Provides:       pandora-server = %{version}
Obsoletes:      pandora-server < %{version}

Pandora FMS is a monitoring Open Source software. It watches your systems and applications, and allows you to know the status of any element of those systems.

Pandora FMS could detect a network interface down, a defacement in your website, a memory leak in one of your server application, or the movement of any value of the NASDAQ new technology market. Pandora FMS could send out SMS message when your systems fails... or when Google's value drop below US348.60?

Pandora FMS runs on any operating system, with specific agents for each platform, gathering data and sending it to a server, it has specific agents for GNU/Linux, AIX, Solaris, HP-UX, BSD/IPSO, and Windows 2000, XP and 2003.

Pandora FMS can also monitor any kind of TCP/IP service, without the need to install agents, and monitor network systems such as load balancers, routers, switches, operating systems, applications, or simply printers if you need. Pandora FMS also supports SNMP for collecting data and for receiving traps.

A few examples of common resources monitored by Pandora FMS could be processor load, disk and memory usage, running processes, log files, environmental factors such as temperature, or application values like strings contained in web pages or any possible way to collect data in an automatic way.

%setup -q -n pandora_server

# remove unnecessary files

# rpmlint: wrong-file-end-of-line-encoding
find lib -type f -exec perl -p -i -e "s|\r\n|\n|" {} +
find util -type f -exec perl -p -i -e "s|\r\n|\n|" {} +


mkdir -p %{buildroot}%{_bindir}/
mkdir -p %{buildroot}%{_sbindir}/
mkdir -p %{buildroot}%{_initddir}/
mkdir -p %{buildroot}%{_sysconfdir}/pandora/
mkdir -p %{buildroot}%{_localstatedir}/spool/pandora/data_in
mkdir -p %{buildroot}%{_localstatedir}/spool/pandora/data_in/conf
mkdir -p %{buildroot}%{_localstatedir}/spool/pandora/data_in/md5
mkdir -p %{buildroot}%{_localstatedir}/spool/pandora/data_in/collections
mkdir -p %{buildroot}%{_localstatedir}/spool/pandora/data_in/netflow
mkdir -p %{buildroot}%{_localstatedir}/log/pandora/
mkdir -p %{buildroot}%{_datadir}/pandora_server/conf/
mkdir -p %{buildroot}%{_prefix}/lib/perl5/
mkdir -p %{buildroot}%{_mandir}/man1/

# All binaries go to /usr/bin
cp -r bin/pandora_server %{buildroot}%{_bindir}/
cp -r bin/pandora_exec %{buildroot}%{_bindir}/
cp -r bin/tentacle_server %{buildroot}%{_bindir}/

cp -r conf/* %{buildroot}%{_datadir}/pandora_server/conf/
cp -r conf/ %{buildroot}%{_sysconfdir}/pandora/
cp -r util %{buildroot}%{_datadir}/pandora_server/
cp -r lib/* %{buildroot}%{_prefix}/lib/perl5/
cp -r AUTHORS COPYING README %{buildroot}%{_datadir}/pandora_server/

cp -r util/pandora_server %{buildroot}%{_initddir}/
cp -r util/tentacle_serverd %{buildroot}%{_initddir}/

cp -r man/man1/pandora_server.1.gz %{buildroot}%{_mandir}/man1/
cp -r man/man1/tentacle_server.1.gz %{buildroot}%{_mandir}/man1/

rm -Rf %{buildroot}%{_datadir}/pandora_server/util/PandoraFMS
rm -Rf %{buildroot}%{_datadir}/pandora_server/util/recon_scripts/PandoraFMS

if [ "`id pandora | grep uid | wc -l`" = 0 ]
  useradd -d %{_datadir}/pandora -s /bin/false -M -g 0 pandora
exit 0

echo "%{_datadir}/pandora_server/util/ %{_sysconfdir}/pandora/pandora_server.conf" > %{_sysconfdir}/cron.hourly/pandora_db
chmod 750 %{_sysconfdir}/cron.hourly/pandora_db
cp -r %{_datadir}/pandora_server/util/pandora_server_logrotate %{_sysconfdir}/logrotate.d/pandora_server

if [ ! -d %{_sysconfdir}/pandora ] ; then
  mkdir -p %{_sysconfdir}/pandora

if [ ! -e "%{_sysconfdir}/pandora/pandora_server.conf" ]
  echo "Creating a new version of Pandora FMS Server config file at %{_sysconfdir}/pandora/pandora_server.conf"
  cat %{_sysconfdir}/pandora/ > %{_sysconfdir}/pandora/pandora_server.conf
  # Do a copy of current .conf, just in case.
  echo "An existing version of pandora_server.conf is found."
  cat %{_sysconfdir}/pandora/pandora_server.conf > %{_sysconfdir}/pandora/pandora_server.conf.old

echo "Don't forget to start Tentacle Server daemon if you want to receive"
echo "data using tentacle"
exit 0