Merge branch 'feature/log-trunc-rotate-5448' into next

Fixes #5448
This commit is contained in:
Michael Friedrich 2014-01-14 17:43:18 +01:00
commit 51aa2d7f43
4 changed files with 42 additions and 1 deletions

View File

@ -44,6 +44,7 @@ install_if_not_exists(icinga2/features-available/perfdata.conf ${CMAKE_INSTALL_S
install_if_not_exists(icinga2/features-available/statusdata.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/scripts/mail-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
install_if_not_exists(logrotate.d/icinga2 ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")

39
etc/logrotate.d/icinga2 Normal file
View File

@ -0,0 +1,39 @@
# ----- logrotate config -------------
/var/log/icinga2/icinga2.log {
daily
rotate 90
compress
delaycompress
missingok
notifempty
create 644 icinga icinga
copytruncate
#postrotate
# if /etc/init.d/icinga2 status > /dev/null ; then \
# /etc/init.d/icinga2 reload > /dev/null; \
# fi;
#endscript
}
/var/log/icinga2/error.log {
daily
rotate 90
compress
delaycompress
missingok
notifempty
create 644 icinga icinga
copytruncate
}
/var/log/icinga2/debug.log {
hourly
rotate 90
compress
delaycompress
missingok
notifempty
create 644 icinga icinga
copytruncate
}

View File

@ -418,6 +418,7 @@ exit 0
%files common
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
%attr(755,-,-) %{_sysconfdir}/logrotate.d/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp

View File

@ -37,7 +37,7 @@ void FileLogger::Start()
String path = GetPath();
try {
stream->open(path.CStr(), std::fstream::out | std::fstream::trunc);
stream->open(path.CStr(), std::fstream::app | std::fstream::out);
if (!stream->good())
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open logfile '" + path + "'"));