From 72653518fc6db1566c1786f29796fcbde27bcb07 Mon Sep 17 00:00:00 2001 From: slerena Date: Fri, 18 Dec 2009 18:22:33 +0000 Subject: [PATCH] 2009-12-18 Sancho Lerena * pandora_server.spec: Added xprobe2 dep (we made the xprobe2 rpm package so now it's possible to satisfy dependency). Alter all paths to binary from /usr/local/bin to /usr/bin. Other minor issues in RPM fixed. * pandora_server_installer: Added description to get deps from zypper and yum. Installing services in debian/ubunty systems with update-rc.d. Make check to link from /usr/local/bin to /usr/bin if install deploy binary at /usr/local. /usr/bin is the new default. * pandora_server_upgrade: /usr/bin as new default. Link issue fixed. * DEBIAN/make_deb_package.sh: Fixed Makefile replace regexp to replace all target binary to put then in the jail under /usr/bin path. * DEBIAN/postinst: Fixed path for tentacle_server at /usr/bin * DEBIAN/prerm: Using native debian commands to remove services. * Tools.pm: If there is a problem loading something in the enterprise, show it to log. * util/pandora_server, util/tentacle_serverd: new path to /usr/bin/ * pandora_server.conf: new path for pandora_exec to /usr/bin/ * util/plugin/udp_nmap_plugin.sh: Check parameters before calling to namp. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2220 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 30 ++++++++++ pandora_server/DEBIAN/make_deb_package.sh | 19 ++++-- pandora_server/DEBIAN/postinst | 2 +- pandora_server/DEBIAN/prerm | 8 +-- pandora_server/Makefile.PL | 2 +- pandora_server/conf/pandora_server.conf | 4 +- pandora_server/lib/PandoraFMS/Tools.pm | 3 +- pandora_server/pandora_server.spec | 29 +++++----- pandora_server/pandora_server_installer | 58 +++++++++++-------- pandora_server/pandora_server_upgrade | 11 ++-- pandora_server/util/pandora_server | 2 +- pandora_server/util/plugin/udp_nmap_plugin.sh | 5 ++ pandora_server/util/tentacle_serverd | 2 +- 13 files changed, 117 insertions(+), 58 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 14eb26bf9b..2b3f311444 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,33 @@ +2009-12-18 Sancho Lerena + + * pandora_server.spec: Added xprobe2 dep (we made the xprobe2 rpm package + so now it's possible to satisfy dependency). Alter all paths to binary from + /usr/local/bin to /usr/bin. Other minor issues in RPM fixed. + + * pandora_server_installer: Added description to get deps from zypper and yum. + Installing services in debian/ubunty systems with update-rc.d. + Make check to link from /usr/local/bin to /usr/bin if install + deploy binary at /usr/local. /usr/bin is the new default. + + * pandora_server_upgrade: /usr/bin as new default. Link issue fixed. + + * DEBIAN/make_deb_package.sh: Fixed Makefile replace regexp to replace all + target binary to put then in the jail under /usr/bin path. + + * DEBIAN/postinst: Fixed path for tentacle_server at /usr/bin + + * DEBIAN/prerm: Using native debian commands to remove services. + + * Tools.pm: If there is a problem loading something in the enterprise, show it + to log. + + * util/pandora_server, + util/tentacle_serverd: new path to /usr/bin/ + + * pandora_server.conf: new path for pandora_exec to /usr/bin/ + + * util/plugin/udp_nmap_plugin.sh: Check parameters before calling to namp. + 2009-12-18 Raul Mateos * pandora_dbstress.pl, pandora_db.pl: Clean code, updated year. diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index a9d4bf360d..3dc0c2d452 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_console_version="3.0.0." +pandora_console_version="3.0.0" echo "This script to make deb must run as root (because the dh-make-perl need this). Then test if you are root." if [ `id -u` != 0 ] @@ -46,20 +46,31 @@ mkdir -p temp_package/etc/pandora mkdir -p temp_package/etc/init.d/ mkdir -p temp_package/etc/logrotate.d mkdir -p temp_package/usr/share/pandora_server -mkdir -p temp_package/usr/local/bin +mkdir -p temp_package/usr/bin echo "Make the perl of Pandora Server." perl Makefile.PL make + +# Adjust Makefile to use our "fake" root dir to install libraries and also binaries" cat Makefile | sed -e "s/PREFIX = \/usr/PREFIX = temp_package\/usr/" > Makefile.temp + +# This is needed to create .DEB in OpenSUSE. + +cat Makefile.temp | sed -e "s/INSTALLBIN = .*/INSTALLBIN = temp_package\/usr\/bin/" > Makefile +cat Makefile | sed -e "s/INSTALLSITEBIN = .*/INSTALLSITEBIN = temp_package\/usr\/bin/" > Makefile.temp +cat Makefile.temp | sed -e "s/INSTALLVENDORBIN = .*/INSTALLVENDORBIN = temp_package\/usr\/bin/" > Makefile +cat Makefile | sed -e "s/INSTALLSCRIPT = .*/INSTALLSCRIPT = temp_package\/usr\/bin/" > Makefile.temp +cat Makefile.temp | sed -e "s/INSTALLSITESCRIPT = .*/INSTALLSITESCRIPT = temp_package\/usr\/bin/" > Makefile +cat Makefile | sed -e "s/INSTALLVENDORSCRIPT = .*/INSTALLVENDORSCRIPT = temp_package\/usr\/bin/" > Makefile.temp + mv Makefile.temp Makefile -rm Makefile.temp make install echo "Copy other files in fake file." cp util/pandora_logrotate temp_package/etc/logrotate.d/pandora -cp bin/tentacle_server temp_package/usr/local/bin +cp bin/tentacle_server temp_package/usr/bin cp util/tentacle_serverd temp_package/etc/init.d/tentacle_serverd cp conf/pandora_server.conf temp_package/etc/pandora/ diff --git a/pandora_server/DEBIAN/postinst b/pandora_server/DEBIAN/postinst index 24d0645653..24cfcd84ac 100755 --- a/pandora_server/DEBIAN/postinst +++ b/pandora_server/DEBIAN/postinst @@ -60,7 +60,7 @@ echo "Creating common Pandora FMS directories" useradd pandora 2> /dev/null mkdir -p /home/pandora/.ssh 2> /dev/null chown -R pandora:root /home/pandora -chmod 755 /usr/local/bin/tentacle_server +chmod 755 /usr/bin/tentacle_server echo "Giving proper permission to /var/spool/pandora" chown -R pandora /var/spool/pandora/ diff --git a/pandora_server/DEBIAN/prerm b/pandora_server/DEBIAN/prerm index 592a569797..e1d662a682 100755 --- a/pandora_server/DEBIAN/prerm +++ b/pandora_server/DEBIAN/prerm @@ -60,10 +60,10 @@ rm /etc/pandora/pandora_server.conf GET_DISTRO="`get_distro`" DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"` -rm /etc/init.d/pandora_server -rm /etc/rc2.d/S90pandora_server -rm /etc/init.d/tentacle_serverd -rm /etc/rc2.d/S80tentacle_serverd +rm /etc/init.d/pandora_server +rm /etc/init.d/tentacle_serverd +update-rc.d pandora_server remove +update-rc.d tentacle_serverd remove if [ -d /etc/cron.daily ] then diff --git a/pandora_server/Makefile.PL b/pandora_server/Makefile.PL index c4650b40b4..0b27ea502d 100644 --- a/pandora_server/Makefile.PL +++ b/pandora_server/Makefile.PL @@ -4,7 +4,7 @@ use ExtUtils::MakeMaker; WriteMakefile( NAME => 'PandoraFMS', VERSION_FROM => 'lib/PandoraFMS/Config.pm', - AUTHOR => 'Artica ST ', + AUTHOR => 'Artica ST ', PREREQ_PM => { NetAddr::IP => 0, DBI => 0, diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index 28d3abc0fe..de75c0dfa9 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -85,9 +85,9 @@ reconserver 1 # DISABLED BY DEFAULT pluginserver 0 -# Pandora FMS Plugin exec tool filepath (by default at /usr/local/bin) +# Pandora FMS Plugin exec tool filepath (by default at /usr/bin) -plugin_exec /usr/local/bin/pandora_exec +plugin_exec /usr/bin/pandora_exec # predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup # DISABLED BY DEFAULT diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index a99d5b1422..2654b62795 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -334,7 +334,8 @@ sub enterprise_load ($) { #return 1 if (is_loaded ('PandoraFMS::Enterprise')); # Try to load the module - eval 'local $SIG{__DIE__}; require PandoraFMS::Enterprise;'; + # eval 'local $SIG{__DIE__}; require PandoraFMS::Enterprise;'; + eval 'require PandoraFMS::Enterprise;'; # Ops return 0 if ($@); diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 4071e2188e..f0c9419b0a 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 3.0.0 -%define release 2 +%define release 4 Summary: Pandora FMS Server Name: %{name} @@ -23,7 +23,7 @@ AutoReq: 0 Provides: %{name}-%{version} Requires: perl-Mail-Sendmail perl-DBI perl-DBD-mysql perl-time-format Requires: perl-NetAddr-IP net-snmp net-tools -Requires: nmap wmic sudo +Requires: nmap wmic sudo xprobe2 %description Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. @@ -46,8 +46,6 @@ export perl_version=5.10.0 rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/bin/ -mkdir -p $RPM_BUILD_ROOT/usr/local -mkdir -p $RPM_BUILD_ROOT/usr/local/bin mkdir -p $RPM_BUILD_ROOT/usr/sbin/ mkdir -p $RPM_BUILD_ROOT/etc/init.d/ mkdir -p $RPM_BUILD_ROOT/etc/pandora/ @@ -58,10 +56,10 @@ mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_server/conf/ mkdir -p $RPM_BUILD_ROOT/usr/lib/perl5/site_perl/$perl_version/ -# All binaries go to /usr/local/bin -cp -aRf bin/pandora_server $RPM_BUILD_ROOT/usr/local/bin/ -cp -aRf bin/pandora_exec $RPM_BUILD_ROOT/usr/local/bin/ -cp -aRf bin/tentacle_server $RPM_BUILD_ROOT/usr/local/bin/ +# All binaries go to /usr/bin +cp -aRf bin/pandora_server $RPM_BUILD_ROOT/usr/bin/ +cp -aRf bin/pandora_exec $RPM_BUILD_ROOT/usr/bin/ +cp -aRf bin/tentacle_server $RPM_BUILD_ROOT/usr/bin/ cp -aRf conf/* $RPM_BUILD_ROOT%{prefix}/pandora_server/conf/ cp -aRf util $RPM_BUILD_ROOT%{prefix}/pandora_server/ @@ -73,13 +71,19 @@ cp -aRf util/tentacle_serverd $RPM_BUILD_ROOT/etc/init.d/ %clean rm -fr $RPM_BUILD_ROOT + %pre /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora +if [ -e "/etc/pandora/pandora_server.conf" ] +then + cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old +fi exit 0 %post chkconfig -s pandora_server on chkconfig -s tentacle_serverd on + echo "/usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" > /etc/cron.daily/pandora_db chmod 750 /etc/cron.daily/pandora_db cp -aRf /usr/share/pandora_server/util/pandora_logrotate /etc/logrotate.d/pandora @@ -114,8 +118,7 @@ rm -Rf /usr/lib/perl5/site_perl/%{perl_version}/PandoraFMS/ rm -Rf /etc/pandora/pandora_server.conf rm -Rf /var/spool/pandora rm -Rf /etc/init.d/pandora_server /etc/init.d/tentacle_serverd -rm -Rf /usr/local/bin/pandora_exec /usr/local/bin/pandora_server -rm -Rf /usr/local/bin/tentacle_server +rm -Rf /usr/bin/pandora_exec /usr/bin/pandora_server /usr/bin/tentacle_server rm -Rf /etc/cron.daily/pandora_db rm -Rf /etc/logrotate.d/pandora @@ -126,9 +129,9 @@ rm -Rf /etc/logrotate.d/pandora /etc/init.d/tentacle_serverd %defattr(755,pandora,root) -/usr/local/bin/pandora_exec -/usr/local/bin/pandora_server -/usr/local/bin/tentacle_server +/usr/bin/pandora_exec +/usr/bin/pandora_server +/usr/bin/tentacle_server %defattr(755,pandora,root) /usr/lib/perl5/site_perl/%{perl_version}/PandoraFMS/ diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 8edae05bd3..a266bd29f2 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -88,11 +88,17 @@ install () { echo "The complete installation guide is at: "http://www.openideas.info/wiki/index.php?title=Pandora_2.0:Documentation_en:Install_Server#Pandora_FMS_Server_installation" " echo " " echo "Debian-based distribution do:" - echo " $ apt-get install snmp snmpd libtime-format-perl libxml-simple-perl libnetaddr-ip-perl libdbi-perl libxml-simple-perl libnetaddr-ip-perl libhtml-parser-perl wmi-client xprobe2 libmail-sendmail-perl" + echo " # apt-get install snmp snmpd libtime-format-perl libxml-simple-perl libnetaddr-ip-perl libdbi-perl libxml-simple-perl libnetaddr-ip-perl libhtml-parser-perl wmi-client xprobe2 libmail-sendmail-perl" echo " " - echo "RPM distribution do" + echo "For CentOS / RHEL do: " echo " " - echo " $ yum perl-XML-SAX* perl-Tie* perl-XML-Simple* perl-IO-Socket* perl-Time-modules* perl-NetAddr-IP* perl-DateTime* perl-ExtUtils perl-DBI" + echo " # yum install perl-XML-SAX* perl-Tie* perl-XML-Simple* perl-IO-Socket* perl-Time-modules* perl-NetAddr-IP* perl-DateTime* perl-ExtUtils perl-DBI nmap xprobe2" + echo " " + echo "For OpenSUSE / SLES do : " + echo " " + echo " # zypper install install nmap perl-DBD-mysql perl-DBI perl-Date-Calc perl-HTML-Parser +perl-HTML-Encoding perl-HTML-Tree perl-IO-Socket-Multicast perl-Mail-Sendmail perl-NetAddr-IP +perl-TimeDate perl-XML-Simple perl-libwww-perl mysql-client" echo " " echo " You also will need to install xprobe2 and wmiclient from rpm (download from our website)" echo " " @@ -121,6 +127,18 @@ install () { make make install + echo "Checking binaries at /usr/local/bin -> /usr/bin" + if [ ! -e "/usr/bin/pandora_server" ] + then + if [ ! -e "/usr/local/bin/pandora_server" ] + then + echo "ERROR compiling Pandora FMS Server from sources. Aborting" + exit 1 + fi + ln -s /usr/local/bin/pandora_server /usr/bin + ln -s /usr/local/bin/pandora_exec /usr/bin + fi + echo "Creating common Pandora FMS directories" id pandora if [ $? -eq 0 ]; then @@ -145,8 +163,8 @@ install () { mkdir $PANDORA_SPOOL/data_in 2> /dev/null mkdir $PANDORA_SPOOL/data_in/conf 2> /dev/null mkdir $PANDORA_SPOOL/data_in/md5 2> /dev/null - mkdir $PANDORA_LOG 2> /dev/null - + mkdir $PANDORA_LOG 2> /dev/null + echo "Giving proper permission to /var/spool/pandora" id -g www-data > /dev/null if [ $? -eq 0 ] @@ -187,14 +205,11 @@ install () { echo "Copying the daemon script into /etc/init.d/pandora_server" cp util/pandora_server /etc/init.d/ - if [ "$DISTRO" == "UBUNTU" ] + if [ "$DISTRO" == "UBUNTU" ] || [ "$DISTRO" == "DEBIAN" ] then + echo "Linking startup script to /etc/rc2.d" - ln -s $PANDORA_SERVER /etc/rc2.d/S90pandora_server - echo "Linking stop daemon scripts"; - ln -s $PANDORA_SERVER /etc/rc0.d/K90pandora_server - ln -s $PANDORA_SERVER /etc/rc1.d/K90pandora_server - ln -s $PANDORA_SERVER /etc/rc6.d/K90pandora_server + update-rc.d pandora_server defaults else if [ "$DISTRO" == "SUSE" ] then @@ -224,34 +239,31 @@ install () { then if [ "$SECOPT" != "--no-tentacle" ] then - if [ "$DISTRO" == "UBUNTU" ] + if [ "$DISTRO" == "UBUNTU" ] || [ "$DISTRO" == "DEBIAN" ] then # Tentacle server install (Ubuntu) - echo "Installing tentacle server in /etc/rc2.d/S80tentacle_serverd" - cp bin/tentacle_server /usr/local/bin + echo "Installing tentacle server" + cp bin/tentacle_server /usr/bin cp util/tentacle_serverd $TENTACLE_SERVER - ln -s $TENTACLE_SERVER /etc/rc2.d/S80tentacle_serverd - ln -s $TENTACLE_SERVER /etc/rc0.d/K80tentacle_serverd - ln -s $TENTACLE_SERVER /etc/rc1.d/K80tentacle_serverd - ln -s $TENTACLE_SERVER /etc/rc6.d/K80tentacle_serverd + update-rc.d tentacle_serverd defaults else if [ "$DISTRO" == "SUSE" ] then echo "Creating Tentacle startup daemon" - cp bin/tentacle_server /usr/local/bin + cp bin/tentacle_server /usr/bin cp util/tentacle_serverd /etc/init.d/tentacle_serverd insserv tentacle_serverd else # Tentacle server install (Other Distros) echo "Installing tentacle server in /etc/rc.d/rc$INITLV.d/S80tentacle_serverd" - cp bin/tentacle_server /usr/local/bin + cp bin/tentacle_server /usr/bin cp util/tentacle_serverd /etc/init.d/tentacle_serverd ln -s $TENTACLE_SERVER /etc/rc.d/rc$INITLV.d/S80tentacle_serverd fi fi fi fi - + echo "Creating Pandora FMS distribution directory in /usr/share/pandora_server" mkdir $PANDORA_HOME 2> /dev/null cp -R util $PANDORA_HOME @@ -300,12 +312,12 @@ uninstall () { rm -Rf $PANDORA_LOG 2> /dev/null rm -Rf $PANDORA_CFG_FILE 2> /dev/null rm -Rf $PANDORA_SERVER 2> /dev/null - rm -Rf /usr/local/bin/pandora_server 2> /dev/null rm -Rf /usr/bin/pandora_server 2> /dev/null + rm -Rf /usr/bin/pandora_exec 2> /dev/null rm -Rf $PANDORA_HOME rm -Rf /etc/cron.daily/pandora_db rm -Rf /etc/logrotate.d/pandora - if [ "$DISTRO" == "UBUNTU" ] + if [ "$DISTRO" == "UBUNTU" ] || [ "$DISTRO" == "DEBIAN" ] then update-rc.d -f pandora_server remove update-rc.d -f tentacle_serverd remove diff --git a/pandora_server/pandora_server_upgrade b/pandora_server/pandora_server_upgrade index 643586b7d4..9e2a402e6b 100644 --- a/pandora_server/pandora_server_upgrade +++ b/pandora_server/pandora_server_upgrade @@ -4,7 +4,7 @@ # Linux Version (generic), for SuSe and Debian/Ubuntu only # other Linux distros could not work properly without modifications # Please see http://www.pandorafms.org -# v3.0.1 Build 091216 +# v3.0.1 Build 091218 # This code is licensed under GPL 2.0 license. # ********************************************************************** @@ -29,14 +29,11 @@ install () { echo "Copying utilities...." cp -R util /usr/share/pandora_server - cp bin/pandora_exec /usr/local/bin + cp bin/pandora_exec /usr/bin echo "Rebuilding links /usr/local/bin -> /usr/bin" - rm /usr/bin/pandora_server - rm /usr/bin/pandora_exec - ln -s /usr/local/bin/pandora_server /usr/bin - ln -s /usr/local/bin/pandora_exec /usr/bin - ln -s /usr/local/bin/tentacle_server /usr/bin + rm /usr/local/bin/pandora_server 2> /dev/null + rm /usr/local/bin/pandora_exec 2> /dev/null if [ -d /etc/logrotate.d ]; then echo "Creating logrotate.d entry for Pandora FMS log management" diff --git a/pandora_server/util/pandora_server b/pandora_server/util/pandora_server index 1921029beb..296f6461f9 100755 --- a/pandora_server/util/pandora_server +++ b/pandora_server/util/pandora_server @@ -23,7 +23,7 @@ # this script to another name, editing PANDORA_HOME to the new .conf export PANDORA_HOME="/etc/pandora/pandora_server.conf" -export PANDORA_DAEMON=/usr/local/bin/pandora_server +export PANDORA_DAEMON=/usr/bin/pandora_server # Uses a wait limit before sending a KILL signal, before trying to stop # Pandora FMS server nicely. Some big systems need some time before close diff --git a/pandora_server/util/plugin/udp_nmap_plugin.sh b/pandora_server/util/plugin/udp_nmap_plugin.sh index dcf90c6ac7..5fd4b8336c 100755 --- a/pandora_server/util/plugin/udp_nmap_plugin.sh +++ b/pandora_server/util/plugin/udp_nmap_plugin.sh @@ -49,6 +49,11 @@ while getopts ":hp:t:" optname esac done +if [ -z "$PORT" ] || [ -z "$HOST" ] +then + help +fi + # execution nmap -T5 -p $PORT -sU $HOST | grep open | wc -l 2> /dev/null diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd index 53db51b443..a03e27ca0e 100755 --- a/pandora_server/util/tentacle_serverd +++ b/pandora_server/util/tentacle_serverd @@ -42,7 +42,7 @@ PANDORA_SERVER_PATH="/var/spool/pandora/data_in" # Tentacle server settings TENTACLE_DAEMON="tentacle_server" -TENTACLE_PATH="/usr/local/bin" +TENTACLE_PATH="/usr/bin" TENTACLE_USER="pandora" TENTACLE_ADDR="0.0.0.0"