Splitted log rotation. Each part (agent, console, server) controls

his own log rotation.
This commit is contained in:
fermin831 2015-11-02 16:52:30 +01:00
parent 806b6999bb
commit 6b724f3c15
14 changed files with 117 additions and 7 deletions

View File

@ -42,6 +42,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/pandora/
mkdir -p $RPM_BUILD_ROOT/etc/init.d/ mkdir -p $RPM_BUILD_ROOT/etc/init.d/
mkdir -p $RPM_BUILD_ROOT/var/log/pandora/ mkdir -p $RPM_BUILD_ROOT/var/log/pandora/
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/
cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/ cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_agent/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/tentacle_client $RPM_BUILD_ROOT/usr/bin/
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent $RPM_BUILD_ROOT/usr/bin/
@ -53,6 +54,8 @@ cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/man/man1/tentacle_client.1.gz $RP
cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew cp -aRf $RPM_BUILD_ROOT%{prefix}/pandora_agent/Linux/pandora_agent.conf $RPM_BUILD_ROOT/usr/share/pandora_agent/pandora_agent.conf.rpmnew
install -m 0644 pandora_agent_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_agent
if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then if [ -f $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec ] ; then
rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec rm $RPM_BUILD_ROOT%{prefix}/pandora_agent/pandora_agent.spec
fi fi
@ -115,6 +118,7 @@ exit 0
%defattr(750,pandora,root) %defattr(750,pandora,root)
/usr/bin/pandora_agent /usr/bin/pandora_agent
/usr/bin/pandora_agent_exec /usr/bin/pandora_agent_exec
%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_agent
%defattr(755,pandora,root) %defattr(755,pandora,root)
/usr/bin/tentacle_client /usr/bin/tentacle_client

View File

@ -89,6 +89,7 @@ fi
if [ ! -e /etc/pandora/collections ]; then if [ ! -e /etc/pandora/collections ]; then
ln -s /usr/share/pandora_agent/collections /etc/pandora ln -s /usr/share/pandora_agent/collections /etc/pandora
fi fi
cp -aRf /usr/share/pandora_agent/pandora_agent_logrotate /etc/logrotate.d/pandora_agent
mkdir -p /var/spool/pandora/data_out mkdir -p /var/spool/pandora/data_out
chkconfig pandora_agent_daemon on chkconfig pandora_agent_daemon on
@ -111,6 +112,15 @@ rm -Rf /usr/share/man/man1/pandora_agent.1.gz
rm -Rf /usr/share/man/man1/tentacle_client.1.gz rm -Rf /usr/share/man/man1/tentacle_client.1.gz
exit 0 exit 0
%postun
# Upgrading
if [ "$1" = "1" ]; then
exit 0
fi
rm -Rf /etc/logrotate.d/pandora_agent
%files %files
%defattr(750,pandora,root) %defattr(750,pandora,root)
/usr/bin/pandora_agent /usr/bin/pandora_agent

View File

