mirror of https://github.com/Icinga/icinga2.git
Merge branch 'master' into mfriedrich/compatido
This commit is contained in:
commit
d0ed2a4840
|
@ -523,8 +523,8 @@ supported ("native::PluginCheck").
|
|||
Attribute: check_command
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Optional when not using check_type == "nagios". The check command. This command
|
||||
may use macros.
|
||||
Optional when not using the "external plugin" check type. The check command.
|
||||
This command may use macros.
|
||||
|
||||
Attribute: check_interval
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -731,9 +731,9 @@ local object Component "delegation" {
|
|||
|
||||
}
|
||||
|
||||
abstract object Service "nagios-service" {
|
||||
abstract object Service "icinga-service" {
|
||||
methods = {
|
||||
check = "native::NagiosCheck"
|
||||
check = "native::PluginCheck"
|
||||
},
|
||||
|
||||
macros = {
|
||||
|
@ -741,7 +741,7 @@ abstract object Service "nagios-service" {
|
|||
}
|
||||
}
|
||||
|
||||
abstract object Service "ping" inherits "nagios-service" {
|
||||
abstract object Service "ping" inherits "icinga-service" {
|
||||
check_command = "$plugindir$/check_ping -H $address$ -w $wrta$,$wpl$% -c $crta$,$cpl$%",
|
||||
|
||||
macros += {
|
||||
|
|
|
@ -55,7 +55,7 @@ local object Component "compatido" {
|
|||
* This template defines some basic parameters for services that use
|
||||
* external plugins for their checks.
|
||||
*/
|
||||
abstract object Service "nagios-service" {
|
||||
abstract object Service "icinga-service" {
|
||||
methods = {
|
||||
check = "native::PluginCheck"
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ abstract object Service "nagios-service" {
|
|||
* The service template for ping checks. In an Icinga 1.x environment
|
||||
* this would be defined as a check command.
|
||||
*/
|
||||
abstract object Service "ping" inherits "nagios-service" {
|
||||
abstract object Service "ping" inherits "icinga-service" {
|
||||
check_command = "$plugindir$/check_ping -H $address$ -w $wrta$,$wpl$% -c $crta$,$cpl$%",
|
||||
|
||||
macros += {
|
||||
|
|
|
@ -99,7 +99,9 @@ void Application::RunEventLoop(void)
|
|||
double nextProfile = 0;
|
||||
#endif /* _DEBUG */
|
||||
|
||||
double lastLoop = Utility::GetTime();
|
||||
/* Start the system time watch thread. */
|
||||
thread t(&Application::TimeWatchThreadProc);
|
||||
t.detach();
|
||||
|
||||
while (!m_ShuttingDown) {
|
||||
Object::ClearHeldObjects();
|
||||
|
@ -109,7 +111,7 @@ void Application::RunEventLoop(void)
|
|||
if (m_ShuttingDown)
|
||||
break;
|
||||
|
||||
Event::ProcessEvents(boost::get_system_time() + boost::posix_time::milliseconds(sleep * 1000));
|
||||
Event::ProcessEvents(boost::posix_time::milliseconds(sleep * 1000));
|
||||
|
||||
DynamicObject::FinishTx();
|
||||
DynamicObject::BeginTx();
|
||||
|
@ -125,17 +127,36 @@ void Application::RunEventLoop(void)
|
|||
nextProfile = Utility::GetTime() + 15.0;
|
||||
}
|
||||
#endif /* _DEBUG */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Watches for changes to the system time. Adjusts timers if necessary.
|
||||
*/
|
||||
void Application::TimeWatchThreadProc(void)
|
||||
{
|
||||
double lastLoop = Utility::GetTime();
|
||||
|
||||
for (;;) {
|
||||
Sleep(5);
|
||||
|
||||
double now = Utility::GetTime();
|
||||
double timeDiff = lastLoop - now;
|
||||
|
||||
if (now < lastLoop) {
|
||||
/* We moved backwards in time - cool. */
|
||||
double lostTime = lastLoop - now;
|
||||
if (abs(timeDiff) > 15) {
|
||||
/* We made a significant jump in time. */
|
||||
stringstream msgbuf;
|
||||
msgbuf << "We moved backwards in time: " << lostTime
|
||||
<< " seconds";
|
||||
msgbuf << "We jumped "
|
||||
<< (timeDiff < 0 ? "forwards" : "backwards")
|
||||
<< " in time: " << abs(timeDiff) << " seconds";
|
||||
Logger::Write(LogInformation, "base", msgbuf.str());
|
||||
Timer::AdjustTimers(-lostTime);
|
||||
|
||||
/* in addition to rescheduling the timers this
|
||||
* causes the event loop to wake up thereby
|
||||
* solving the problem that timed_wait()
|
||||
* uses an absolute timestamp for the timeout */
|
||||
Event::Post(boost::bind(&Timer::AdjustTimers,
|
||||
-timeDiff));
|
||||
}
|
||||
|
||||
lastLoop = now;
|
||||
|
|
|
@ -79,6 +79,8 @@ private:
|
|||
#else /* _WIN32 */
|
||||
static BOOL WINAPI CtrlHandler(DWORD type);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static void TimeWatchThreadProc(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,9 +38,9 @@ Event::Event(const Event::Callback& callback)
|
|||
* Waits for events using the specified timeout value and processes
|
||||
* them.
|
||||
*
|
||||
* @param wait_until The wait timeout.
|
||||
* @param timeout The wait timeout.
|
||||
*/
|
||||
void Event::ProcessEvents(const system_time& wait_until)
|
||||
void Event::ProcessEvents(millisec timeout)
|
||||
{
|
||||
vector<Event> events;
|
||||
|
||||
|
@ -50,7 +50,7 @@ void Event::ProcessEvents(const system_time& wait_until)
|
|||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
while (m_Events.empty()) {
|
||||
if (!m_EventAvailable.timed_wait(lock, wait_until))
|
||||
if (!m_EventAvailable.timed_wait(lock, timeout))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class I2_BASE_API Event
|
|||
public:
|
||||
typedef function<void ()> Callback;
|
||||
|
||||
static void ProcessEvents(const system_time& wait_until);
|
||||
static void ProcessEvents(millisec timeout);
|
||||
static void Post(const Callback& callback);
|
||||
|
||||
private:
|
||||
|
|
|
@ -139,6 +139,7 @@ using boost::thread;
|
|||
using boost::thread_group;
|
||||
using boost::condition_variable;
|
||||
using boost::system_time;
|
||||
using boost::posix_time::millisec;
|
||||
using boost::tie;
|
||||
using boost::throw_exception;
|
||||
using boost::rethrow_exception;
|
||||
|
|
|
@ -37,7 +37,7 @@ Timer::Timer(void)
|
|||
*/
|
||||
double Timer::ProcessTimers(void)
|
||||
{
|
||||
double wakeup = 30;
|
||||
double wakeup = 30; /* wake up at least once after this many seconds */
|
||||
|
||||
double st = Utility::GetTime();
|
||||
|
||||
|
@ -164,7 +164,14 @@ void Timer::Reschedule(double next)
|
|||
*/
|
||||
void Timer::AdjustTimers(double adjustment)
|
||||
{
|
||||
BOOST_FOREACH(Timer::Ptr timer, m_Timers) {
|
||||
timer->m_Next += adjustment;
|
||||
double now = Utility::GetTime();
|
||||
|
||||
Timer::CollectionType::iterator i;
|
||||
for (i = m_Timers.begin(); i != m_Timers.end(); i++) {
|
||||
Timer::Ptr timer = i->lock();
|
||||
|
||||
if (abs(now - (timer->m_Next + adjustment)) <
|
||||
abs(now - timer->m_Next))
|
||||
timer->m_Next += adjustment;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue