mirror of https://github.com/Icinga/icinga2.git
parent
0f9d76d40b
commit
076d297931
|
@ -149,9 +149,9 @@ void Application::SetResourceLimits(void)
|
||||||
rl.rlim_max = rl.rlim_cur;
|
rl.rlim_max = rl.rlim_cur;
|
||||||
|
|
||||||
if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
|
if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
|
||||||
Log(LogNotice, "base", "Could not adjust resource limit for open file handles (RLIMIT_NOFILE)");
|
Log(LogNotice, "Application", "Could not adjust resource limit for open file handles (RLIMIT_NOFILE)");
|
||||||
# else /* RLIMIT_NOFILE */
|
# else /* RLIMIT_NOFILE */
|
||||||
Log(LogNotice, "base", "System does not support adjusting the resource limit for open file handles (RLIMIT_NOFILE)");
|
Log(LogNotice, "Application", "System does not support adjusting the resource limit for open file handles (RLIMIT_NOFILE)");
|
||||||
# endif /* RLIMIT_NOFILE */
|
# endif /* RLIMIT_NOFILE */
|
||||||
|
|
||||||
# ifdef RLIMIT_NPROC
|
# ifdef RLIMIT_NPROC
|
||||||
|
@ -159,9 +159,9 @@ void Application::SetResourceLimits(void)
|
||||||
rl.rlim_max = rl.rlim_cur;
|
rl.rlim_max = rl.rlim_cur;
|
||||||
|
|
||||||
if (setrlimit(RLIMIT_NPROC, &rl) < 0)
|
if (setrlimit(RLIMIT_NPROC, &rl) < 0)
|
||||||
Log(LogNotice, "base", "Could not adjust resource limit for number of processes (RLIMIT_NPROC)");
|
Log(LogNotice, "Application", "Could not adjust resource limit for number of processes (RLIMIT_NPROC)");
|
||||||
# else /* RLIMIT_NPROC */
|
# else /* RLIMIT_NPROC */
|
||||||
Log(LogNotice, "base", "System does not support adjusting the resource limit for number of processes (RLIMIT_NPROC)");
|
Log(LogNotice, "Application", "System does not support adjusting the resource limit for number of processes (RLIMIT_NPROC)");
|
||||||
# endif /* RLIMIT_NPROC */
|
# endif /* RLIMIT_NPROC */
|
||||||
|
|
||||||
# ifdef RLIMIT_STACK
|
# ifdef RLIMIT_STACK
|
||||||
|
@ -181,7 +181,7 @@ void Application::SetResourceLimits(void)
|
||||||
rl.rlim_max = rl.rlim_cur;
|
rl.rlim_max = rl.rlim_cur;
|
||||||
|
|
||||||
if (setrlimit(RLIMIT_STACK, &rl) < 0)
|
if (setrlimit(RLIMIT_STACK, &rl) < 0)
|
||||||
Log(LogNotice, "base", "Could not adjust resource limit for stack size (RLIMIT_STACK)");
|
Log(LogNotice, "Application", "Could not adjust resource limit for stack size (RLIMIT_STACK)");
|
||||||
else {
|
else {
|
||||||
char **new_argv = static_cast<char **>(malloc(sizeof(char *) * (argc + 2)));
|
char **new_argv = static_cast<char **>(malloc(sizeof(char *) * (argc + 2)));
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ void Application::SetResourceLimits(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# else /* RLIMIT_STACK */
|
# else /* RLIMIT_STACK */
|
||||||
Log(LogNotice, "base", "System does not support adjusting the resource limit for stack size (RLIMIT_STACK)");
|
Log(LogNotice, "Application", "System does not support adjusting the resource limit for stack size (RLIMIT_STACK)");
|
||||||
# endif /* RLIMIT_STACK */
|
# endif /* RLIMIT_STACK */
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ mainloop:
|
||||||
Utility::Sleep(2.5);
|
Utility::Sleep(2.5);
|
||||||
|
|
||||||
if (m_RequestReopenLogs) {
|
if (m_RequestReopenLogs) {
|
||||||
Log(LogNotice, "base", "Reopening log files");
|
Log(LogNotice, "Application", "Reopening log files");
|
||||||
m_RequestReopenLogs = false;
|
m_RequestReopenLogs = false;
|
||||||
OnReopenLogs();
|
OnReopenLogs();
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ mainloop:
|
||||||
msgbuf << "We jumped "
|
msgbuf << "We jumped "
|
||||||
<< (timeDiff < 0 ? "forward" : "backward")
|
<< (timeDiff < 0 ? "forward" : "backward")
|
||||||
<< " in time: " << abs(timeDiff) << " seconds";
|
<< " in time: " << abs(timeDiff) << " seconds";
|
||||||
Log(LogInformation, "base", msgbuf.str());
|
Log(LogInformation, "Application", msgbuf.str());
|
||||||
|
|
||||||
Timer::AdjustTimers(-timeDiff);
|
Timer::AdjustTimers(-timeDiff);
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ mainloop:
|
||||||
goto mainloop;
|
goto mainloop;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogInformation, "base", "Shutting down Icinga...");
|
Log(LogInformation, "Application", "Shutting down Icinga...");
|
||||||
DynamicObject::StopObjects();
|
DynamicObject::StopObjects();
|
||||||
Application::GetInstance()->OnShutdown();
|
Application::GetInstance()->OnShutdown();
|
||||||
|
|
||||||
|
@ -307,13 +307,13 @@ void Application::OnShutdown(void)
|
||||||
static void ReloadProcessCallback(const ProcessResult& pr)
|
static void ReloadProcessCallback(const ProcessResult& pr)
|
||||||
{
|
{
|
||||||
if (pr.ExitStatus != 0)
|
if (pr.ExitStatus != 0)
|
||||||
Log(LogCritical, "base", "Found error in config: reloading aborted");
|
Log(LogCritical, "Application", "Found error in config: reloading aborted");
|
||||||
l_Restarting = false;
|
l_Restarting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t Application::StartReloadProcess(void)
|
pid_t Application::StartReloadProcess(void)
|
||||||
{
|
{
|
||||||
Log(LogInformation, "base", "Got reload command: Starting new instance.");
|
Log(LogInformation, "Application", "Got reload command: Starting new instance.");
|
||||||
|
|
||||||
// prepare arguments
|
// prepare arguments
|
||||||
Array::Ptr args = make_shared<Array>();
|
Array::Ptr args = make_shared<Array>();
|
||||||
|
@ -683,7 +683,7 @@ void Application::UpdatePidFile(const String& filename, pid_t pid)
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
|
|
||||||
if (fcntl(fd, F_SETLK, &lock) < 0) {
|
if (fcntl(fd, F_SETLK, &lock) < 0) {
|
||||||
Log(LogCritical, "base", "Could not lock PID file. Make sure that only one instance of the application is running.");
|
Log(LogCritical, "Application", "Could not lock PID file. Make sure that only one instance of the application is running.");
|
||||||
|
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ Value DynamicObject::InvokeMethod(const String& method,
|
||||||
|
|
||||||
void DynamicObject::DumpObjects(const String& filename, int attributeTypes)
|
void DynamicObject::DumpObjects(const String& filename, int attributeTypes)
|
||||||
{
|
{
|
||||||
Log(LogInformation, "base", "Dumping program state to file '" + filename + "'");
|
Log(LogInformation, "DynamicObject", "Dumping program state to file '" + filename + "'");
|
||||||
|
|
||||||
String tempFilename = filename + ".tmp";
|
String tempFilename = filename + ".tmp";
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes)
|
||||||
|
|
||||||
ASSERT(!object->IsActive());
|
ASSERT(!object->IsActive());
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Log(LogDebug, "base", "Restoring object '" + name + "' of type '" + type + "'.");
|
Log(LogDebug, "DynamicObject", "Restoring object '" + name + "' of type '" + type + "'.");
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
Dictionary::Ptr update = persistentObject->Get("update");
|
Dictionary::Ptr update = persistentObject->Get("update");
|
||||||
Deserialize(object, update, false, attributeTypes);
|
Deserialize(object, update, false, attributeTypes);
|
||||||
|
@ -306,7 +306,7 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes)
|
||||||
|
|
||||||
void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
|
void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
|
||||||
{
|
{
|
||||||
Log(LogInformation, "base", "Restoring program state from file '" + filename + "'");
|
Log(LogInformation, "DynamicObject", "Restoring program state from file '" + filename + "'");
|
||||||
|
|
||||||
std::fstream fp;
|
std::fstream fp;
|
||||||
fp.open(filename.CStr(), std::ios_base::in);
|
fp.open(filename.CStr(), std::ios_base::in);
|
||||||
|
@ -329,7 +329,7 @@ void DynamicObject::RestoreObjects(const String& filename, int attributeTypes)
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "Restored " << restored << " objects";
|
msgbuf << "Restored " << restored << " objects";
|
||||||
Log(LogInformation, "base", msgbuf.str());
|
Log(LogInformation, "DynamicObject", msgbuf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicObject::StopObjects(void)
|
void DynamicObject::StopObjects(void)
|
||||||
|
|
|
@ -426,7 +426,7 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
|
||||||
m_FD = outReadPipe;
|
m_FD = outReadPipe;
|
||||||
m_PID = pi.dwProcessId;
|
m_PID = pi.dwProcessId;
|
||||||
|
|
||||||
Log(LogNotice, "base", "Running command '" + m_Arguments +
|
Log(LogNotice, "Process", "Running command '" + m_Arguments +
|
||||||
"': PID " + Convert::ToString(m_PID));
|
"': PID " + Convert::ToString(m_PID));
|
||||||
|
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
@ -531,7 +531,7 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
|
||||||
|
|
||||||
m_PID = m_Process;
|
m_PID = m_Process;
|
||||||
|
|
||||||
Log(LogNotice, "base", "Running command '" + boost::algorithm::join(m_Arguments, "', '") +
|
Log(LogNotice, "Process", "Running command '" + boost::algorithm::join(m_Arguments, "', '") +
|
||||||
"': PID " + Convert::ToString(m_PID));
|
"': PID " + Convert::ToString(m_PID));
|
||||||
|
|
||||||
m_Arguments.clear();
|
m_Arguments.clear();
|
||||||
|
@ -582,7 +582,7 @@ bool Process::DoEvents(void)
|
||||||
double timeout = m_Result.ExecutionStart + m_Timeout;
|
double timeout = m_Result.ExecutionStart + m_Timeout;
|
||||||
|
|
||||||
if (timeout < Utility::GetTime()) {
|
if (timeout < Utility::GetTime()) {
|
||||||
Log(LogNotice, "base", "Killing process '" + Convert::ToString(m_PID) + " after timeout of " + Convert::ToString(m_Timeout) + " seconds");
|
Log(LogNotice, "Process", "Killing process '" + Convert::ToString(m_PID) + " after timeout of " + Convert::ToString(m_Timeout) + " seconds");
|
||||||
|
|
||||||
m_OutputStream << "<Timeout exceeded.>";
|
m_OutputStream << "<Timeout exceeded.>";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -630,7 +630,7 @@ bool Process::DoEvents(void)
|
||||||
DWORD exitcode;
|
DWORD exitcode;
|
||||||
GetExitCodeProcess(m_Process, &exitcode);
|
GetExitCodeProcess(m_Process, &exitcode);
|
||||||
|
|
||||||
Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode));
|
Log(LogNotice, "Process", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode));
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
int status, exitcode;
|
int status, exitcode;
|
||||||
if (waitpid(m_Process, &status, 0) != m_Process) {
|
if (waitpid(m_Process, &status, 0) != m_Process) {
|
||||||
|
@ -642,9 +642,9 @@ bool Process::DoEvents(void)
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
exitcode = WEXITSTATUS(status);
|
exitcode = WEXITSTATUS(status);
|
||||||
|
|
||||||
Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode));
|
Log(LogNotice, "Process", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode));
|
||||||
} else if (WIFSIGNALED(status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " was terminated by signal " + Convert::ToString(WTERMSIG(status)));
|
Log(LogNotice, "Process", "PID " + Convert::ToString(m_PID) + " was terminated by signal " + Convert::ToString(WTERMSIG(status)));
|
||||||
|
|
||||||
std::ostringstream outputbuf;
|
std::ostringstream outputbuf;
|
||||||
outputbuf << "<Terminated by signal " << WTERMSIG(status) << ".>";
|
outputbuf << "<Terminated by signal " << WTERMSIG(status) << ".>";
|
||||||
|
|
|
@ -136,9 +136,9 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
|
||||||
msgbuf << "Exception thrown in event handler: " << std::endl
|
msgbuf << "Exception thrown in event handler: " << std::endl
|
||||||
<< DiagnosticInformation(ex);
|
<< DiagnosticInformation(ex);
|
||||||
|
|
||||||
Log(LogCritical, "base", msgbuf.str());
|
Log(LogCritical, "ThreadPool", msgbuf.str());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Log(LogCritical, "base", "Exception of unknown type thrown in event handler.");
|
Log(LogCritical, "ThreadPool", "Exception of unknown type thrown in event handler.");
|
||||||
}
|
}
|
||||||
|
|
||||||
double et = Utility::GetTime();
|
double et = Utility::GetTime();
|
||||||
|
@ -178,7 +178,7 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
|
||||||
msgbuf << "Event call took " << (et - st) << "s";
|
msgbuf << "Event call took " << (et - st) << "s";
|
||||||
# endif /* RUSAGE_THREAD */
|
# endif /* RUSAGE_THREAD */
|
||||||
|
|
||||||
Log(LogWarning, "base", msgbuf.str());
|
Log(LogWarning, "ThreadPool", msgbuf.str());
|
||||||
}
|
}
|
||||||
#endif /* _DEBUG */
|
#endif /* _DEBUG */
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ void ThreadPool::ManagerThreadProc(void)
|
||||||
if (tthreads != 0) {
|
if (tthreads != 0) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "Thread pool; current: " << alive << "; adjustment: " << tthreads;
|
msgbuf << "Thread pool; current: " << alive << "; adjustment: " << tthreads;
|
||||||
Log(LogNotice, "base", msgbuf.str());
|
Log(LogNotice, "ThreadPool", msgbuf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < -tthreads; i++)
|
for (int i = 0; i < -tthreads; i++)
|
||||||
|
@ -319,7 +319,7 @@ void ThreadPool::ManagerThreadProc(void)
|
||||||
<< (long)(total_avg_latency * 1000 / (sizeof(m_Queues) / sizeof(m_Queues[0]))) << "ms"
|
<< (long)(total_avg_latency * 1000 / (sizeof(m_Queues) / sizeof(m_Queues[0]))) << "ms"
|
||||||
<< "; Threads: " << total_alive
|
<< "; Threads: " << total_alive
|
||||||
<< "; Pool utilization: " << (total_utilization / (sizeof(m_Queues) / sizeof(m_Queues[0]))) << "%";
|
<< "; Pool utilization: " << (total_utilization / (sizeof(m_Queues) / sizeof(m_Queues[0]))) << "%";
|
||||||
Log(LogNotice, "base", msgbuf.str());
|
Log(LogNotice, "ThreadPool", msgbuf.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ void ThreadPool::Queue::SpawnWorker(boost::thread_group& group)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < sizeof(Threads) / sizeof(Threads[0]); i++) {
|
for (size_t i = 0; i < sizeof(Threads) / sizeof(Threads[0]); i++) {
|
||||||
if (Threads[i].State == ThreadDead) {
|
if (Threads[i].State == ThreadDead) {
|
||||||
Log(LogDebug, "base", "Spawning worker thread.");
|
Log(LogDebug, "ThreadPool", "Spawning worker thread.");
|
||||||
|
|
||||||
Threads[i] = WorkerThread(ThreadIdle);
|
Threads[i] = WorkerThread(ThreadIdle);
|
||||||
Threads[i].Thread = group.create_thread(boost::bind(&ThreadPool::WorkerThread::ThreadProc, boost::ref(Threads[i]), boost::ref(*this)));
|
Threads[i].Thread = group.create_thread(boost::bind(&ThreadPool::WorkerThread::ThreadProc, boost::ref(Threads[i]), boost::ref(*this)));
|
||||||
|
@ -348,7 +348,7 @@ void ThreadPool::Queue::KillWorker(boost::thread_group& group)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < sizeof(Threads) / sizeof(Threads[0]); i++) {
|
for (size_t i = 0; i < sizeof(Threads) / sizeof(Threads[0]); i++) {
|
||||||
if (Threads[i].State == ThreadIdle && !Threads[i].Zombie) {
|
if (Threads[i].State == ThreadIdle && !Threads[i].Zombie) {
|
||||||
Log(LogDebug, "base", "Killing worker thread.");
|
Log(LogDebug, "ThreadPool", "Killing worker thread.");
|
||||||
|
|
||||||
group.remove_thread(Threads[i].Thread);
|
group.remove_thread(Threads[i].Thread);
|
||||||
Threads[i].Thread->detach();
|
Threads[i].Thread->detach();
|
||||||
|
|
|
@ -368,7 +368,7 @@ Utility::LoadExtensionLibrary(const String& library)
|
||||||
path = "lib" + library + ".so";
|
path = "lib" + library + ".so";
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
Log(LogInformation, "base", "Loading library '" + path + "'");
|
Log(LogInformation, "Utility", "Loading library '" + path + "'");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HMODULE hModule = LoadLibrary(path.CStr());
|
HMODULE hModule = LoadLibrary(path.CStr());
|
||||||
|
|
|
@ -124,7 +124,7 @@ void WorkQueue::StatusTimerHandler(void)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
|
|
||||||
Log(LogNotice, "base", "WQ #" + Convert::ToString(m_ID) + " items: " + Convert::ToString(m_Items.size()));
|
Log(LogNotice, "WorkQueue", "#" + Convert::ToString(m_ID) + " items: " + Convert::ToString(m_Items.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkQueue::WorkerThreadProc(void)
|
void WorkQueue::WorkerThreadProc(void)
|
||||||
|
|
Loading…
Reference in New Issue