mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
parent
fceeeba05e
commit
2350593ef0
1
debian/icinga2-common.install
vendored
1
debian/icinga2-common.install
vendored
@ -2,6 +2,7 @@ debian/tmp/etc/icinga2
|
|||||||
debian/config/apt.conf etc/icinga2/conf.d/hosts/localhost
|
debian/config/apt.conf etc/icinga2/conf.d/hosts/localhost
|
||||||
debian/config/kernel.conf etc/icinga2/conf.d/hosts/localhost
|
debian/config/kernel.conf etc/icinga2/conf.d/hosts/localhost
|
||||||
debian/config/check_kernel etc/sudoers.d
|
debian/config/check_kernel etc/sudoers.d
|
||||||
|
etc/logrotate.d
|
||||||
usr/bin/icinga2-build*
|
usr/bin/icinga2-build*
|
||||||
usr/bin/icinga2-sign-key
|
usr/bin/icinga2-sign-key
|
||||||
usr/sbin/icinga2-*-feature
|
usr/sbin/icinga2-*-feature
|
||||||
|
@ -8,11 +8,27 @@
|
|||||||
notifempty
|
notifempty
|
||||||
create 644 icinga icinga
|
create 644 icinga icinga
|
||||||
copytruncate
|
copytruncate
|
||||||
#postrotate
|
postrotate
|
||||||
# if /etc/init.d/icinga2 status > /dev/null ; then \
|
if ! killall -q -USR1 icinga2; then
|
||||||
# /etc/init.d/icinga2 reload > /dev/null; \
|
exit 1
|
||||||
# fi;
|
fi
|
||||||
#endscript
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
/var/log/icinga2/debug.log {
|
||||||
|
hourly
|
||||||
|
rotate 90
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
create 644 icinga icinga
|
||||||
|
copytruncate
|
||||||
|
postrotate
|
||||||
|
if ! killall -q -USR1 icinga2; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
endscript
|
||||||
}
|
}
|
||||||
|
|
||||||
/var/log/icinga2/error.log {
|
/var/log/icinga2/error.log {
|
||||||
@ -26,14 +42,3 @@
|
|||||||
copytruncate
|
copytruncate
|
||||||
}
|
}
|
||||||
|
|
||||||
/var/log/icinga2/debug.log {
|
|
||||||
hourly
|
|
||||||
rotate 90
|
|
||||||
compress
|
|
||||||
delaycompress
|
|
||||||
missingok
|
|
||||||
notifempty
|
|
||||||
create 644 icinga icinga
|
|
||||||
copytruncate
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -43,9 +43,11 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_TYPE(Application);
|
REGISTER_TYPE(Application);
|
||||||
|
|
||||||
|
boost::signals2::signal<void (void)> Application::OnReopenLogs;
|
||||||
Application *Application::m_Instance = NULL;
|
Application *Application::m_Instance = NULL;
|
||||||
bool Application::m_ShuttingDown = false;
|
bool Application::m_ShuttingDown = false;
|
||||||
bool Application::m_RequestRestart = false;
|
bool Application::m_RequestRestart = false;
|
||||||
|
bool Application::m_RequestReopenLogs = false;
|
||||||
pid_t Application::m_ReloadProcess = 0;
|
pid_t Application::m_ReloadProcess = 0;
|
||||||
static bool l_Restarting = false;
|
static bool l_Restarting = false;
|
||||||
bool Application::m_Debugging = false;
|
bool Application::m_Debugging = false;
|
||||||
@ -238,6 +240,12 @@ mainloop:
|
|||||||
/* Watches for changes to the system time. Adjusts timers if necessary. */
|
/* Watches for changes to the system time. Adjusts timers if necessary. */
|
||||||
Utility::Sleep(2.5);
|
Utility::Sleep(2.5);
|
||||||
|
|
||||||
|
if (m_RequestReopenLogs) {
|
||||||
|
Log(LogInformation, "base", "Reopening log files");
|
||||||
|
m_RequestReopenLogs = false;
|
||||||
|
OnReopenLogs();
|
||||||
|
}
|
||||||
|
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
double timeDiff = lastLoop - now;
|
double timeDiff = lastLoop - now;
|
||||||
|
|
||||||
@ -336,6 +344,15 @@ void Application::RequestRestart(void)
|
|||||||
m_RequestRestart = true;
|
m_RequestRestart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signals the application to reopen log files during the
|
||||||
|
* next execution of the event loop.
|
||||||
|
*/
|
||||||
|
void Application::RequestReopenLogs(void)
|
||||||
|
{
|
||||||
|
m_RequestReopenLogs = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the full path of the executable.
|
* Retrieves the full path of the executable.
|
||||||
*
|
*
|
||||||
@ -484,6 +501,17 @@ void Application::SigIntTermHandler(int signum)
|
|||||||
instance->RequestShutdown();
|
instance->RequestShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal handler for SIGUSR1. This signal causes Icinga to re-open
|
||||||
|
* its log files and is mainly for use by logrotate.
|
||||||
|
*
|
||||||
|
* @param - The signal number.
|
||||||
|
*/
|
||||||
|
void Application::SigUsr1Handler(int)
|
||||||
|
{
|
||||||
|
RequestReopenLogs();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal handler for SIGABRT. Helps with debugging ASSERT()s.
|
* Signal handler for SIGABRT. Helps with debugging ASSERT()s.
|
||||||
*
|
*
|
||||||
@ -614,6 +642,9 @@ int Application::Run(void)
|
|||||||
|
|
||||||
sa.sa_handler = SIG_IGN;
|
sa.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGPIPE, &sa, NULL);
|
sigaction(SIGPIPE, &sa, NULL);
|
||||||
|
|
||||||
|
sa.sa_handler = &Application::SigUsr1Handler;
|
||||||
|
sigaction(SIGUSR1, &sa, NULL);
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
|
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
@ -37,6 +37,8 @@ class I2_BASE_API Application : public ObjectImpl<Application> {
|
|||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(Application);
|
DECLARE_PTR_TYPEDEFS(Application);
|
||||||
|
|
||||||
|
static boost::signals2::signal<void (void)> OnReopenLogs;
|
||||||
|
|
||||||
~Application(void);
|
~Application(void);
|
||||||
|
|
||||||
static void InitializeBase(void);
|
static void InitializeBase(void);
|
||||||
@ -64,6 +66,7 @@ public:
|
|||||||
|
|
||||||
static void RequestShutdown(void);
|
static void RequestShutdown(void);
|
||||||
static void RequestRestart(void);
|
static void RequestRestart(void);
|
||||||
|
static void RequestReopenLogs(void);
|
||||||
|
|
||||||
static void SetDebugging(bool debug);
|
static void SetDebugging(bool debug);
|
||||||
static bool IsDebugging(void);
|
static bool IsDebugging(void);
|
||||||
@ -128,6 +131,7 @@ private:
|
|||||||
static bool m_RequestRestart; /**< A restart was requested through SIGHUP */
|
static bool m_RequestRestart; /**< A restart was requested through SIGHUP */
|
||||||
static pid_t m_ReloadProcess; /**< The PID of a subprocess doing a reload,
|
static pid_t m_ReloadProcess; /**< The PID of a subprocess doing a reload,
|
||||||
only valid when l_Restarting==true */
|
only valid when l_Restarting==true */
|
||||||
|
static bool m_RequestReopenLogs; /**< Whether we should re-open log files. */
|
||||||
|
|
||||||
static int m_ArgC; /**< The number of command-line arguments. */
|
static int m_ArgC; /**< The number of command-line arguments. */
|
||||||
static char **m_ArgV; /**< Command-line arguments. */
|
static char **m_ArgV; /**< Command-line arguments. */
|
||||||
@ -146,6 +150,7 @@ private:
|
|||||||
static void DisplayBugMessage(void);
|
static void DisplayBugMessage(void);
|
||||||
|
|
||||||
static void SigAbrtHandler(int signum);
|
static void SigAbrtHandler(int signum);
|
||||||
|
static void SigUsr1Handler(int signum);
|
||||||
static void ExceptionHandler(void);
|
static void ExceptionHandler(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "base/filelogger.h"
|
#include "base/filelogger.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/statsfunction.h"
|
#include "base/statsfunction.h"
|
||||||
|
#include "base/application.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
@ -44,10 +45,17 @@ Value FileLogger::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr&)
|
|||||||
/**
|
/**
|
||||||
* Constructor for the FileLogger class.
|
* Constructor for the FileLogger class.
|
||||||
*/
|
*/
|
||||||
void FileLogger::Start()
|
void FileLogger::Start(void)
|
||||||
{
|
{
|
||||||
StreamLogger::Start();
|
StreamLogger::Start();
|
||||||
|
|
||||||
|
ReopenLogFile();
|
||||||
|
|
||||||
|
Application::OnReopenLogs.connect(boost::bind(&FileLogger::ReopenLogFile, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileLogger::ReopenLogFile(void)
|
||||||
|
{
|
||||||
std::ofstream *stream = new std::ofstream();
|
std::ofstream *stream = new std::ofstream();
|
||||||
|
|
||||||
String path = GetPath();
|
String path = GetPath();
|
||||||
|
@ -40,6 +40,9 @@ public:
|
|||||||
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
||||||
|
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ReopenLogFile(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,9 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
|
|||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
|
if (m_OwnsStream)
|
||||||
|
delete m_Stream;
|
||||||
|
|
||||||
m_Stream = stream;
|
m_Stream = stream;
|
||||||
m_OwnsStream = ownsStream;
|
m_OwnsStream = ownsStream;
|
||||||
m_Tty = IsTty(*stream);
|
m_Tty = IsTty(*stream);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user