@ -154,6 +154,7 @@ uninstall () {
rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null
rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null
rm -f $DESTDIR/etc/logrotate.d/pandora_agent
#Test if exist Pandora Server in this machine #Test if exist Pandora Server in this machine
if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ] if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ]
@ -465,6 +466,15 @@ install () {
done done
[ "$MSG" ] && echo "$MSG" [ "$MSG" ] && echo "$MSG"
fi fi
if [ -d /etc/logrotate.d ]
then
[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
echo "Creating logrotate.d entry for Pandora FMS log management"
cp pandora_agent_logrotate $DESTDIR/etc/logrotate.d/pandora_agent
else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi
echo "Done." echo "Done."
echo " " echo " "

View File

@ -0,0 +1 @@
/var/log/pandora/pandora_agent.log

View File

@ -47,9 +47,11 @@ rm -rf $RPM_BUILD_ROOT
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_console mkdir -p $RPM_BUILD_ROOT%{prefix}/pandora_console
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/
cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_console cp -aRf * $RPM_BUILD_ROOT%{prefix}/pandora_console
rm $RPM_BUILD_ROOT%{prefix}/pandora_console/*.spec rm $RPM_BUILD_ROOT%{prefix}/pandora_console/*.spec
rm $RPM_BUILD_ROOT%{prefix}/pandora_console/pandora_console_install rm $RPM_BUILD_ROOT%{prefix}/pandora_console/pandora_console_install
install -m 0644 pandora_console_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_console
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
@ -76,3 +78,4 @@ fi
%defattr(0644,%{httpd_user},%{httpd_group},0755) %defattr(0644,%{httpd_user},%{httpd_group},0755)
%docdir %{prefix}/pandora_console/docs %docdir %{prefix}/pandora_console/docs
%{prefix}/pandora_console %{prefix}/pandora_console
%config(noreplace) %{_sysconfdir}/logrotate.d/pandora_console

View File

@ -66,7 +66,7 @@ if [ -f %{prefix}/pandora_console/include/config.php ] ; then
else else
echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it." echo "Please, now, point your browser to http://your_IP_address/pandora_console/install.php and follow all the steps described on it."
fi fi
cp -aRf %{prefix}/pandora_console/pandora_console_logrotate /etc/logrotate.d/pandora_console
%preun %preun
@ -77,6 +77,15 @@ fi
rm -Rf %{prefix}/pandora_console rm -Rf %{prefix}/pandora_console
%postun
# Upgrading
if [ "$1" = "1" ]; then
exit 0
fi
rm -Rf /etc/logrotate.d/pandora_console
%files %files
%defattr(0644,%{httpd_user},%{httpd_group},0755) %defattr(0644,%{httpd_user},%{httpd_group},0755)
%docdir %{prefix}/pandora_console/docs %docdir %{prefix}/pandora_console/docs

View File

@ -110,6 +110,7 @@ uninstall () {
echo "Removing Pandora FMS Console" echo "Removing Pandora FMS Console"
rm -Rf $PANDORA_HOME rm -Rf $PANDORA_HOME
rm -f $DESTDIR/etc/logrotate.d/pandora_console
echo "You need to drop manually pandora database from your Database server" echo "You need to drop manually pandora database from your Database server"
echo "Done" echo "Done"
} }
@ -178,6 +179,15 @@ install () {
[ ! -d $DESTDIR/var/spool/pandora/data_in/$subdir ] && mkdir -p $DESTDIR/var/spool/pandora/data_in/$subdir [ ! -d $DESTDIR/var/spool/pandora/data_in/$subdir ] && mkdir -p $DESTDIR/var/spool/pandora/data_in/$subdir
done done
if [ -d /etc/logrotate.d ]
then
[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
echo "Creating logrotate.d entry for Pandora FMS log management"
cp pandora_console_logrotate $DESTDIR/etc/logrotate.d/pandora_console
else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi
#Ownership #Ownership
chown -R $WWWUSER:$PANDORA_HOME_GROUP $DESTDIR$PANDORA_HOME 2> /dev/null chown -R $WWWUSER:$PANDORA_HOME_GROUP $DESTDIR$PANDORA_HOME 2> /dev/null
chown -R pandora:$WWWGROUP $DESTDIR/var/spool/pandora/ 2> /dev/null chown -R pandora:$WWWGROUP $DESTDIR/var/spool/pandora/ 2> /dev/null

View File

@ -0,0 +1,35 @@
# DEBIAN / UBUNTU
/var/www/pandora_console/pandora_console.log {
weekly
missingok
size 100000
rotate 3
maxage 15
compress
notifempty
create 644 www-data www-data
}
# OpenSUSE, SLES
/srv/www/htdocs/pandora_console/pandora_console.log {
weekly
missingok
size 100000
rotate 3
maxage 15
compress
notifempty
create 644 wwwrun www
}
# Centos, Redhat, Fedora
/var/www/html/pandora_console/pandora_console.log {
weekly
missingok
size 100000
rotate 3
maxage 15
compress
notifempty
create 644 apache root
}

View File

@ -78,6 +78,13 @@ pandora_upgrade () {
return 1 return 1
fi fi
if [ -d /etc/logrotate.d ]; then
echo "Creating logrotate.d entry for Pandora FMS log management"
cp pandora_console_logrotate /etc/logrotate.d/pandora_console
else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi
# Remove unnecessary files (optional, set variable to activate) # Remove unnecessary files (optional, set variable to activate)
REMOVEFILES=0 REMOVEFILES=0

View File

@ -77,7 +77,7 @@ install -m 0444 man/man1/tentacle_server.1.gz $RPM_BUILD_ROOT%{_mandir}/man1/
rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/PandoraFMS rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/PandoraFMS
rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS
install -m 0644 util/pandora_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_server install -m 0644 util/pandora_server_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_server
install -m 0640 conf/pandora_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/pandora/pandora_server.conf.new install -m 0640 conf/pandora_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/pandora/pandora_server.conf.new
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d

View File

@ -100,7 +100,7 @@ chkconfig tentacle_serverd on
echo "/usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" > /etc/cron.hourly/pandora_db echo "/usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" > /etc/cron.hourly/pandora_db
chmod 750 /etc/cron.hourly/pandora_db chmod 750 /etc/cron.hourly/pandora_db
cp -aRf /usr/share/pandora_server/util/pandora_logrotate /etc/logrotate.d/pandora cp -aRf /usr/share/pandora_server/util/pandora_server_logrotate /etc/logrotate.d/pandora_server
if [ ! -d /etc/pandora ] ; then if [ ! -d /etc/pandora ] ; then
mkdir -p /etc/pandora mkdir -p /etc/pandora
@ -150,7 +150,7 @@ rm -Rf /var/spool/pandora
rm -Rf /etc/init.d/pandora_server /etc/init.d/tentacle_serverd rm -Rf /etc/init.d/pandora_server /etc/init.d/tentacle_serverd
rm -Rf /usr/bin/pandora_exec /usr/bin/pandora_server /usr/bin/tentacle_server rm -Rf /usr/bin/pandora_exec /usr/bin/pandora_server /usr/bin/tentacle_server
rm -Rf /etc/cron.hourly/pandora_db rm -Rf /etc/cron.hourly/pandora_db
rm -Rf /etc/logrotate.d/pandora rm -Rf /etc/logrotate.d/pandora_server
rm -Rf /usr/share/man/man1/pandora_server.1.gz rm -Rf /usr/share/man/man1/pandora_server.1.gz
rm -Rf /usr/share/man/man1/tentacle_server.1.gz rm -Rf /usr/share/man/man1/tentacle_server.1.gz

View File

@ -339,7 +339,7 @@ perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client"
then then
[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d [ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
echo "Creating logrotate.d entry for Pandora FMS log management" echo "Creating logrotate.d entry for Pandora FMS log management"
cp util/pandora_logrotate $DESTDIR/etc/logrotate.d/pandora cp util/pandora_server_logrotate $DESTDIR/etc/logrotate.d/pandora_server
else else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)" echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi fi
@ -450,7 +450,7 @@ uninstall () {
rm -f $DESTDIR$PREFIX/bin/tentacle_server 2> /dev/null rm -f $DESTDIR$PREFIX/bin/tentacle_server 2> /dev/null
rm -Rf $DESTDIR$PANDORA_HOME rm -Rf $DESTDIR$PANDORA_HOME
rm -f $DESTDIR/etc/cron.hourly/pandora_db rm -f $DESTDIR/etc/cron.hourly/pandora_db
rm -f $DESTDIR/etc/logrotate.d/pandora rm -f $DESTDIR/etc/logrotate.d/pandora_server
if [ "$DESTDIR" ] if [ "$DESTDIR" ]
then then
# do nothing with "fakeroot" uninstallation # do nothing with "fakeroot" uninstallation

View File

@ -38,7 +38,7 @@ install () {
if [ -d /etc/logrotate.d ]; then if [ -d /etc/logrotate.d ]; then
echo "Creating logrotate.d entry for Pandora FMS log management" echo "Creating logrotate.d entry for Pandora FMS log management"
cp util/pandora_logrotate /etc/logrotate.d/pandora cp util/pandora_server_logrotate /etc/logrotate.d/pandora_server
else else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)" echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi fi

View File

@ -0,0 +1,21 @@
/var/log/pandora/pandora_server.log
/var/log/pandora/pandora_server.error {
weekly
missingok
size 300000
rotate 3
maxage 90
compress
notifempty
copytruncate
}
/var/log/pandora/pandora_snmptrap.log {
weekly
missingok
size 500000
rotate 1
maxage 30
notifempty
copytruncate
}