mirror of https://github.com/Icinga/icinga2.git
parent
6c23481a55
commit
29b056c848
|
@ -171,21 +171,11 @@ void CompatComponent::ProcessCommand(const String& command)
|
|||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
void CompatComponent::DumpComments(ofstream& fp, const DynamicObject::Ptr& owner)
|
||||
void CompatComponent::DumpComments(ofstream& fp, const Service::Ptr& owner, CompatObjectType type)
|
||||
{
|
||||
Service::Ptr service;
|
||||
Host::Ptr host;
|
||||
Dictionary::Ptr comments;
|
||||
|
||||
if (owner->GetType() == DynamicType::GetByName("Service")) {
|
||||
service = dynamic_pointer_cast<Service>(owner);
|
||||
comments = service->GetComments();
|
||||
|
||||
host = service->GetHost();
|
||||
} else {
|
||||
host = dynamic_pointer_cast<Host>(owner);
|
||||
comments = host->GetComments();
|
||||
}
|
||||
Dictionary::Ptr comments = owner->GetComments();
|
||||
|
||||
if (!comments)
|
||||
return;
|
||||
|
@ -193,16 +183,16 @@ void CompatComponent::DumpComments(ofstream& fp, const DynamicObject::Ptr& owner
|
|||
String id;
|
||||
Dictionary::Ptr comment;
|
||||
BOOST_FOREACH(tie(id, comment), comments) {
|
||||
if (CommentProcessor::IsCommentExpired(comment))
|
||||
if (Service::IsCommentExpired(comment))
|
||||
continue;
|
||||
|
||||
if (!service)
|
||||
if (type == CompatTypeHost)
|
||||
fp << "hostcomment {" << "\n";
|
||||
else
|
||||
fp << "servicecomment {" << "\n"
|
||||
<< "\t" << "service_description=" << service->GetShortName() << "\n";
|
||||
<< "\t" << "service_description=" << owner->GetShortName() << "\n";
|
||||
|
||||
fp << "\t" << "host_name=" << host->GetName() << "\n"
|
||||
fp << "\t" << "host_name=" << owner->GetHost()->GetName() << "\n"
|
||||
<< "\t" << "comment_id=" << static_cast<String>(comment->Get("legacy_id")) << "\n"
|
||||
<< "\t" << "entry_time=" << static_cast<double>(comment->Get("entry_time")) << "\n"
|
||||
<< "\t" << "entry_type=" << static_cast<long>(comment->Get("entry_type")) << "\n"
|
||||
|
@ -216,21 +206,9 @@ void CompatComponent::DumpComments(ofstream& fp, const DynamicObject::Ptr& owner
|
|||
}
|
||||
}
|
||||
|
||||
void CompatComponent::DumpDowntimes(ofstream& fp, const DynamicObject::Ptr& owner)
|
||||
void CompatComponent::DumpDowntimes(ofstream& fp, const Service::Ptr& owner, CompatObjectType type)
|
||||
{
|
||||
Service::Ptr service;
|
||||
Host::Ptr host;
|
||||
Dictionary::Ptr downtimes;
|
||||
|
||||
if (owner->GetType() == DynamicType::GetByName("Service")) {
|
||||
service = dynamic_pointer_cast<Service>(owner);
|
||||
downtimes = service->GetDowntimes();
|
||||
|
||||
host = service->GetHost();
|
||||
} else {
|
||||
host = dynamic_pointer_cast<Host>(owner);
|
||||
downtimes = host->GetDowntimes();
|
||||
}
|
||||
Dictionary::Ptr downtimes = owner->GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
@ -238,21 +216,21 @@ void CompatComponent::DumpDowntimes(ofstream& fp, const DynamicObject::Ptr& owne
|
|||
String id;
|
||||
Dictionary::Ptr downtime;
|
||||
BOOST_FOREACH(tie(id, downtime), downtimes) {
|
||||
if (DowntimeProcessor::IsDowntimeExpired(downtime))
|
||||
if (Service::IsDowntimeExpired(downtime))
|
||||
continue;
|
||||
|
||||
if (!service)
|
||||
if (type == CompatTypeHost)
|
||||
fp << "hostdowntime {" << "\n";
|
||||
else
|
||||
fp << "servicedowntime {" << "\n"
|
||||
<< "\t" << "service_description=" << service->GetShortName() << "\n";
|
||||
<< "\t" << "service_description=" << owner->GetShortName() << "\n";
|
||||
|
||||
Dictionary::Ptr triggeredByObj = DowntimeProcessor::GetDowntimeByID(downtime->Get("triggered_by"));
|
||||
Dictionary::Ptr triggeredByObj = Service::GetDowntimeByID(downtime->Get("triggered_by"));
|
||||
int triggeredByLegacy = 0;
|
||||
if (triggeredByObj)
|
||||
triggeredByLegacy = triggeredByObj->Get("legacy_id");
|
||||
|
||||
fp << "\t" << "host_name=" << host->GetName() << "\n"
|
||||
fp << "\t" << "host_name=" << owner->GetHost()->GetName() << "\n"
|
||||
<< "\t" << "downtime_id=" << static_cast<String>(downtime->Get("legacy_id")) << "\n"
|
||||
<< "\t" << "entry_time=" << static_cast<double>(downtime->Get("entry_time")) << "\n"
|
||||
<< "\t" << "start_time=" << static_cast<double>(downtime->Get("start_time")) << "\n"
|
||||
|
@ -260,7 +238,7 @@ void CompatComponent::DumpDowntimes(ofstream& fp, const DynamicObject::Ptr& owne
|
|||
<< "\t" << "triggered_by=" << triggeredByLegacy << "\n"
|
||||
<< "\t" << "fixed=" << static_cast<long>(downtime->Get("fixed")) << "\n"
|
||||
<< "\t" << "duration=" << static_cast<long>(downtime->Get("duration")) << "\n"
|
||||
<< "\t" << "is_in_effect=" << (DowntimeProcessor::IsDowntimeActive(downtime) ? 1 : 0) << "\n"
|
||||
<< "\t" << "is_in_effect=" << (Service::IsDowntimeActive(downtime) ? 1 : 0) << "\n"
|
||||
<< "\t" << "author=" << static_cast<String>(downtime->Get("author")) << "\n"
|
||||
<< "\t" << "comment=" << static_cast<String>(downtime->Get("comment")) << "\n"
|
||||
<< "\t" << "trigger_time=" << static_cast<double>(downtime->Get("trigger_time")) << "\n"
|
||||
|
@ -284,18 +262,17 @@ void CompatComponent::DumpHostStatus(ofstream& fp, const Host::Ptr& host)
|
|||
|
||||
Service::Ptr hostcheck = host->GetHostCheckService();
|
||||
|
||||
if (hostcheck)
|
||||
DumpServiceStatusAttrs(fp, hostcheck, CompatStateHost);
|
||||
if (hostcheck) {
|
||||
DumpServiceStatusAttrs(fp, hostcheck, CompatTypeHost);
|
||||
}
|
||||
|
||||
fp << "\t" << "problem_has_been_acknowledged=" << (host->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
||||
<< "\t" << "acknowledgement_type=" << static_cast<int>(host->GetAcknowledgement()) << "\n"
|
||||
<< "\t" << "acknowledgement_end_time=" << host->GetAcknowledgementExpiry() << "\n"
|
||||
<< "\t" << "scheduled_downtime_depth=" << (host->IsInDowntime() ? 1 : 0) << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
fp << "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
|
||||
DumpDowntimes(fp, host);
|
||||
DumpComments(fp, host);
|
||||
if (hostcheck) {
|
||||
DumpDowntimes(fp, hostcheck, CompatTypeHost);
|
||||
DumpComments(fp, hostcheck, CompatTypeHost);
|
||||
}
|
||||
}
|
||||
|
||||
void CompatComponent::DumpHostObject(ofstream& fp, const Host::Ptr& host)
|
||||
|
@ -321,7 +298,7 @@ void CompatComponent::DumpHostObject(ofstream& fp, const Host::Ptr& host)
|
|||
<< "\n";
|
||||
}
|
||||
|
||||
void CompatComponent::DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& service, CompatStateType type)
|
||||
void CompatComponent::DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& service, CompatObjectType type)
|
||||
{
|
||||
String output;
|
||||
String perfdata;
|
||||
|
@ -346,7 +323,7 @@ void CompatComponent::DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& s
|
|||
if (state > StateUnknown)
|
||||
state = StateUnknown;
|
||||
|
||||
if (type == CompatStateHost) {
|
||||
if (type == CompatTypeHost) {
|
||||
if (state == StateOK || state == StateWarning)
|
||||
state = 0;
|
||||
else
|
||||
|
@ -374,7 +351,11 @@ void CompatComponent::DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& s
|
|||
<< "\t" << "last_hard_state_change=" << service->GetLastHardStateChange() << "\n"
|
||||
<< "\t" << "last_update=" << time(NULL) << "\n"
|
||||
<< "\t" << "active_checks_enabled=" << (service->GetEnableActiveChecks() ? 1 : 0) <<"\n"
|
||||
<< "\t" << "passive_checks_enabled=" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n";
|
||||
<< "\t" << "passive_checks_enabled=" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
||||
<< "\t" << "problem_has_been_acknowledged=" << (service->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
||||
<< "\t" << "acknowledgement_type=" << static_cast<int>(service->GetAcknowledgement()) << "\n"
|
||||
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
|
||||
<< "\t" << "scheduled_downtime_depth=" << (service->IsInDowntime() ? 1 : 0) << "\n";
|
||||
}
|
||||
|
||||
void CompatComponent::DumpServiceStatus(ofstream& fp, const Service::Ptr& service)
|
||||
|
@ -383,17 +364,13 @@ void CompatComponent::DumpServiceStatus(ofstream& fp, const Service::Ptr& servic
|
|||
<< "\t" << "host_name=" << service->GetHost()->GetName() << "\n"
|
||||
<< "\t" << "service_description=" << service->GetShortName() << "\n";
|
||||
|
||||
DumpServiceStatusAttrs(fp, service, CompatStateService);
|
||||
DumpServiceStatusAttrs(fp, service, CompatTypeService);
|
||||
|
||||
fp << "\t" << "problem_has_been_acknowledged=" << (service->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
||||
<< "\t" << "acknowledgement_type=" << static_cast<int>(service->GetAcknowledgement()) << "\n"
|
||||
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
|
||||
<< "\t" << "scheduled_downtime_depth=" << (service->IsInDowntime() ? 1 : 0) << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
fp << "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
|
||||
DumpDowntimes(fp, service);
|
||||
DumpComments(fp, service);
|
||||
DumpDowntimes(fp, service, CompatTypeService);
|
||||
DumpComments(fp, service, CompatTypeService);
|
||||
}
|
||||
|
||||
void CompatComponent::DumpServiceObject(ofstream& fp, const Service::Ptr& service)
|
||||
|
@ -465,8 +442,8 @@ void CompatComponent::StatusTimerHandler(void)
|
|||
<< "\t" << "enable_failure_prediction=0" << "\n"
|
||||
<< "\t" << "active_scheduled_service_check_stats=" << CIB::GetActiveChecksStatistics(60) << "," << CIB::GetActiveChecksStatistics(5 * 60) << "," << CIB::GetActiveChecksStatistics(15 * 60) << "\n"
|
||||
<< "\t" << "passive_service_check_stats=" << CIB::GetPassiveChecksStatistics(60) << "," << CIB::GetPassiveChecksStatistics(5 * 60) << "," << CIB::GetPassiveChecksStatistics(15 * 60) << "\n"
|
||||
<< "\t" << "next_downtime_id=" << DowntimeProcessor::GetNextDowntimeID() << "\n"
|
||||
<< "\t" << "next_comment_id=" << CommentProcessor::GetNextCommentID() << "\n"
|
||||
<< "\t" << "next_downtime_id=" << Service::GetNextDowntimeID() << "\n"
|
||||
<< "\t" << "next_comment_id=" << Service::GetNextCommentID() << "\n"
|
||||
<< "\t" << "}" << "\n"
|
||||
<< "\n";
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
namespace icinga
|
||||
{
|
||||
|
||||
enum CompatStateType
|
||||
enum CompatObjectType
|
||||
{
|
||||
CompatStateService,
|
||||
CompatStateHost
|
||||
CompatTypeService,
|
||||
CompatTypeHost
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -53,12 +53,12 @@ private:
|
|||
String GetLogPath(void) const;
|
||||
String GetCommandPath(void) const;
|
||||
|
||||
void DumpDowntimes(ofstream& fp, const DynamicObject::Ptr& owner);
|
||||
void DumpComments(ofstream& fp, const DynamicObject::Ptr& owner);
|
||||
void DumpDowntimes(ofstream& fp, const Service::Ptr& owner, CompatObjectType type);
|
||||
void DumpComments(ofstream& fp, const Service::Ptr& owner, CompatObjectType type);
|
||||
void DumpHostStatus(ofstream& fp, const Host::Ptr& host);
|
||||
void DumpHostObject(ofstream& fp, const Host::Ptr& host);
|
||||
|
||||
void DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& service, CompatStateType type);
|
||||
void DumpServiceStatusAttrs(ofstream& fp, const Service::Ptr& service, CompatObjectType type);
|
||||
|
||||
template<typename T>
|
||||
void DumpNameList(ofstream& fp, const T& list)
|
||||
|
|
|
@ -5,15 +5,10 @@ pkglib_LTLIBRARIES = \
|
|||
libicinga.la
|
||||
|
||||
libicinga_la_SOURCES = \
|
||||
acknowledgement.h \
|
||||
checkresultmessage.cpp \
|
||||
checkresultmessage.h \
|
||||
cib.cpp \
|
||||
cib.h \
|
||||
commentprocessor.cpp \
|
||||
commentprocessor.h \
|
||||
downtimeprocessor.cpp \
|
||||
downtimeprocessor.h \
|
||||
externalcommandprocessor.cpp \
|
||||
externalcommandprocessor.h \
|
||||
host.cpp \
|
||||
|
@ -30,9 +25,11 @@ libicinga_la_SOURCES = \
|
|||
pluginchecktask.cpp \
|
||||
pluginchecktask.h \
|
||||
service.cpp \
|
||||
service-comment.cpp \
|
||||
service-downtime.cpp \
|
||||
service.h \
|
||||
servicegroup.cpp \
|
||||
servicegroup.h \
|
||||
service.h
|
||||
servicegroup.h
|
||||
|
||||
libicinga_la_CPPFLAGS = \
|
||||
-DI2_ICINGA_BUILD \
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ACKNOWLEDGEMENT_H
|
||||
#define ACKNOWLEDGEMENT_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* The acknowledgement type of a host/service.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
enum AcknowledgementType
|
||||
{
|
||||
AcknowledgementNone = 0,
|
||||
AcknowledgementNormal = 1,
|
||||
AcknowledgementSticky = 2
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ACKNOWLEDGEMENT_H */
|
|
@ -1,78 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef COMMENTPROCESSOR_H
|
||||
#define COMMENTPROCESSOR_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
enum CommentType
|
||||
{
|
||||
Comment_User = 1,
|
||||
Comment_Downtime = 2,
|
||||
Comment_Flapping = 3,
|
||||
Comment_Acknowledgement = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Comment processor.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API CommentProcessor
|
||||
{
|
||||
public:
|
||||
static int GetNextCommentID(void);
|
||||
|
||||
static String AddComment(const DynamicObject::Ptr& owner,
|
||||
CommentType entryType, const String& author, const String& text,
|
||||
double expireTime);
|
||||
|
||||
static void RemoveAllComments(const DynamicObject::Ptr& owner);
|
||||
static void RemoveComment(const String& id);
|
||||
|
||||
static String GetIDFromLegacyID(int id);
|
||||
static DynamicObject::Ptr GetOwnerByCommentID(const String& id);
|
||||
static Dictionary::Ptr GetCommentByID(const String& id);
|
||||
|
||||
static bool IsCommentExpired(const Dictionary::Ptr& comment);
|
||||
|
||||
static void InvalidateCommentCache(void);
|
||||
static void ValidateCommentCache(void);
|
||||
|
||||
private:
|
||||
static int m_NextCommentID;
|
||||
|
||||
static map<int, String> m_LegacyCommentCache;
|
||||
static map<String, DynamicObject::WeakPtr> m_CommentCache;
|
||||
static bool m_CommentCacheValid;
|
||||
static Timer::Ptr m_CommentExpireTimer;
|
||||
|
||||
CommentProcessor(void);
|
||||
|
||||
static void CommentExpireTimerHandler(void);
|
||||
|
||||
static void AddCommentsToCache(const DynamicObject::Ptr& owner);
|
||||
static void RemoveExpiredComments(const DynamicObject::Ptr& owner);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DOWNTIMEPROCESSOR_H */
|
|
@ -1,74 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Icinga 2 *
|
||||
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License *
|
||||
* as published by the Free Software Foundation; either version 2 *
|
||||
* of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the Free Software Foundation *
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DOWNTIMEPROCESSOR_H
|
||||
#define DOWNTIMEPROCESSOR_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
/**
|
||||
* Downtime processor.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
class I2_ICINGA_API DowntimeProcessor
|
||||
{
|
||||
public:
|
||||
static int GetNextDowntimeID(void);
|
||||
|
||||
static String AddDowntime(const DynamicObject::Ptr& owner,
|
||||
const String& author, const String& comment,
|
||||
double startTime, double endTime,
|
||||
bool fixed, const String& triggeredBy, double duration);
|
||||
|
||||
static void RemoveDowntime(const String& id);
|
||||
|
||||
static void TriggerDowntimes(const DynamicObject::Ptr& owner);
|
||||
static void TriggerDowntime(const String& id);
|
||||
|
||||
static String GetIDFromLegacyID(int id);
|
||||
static DynamicObject::Ptr GetOwnerByDowntimeID(const String& id);
|
||||
static Dictionary::Ptr GetDowntimeByID(const String& id);
|
||||
|
||||
static bool IsDowntimeActive(const Dictionary::Ptr& downtime);
|
||||
static bool IsDowntimeExpired(const Dictionary::Ptr& downtime);
|
||||
|
||||
static void InvalidateDowntimeCache(void);
|
||||
static void ValidateDowntimeCache(void);
|
||||
|
||||
private:
|
||||
static int m_NextDowntimeID;
|
||||
|
||||
static map<int, String> m_LegacyDowntimeCache;
|
||||
static map<String, DynamicObject::WeakPtr> m_DowntimeCache;
|
||||
static bool m_DowntimeCacheValid;
|
||||
static Timer::Ptr m_DowntimeExpireTimer;
|
||||
|
||||
DowntimeProcessor(void);
|
||||
|
||||
static void DowntimeExpireTimerHandler(void);
|
||||
|
||||
static void AddDowntimesToCache(const DynamicObject::Ptr& owner);
|
||||
static void RemoveExpiredDowntimes(const DynamicObject::Ptr& owner);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* DOWNTIMEPROCESSOR_H */
|
|
@ -328,8 +328,11 @@ void ExternalCommandProcessor::AcknowledgeHostProblem(double, const vector<Strin
|
|||
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Setting acknowledgement for host '" + host->GetName() + "'");
|
||||
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||
host->SetAcknowledgementExpiry(0);
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||
service->SetAcknowledgementExpiry(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector<String>& arguments)
|
||||
|
@ -346,8 +349,11 @@ void ExternalCommandProcessor::AcknowledgeHostProblemExpire(double, const vector
|
|||
BOOST_THROW_EXCEPTION(invalid_argument("The host '" + arguments[0] + "' is OK."));
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Setting timed acknowledgement for host '" + host->GetName() + "'");
|
||||
host->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||
host->SetAcknowledgementExpiry(timestamp);
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
service->SetAcknowledgement(sticky ? AcknowledgementSticky : AcknowledgementNormal);
|
||||
service->SetAcknowledgementExpiry(timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const vector<String>& arguments)
|
||||
|
@ -358,8 +364,11 @@ void ExternalCommandProcessor::RemoveHostAcknowledgement(double, const vector<St
|
|||
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Removing acknowledgement for host '" + host->GetName() + "'");
|
||||
host->SetAcknowledgement(AcknowledgementNone);
|
||||
host->SetAcknowledgementExpiry(0);
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
service->SetAcknowledgement(AcknowledgementNone);
|
||||
service->SetAcknowledgementExpiry(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::EnableHostgroupSvcChecks(double, const vector<String>& arguments)
|
||||
|
@ -540,10 +549,10 @@ void ExternalCommandProcessor::ScheduleSvcDowntime(double, const vector<String>&
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[5]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for service " + service->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(service, arguments[7], arguments[8],
|
||||
(void) service->AddDowntime(arguments[7], arguments[8],
|
||||
Convert::ToDouble(arguments[2]), Convert::ToDouble(arguments[3]),
|
||||
Convert::ToBool(arguments[4]), triggeredBy, Convert::ToDouble(arguments[6]));
|
||||
}
|
||||
|
@ -555,8 +564,8 @@ void ExternalCommandProcessor::DelSvcDowntime(double, const vector<String>& argu
|
|||
|
||||
int id = Convert::ToLong(arguments[0]);
|
||||
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
||||
String rid = DowntimeProcessor::GetIDFromLegacyID(id);
|
||||
DowntimeProcessor::RemoveDowntime(rid);
|
||||
String rid = Service::GetDowntimeIDFromLegacyID(id);
|
||||
Service::RemoveDowntime(rid);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ScheduleHostDowntime(double, const vector<String>& arguments)
|
||||
|
@ -569,12 +578,15 @@ void ExternalCommandProcessor::ScheduleHostDowntime(double, const vector<String>
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(host, arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::DelHostDowntime(double, const vector<String>& arguments)
|
||||
|
@ -584,8 +596,8 @@ void ExternalCommandProcessor::DelHostDowntime(double, const vector<String>& arg
|
|||
|
||||
int id = Convert::ToLong(arguments[0]);
|
||||
Logger::Write(LogInformation, "icinga", "Removing downtime ID " + arguments[0]);
|
||||
String rid = DowntimeProcessor::GetIDFromLegacyID(id);
|
||||
DowntimeProcessor::RemoveDowntime(rid);
|
||||
String rid = Service::GetDowntimeIDFromLegacyID(id);
|
||||
Service::RemoveDowntime(rid);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const vector<String>& arguments)
|
||||
|
@ -598,16 +610,11 @@ void ExternalCommandProcessor::ScheduleHostSvcDowntime(double, const vector<Stri
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(host, arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
BOOST_FOREACH(const Service::Ptr& service, host->GetServices()) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for service " + service->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(service, arguments[6], arguments[7],
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
|
@ -623,13 +630,16 @@ void ExternalCommandProcessor::ScheduleHostgroupHostDowntime(double, const vecto
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
BOOST_FOREACH(const Host::Ptr& host, hg->GetMembers()) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(host, arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,7 +653,7 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const vector
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
/* Note: we can't just directly create downtimes for all the services by iterating
|
||||
* over all hosts in the host group - otherwise we might end up creating multiple
|
||||
|
@ -659,7 +669,7 @@ void ExternalCommandProcessor::ScheduleHostgroupSvcDowntime(double, const vector
|
|||
|
||||
BOOST_FOREACH(const Service::Ptr& service, services) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for service " + service->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(service, arguments[6], arguments[7],
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
|
@ -675,21 +685,23 @@ void ExternalCommandProcessor::ScheduleServicegroupHostDowntime(double, const ve
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
/* Note: we can't just directly create downtimes for all the hosts by iterating
|
||||
* over all services in the service group - otherwise we might end up creating multiple
|
||||
* downtimes for some hosts. */
|
||||
|
||||
set<Host::Ptr> hosts;
|
||||
set<Service::Ptr> services;
|
||||
|
||||
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
|
||||
hosts.insert(service->GetHost());
|
||||
Service::Ptr hcService = service->GetHost()->GetHostCheckService();
|
||||
if (hcService)
|
||||
services.insert(hcService);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const Host::Ptr& host, hosts) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for host " + host->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(host, arguments[6], arguments[7],
|
||||
BOOST_FOREACH(const Service::Ptr& service, services) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for service " + service->GetName());
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
|
@ -705,11 +717,11 @@ void ExternalCommandProcessor::ScheduleServicegroupSvcDowntime(double, const vec
|
|||
String triggeredBy;
|
||||
int triggeredByLegacy = Convert::ToLong(arguments[4]);
|
||||
if (triggeredByLegacy != 0)
|
||||
triggeredBy = DowntimeProcessor::GetIDFromLegacyID(triggeredByLegacy);
|
||||
triggeredBy = Service::GetDowntimeIDFromLegacyID(triggeredByLegacy);
|
||||
|
||||
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
|
||||
Logger::Write(LogInformation, "icinga", "Creating downtime for service " + service->GetName());
|
||||
(void) DowntimeProcessor::AddDowntime(service, arguments[6], arguments[7],
|
||||
(void) service->AddDowntime(arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(arguments[3]), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
|
@ -723,7 +735,10 @@ void ExternalCommandProcessor::AddHostComment(double, const vector<String>& argu
|
|||
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Creating comment for host " + host->GetName());
|
||||
(void) CommentProcessor::AddComment(host, Comment_User, arguments[2], arguments[3], 0);
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
(void) service->AddComment(CommentUser, arguments[2], arguments[3], 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::DelHostComment(double, const vector<String>& arguments)
|
||||
|
@ -733,8 +748,8 @@ void ExternalCommandProcessor::DelHostComment(double, const vector<String>& argu
|
|||
|
||||
int id = Convert::ToLong(arguments[0]);
|
||||
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
||||
String rid = CommentProcessor::GetIDFromLegacyID(id);
|
||||
CommentProcessor::RemoveComment(rid);
|
||||
String rid = Service::GetCommentIDFromLegacyID(id);
|
||||
Service::RemoveComment(rid);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::AddSvcComment(double, const vector<String>& arguments)
|
||||
|
@ -745,7 +760,7 @@ void ExternalCommandProcessor::AddSvcComment(double, const vector<String>& argum
|
|||
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Creating comment for service " + service->GetName());
|
||||
(void) CommentProcessor::AddComment(service, Comment_User, arguments[3], arguments[4], 0);
|
||||
(void) service->AddComment(CommentUser, arguments[3], arguments[4], 0);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::DelSvcComment(double, const vector<String>& arguments)
|
||||
|
@ -756,8 +771,8 @@ void ExternalCommandProcessor::DelSvcComment(double, const vector<String>& argum
|
|||
int id = Convert::ToLong(arguments[0]);
|
||||
Logger::Write(LogInformation, "icinga", "Removing comment ID " + arguments[0]);
|
||||
|
||||
String rid = CommentProcessor::GetIDFromLegacyID(id);
|
||||
CommentProcessor::RemoveComment(rid);
|
||||
String rid = Service::GetCommentIDFromLegacyID(id);
|
||||
Service::RemoveComment(rid);
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::DelAllHostComments(double, const vector<String>& arguments)
|
||||
|
@ -768,7 +783,10 @@ void ExternalCommandProcessor::DelAllHostComments(double, const vector<String>&
|
|||
Host::Ptr host = Host::GetByName(arguments[0]);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Removing all comments for host " + host->GetName());
|
||||
CommentProcessor::RemoveAllComments(host);
|
||||
Service::Ptr service = host->GetHostCheckService();
|
||||
if (service) {
|
||||
service->RemoveAllComments();
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalCommandProcessor::DelAllSvcComments(double, const vector<String>& arguments)
|
||||
|
@ -779,5 +797,5 @@ void ExternalCommandProcessor::DelAllSvcComments(double, const vector<String>& a
|
|||
Service::Ptr service = Service::GetByNamePair(arguments[0], arguments[1]);
|
||||
|
||||
Logger::Write(LogInformation, "icinga", "Removing all comments for service " + service->GetName());
|
||||
CommentProcessor::RemoveAllComments(service);
|
||||
service->RemoveAllComments();
|
||||
}
|
||||
|
|
|
@ -27,10 +27,6 @@ bool Host::m_ServicesCacheValid = true;
|
|||
REGISTER_SCRIPTFUNCTION("native::ValidateServiceDictionary", &Host::ValidateServiceDictionary);
|
||||
|
||||
static AttributeDescription hostAttributes[] = {
|
||||
{ "acknowledgement", Attribute_Replicated },
|
||||
{ "acknowledgement_expiry", Attribute_Replicated },
|
||||
{ "downtimes", Attribute_Replicated },
|
||||
{ "comments", Attribute_Replicated },
|
||||
{ "convenience_services", Attribute_Transient }
|
||||
};
|
||||
|
||||
|
@ -43,7 +39,6 @@ Host::Host(const Dictionary::Ptr& properties)
|
|||
void Host::OnInitCompleted(void)
|
||||
{
|
||||
HostGroup::InvalidateMembersCache();
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
|
||||
UpdateSlaveServices();
|
||||
}
|
||||
|
@ -51,7 +46,6 @@ void Host::OnInitCompleted(void)
|
|||
Host::~Host(void)
|
||||
{
|
||||
HostGroup::InvalidateMembersCache();
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
|
||||
Dictionary::Ptr services = Get("convenience_services");
|
||||
|
||||
|
@ -97,20 +91,6 @@ Dictionary::Ptr Host::GetMacros(void) const
|
|||
return Get("macros");
|
||||
}
|
||||
|
||||
Dictionary::Ptr Host::GetDowntimes(void) const
|
||||
{
|
||||
DowntimeProcessor::ValidateDowntimeCache();
|
||||
|
||||
return Get("downtimes");
|
||||
}
|
||||
|
||||
Dictionary::Ptr Host::GetComments(void) const
|
||||
{
|
||||
CommentProcessor::ValidateCommentCache();
|
||||
|
||||
return Get("comments");
|
||||
}
|
||||
|
||||
Dictionary::Ptr Host::GetHostDependencies(void) const
|
||||
{
|
||||
return Get("hostdependencies");
|
||||
|
@ -158,18 +138,8 @@ bool Host::IsReachable(void)
|
|||
|
||||
bool Host::IsInDowntime(void) const
|
||||
{
|
||||
Dictionary::Ptr downtimes = GetDowntimes();
|
||||
|
||||
if (!downtimes)
|
||||
return false;
|
||||
|
||||
Dictionary::Ptr downtime;
|
||||
BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
|
||||
if (DowntimeProcessor::IsDowntimeActive(downtime))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Service::Ptr service = GetHostCheckService();
|
||||
return (service || service->IsInDowntime());
|
||||
}
|
||||
|
||||
bool Host::IsUp(void) const
|
||||
|
@ -289,8 +259,6 @@ void Host::OnAttributeChanged(const String& name, const Value&)
|
|||
{
|
||||
if (name == "hostgroups")
|
||||
HostGroup::InvalidateMembersCache();
|
||||
else if (name == "downtimes")
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
else if (name == "services")
|
||||
UpdateSlaveServices();
|
||||
}
|
||||
|
@ -315,49 +283,6 @@ set<Service::Ptr> Host::GetServices(void) const
|
|||
return services;
|
||||
}
|
||||
|
||||
AcknowledgementType Host::GetAcknowledgement(void)
|
||||
{
|
||||
Value value = Get("acknowledgement");
|
||||
|
||||
if (value.IsEmpty())
|
||||
return AcknowledgementNone;
|
||||
|
||||
int ivalue = static_cast<int>(value);
|
||||
AcknowledgementType avalue = static_cast<AcknowledgementType>(ivalue);
|
||||
|
||||
if (avalue != AcknowledgementNone) {
|
||||
double expiry = GetAcknowledgementExpiry();
|
||||
|
||||
if (expiry != 0 && expiry < Utility::GetTime()) {
|
||||
avalue = AcknowledgementNone;
|
||||
SetAcknowledgement(avalue);
|
||||
SetAcknowledgementExpiry(0);
|
||||
}
|
||||
}
|
||||
|
||||
return avalue;
|
||||
}
|
||||
|
||||
void Host::SetAcknowledgement(AcknowledgementType acknowledgement)
|
||||
{
|
||||
Set("acknowledgement", static_cast<long>(acknowledgement));
|
||||
}
|
||||
|
||||
double Host::GetAcknowledgementExpiry(void) const
|
||||
{
|
||||
Value value = Get("acknowledgement_expiry");
|
||||
|
||||
if (value.IsEmpty())
|
||||
return 0;
|
||||
|
||||
return static_cast<double>(value);
|
||||
}
|
||||
|
||||
void Host::SetAcknowledgementExpiry(double timestamp)
|
||||
{
|
||||
Set("acknowledgement_expiry", timestamp);
|
||||
}
|
||||
|
||||
void Host::InvalidateServicesCache(void)
|
||||
{
|
||||
m_ServicesCacheValid = false;
|
||||
|
|
|
@ -47,18 +47,10 @@ public:
|
|||
Dictionary::Ptr GetGroups(void) const;
|
||||
|
||||
Dictionary::Ptr GetMacros(void) const;
|
||||
Dictionary::Ptr GetDowntimes(void) const;
|
||||
Dictionary::Ptr GetComments(void) const;
|
||||
Dictionary::Ptr GetHostDependencies(void) const;
|
||||
Dictionary::Ptr GetServiceDependencies(void) const;
|
||||
String GetHostCheck(void) const;
|
||||
|
||||
AcknowledgementType GetAcknowledgement(void);
|
||||
void SetAcknowledgement(AcknowledgementType acknowledgement);
|
||||
|
||||
double GetAcknowledgementExpiry(void) const;
|
||||
void SetAcknowledgementExpiry(double timestamp);
|
||||
|
||||
shared_ptr<Service> GetHostCheckService(void) const;
|
||||
set<Host::Ptr> GetParentHosts(void) const;
|
||||
set<shared_ptr<Service> > GetParentServices(void) const;
|
||||
|
|
|
@ -46,10 +46,6 @@ using boost::algorithm::is_any_of;
|
|||
#include "endpointmanager.h"
|
||||
#include "icingaapplication.h"
|
||||
|
||||
#include "acknowledgement.h"
|
||||
#include "downtimeprocessor.h"
|
||||
#include "commentprocessor.h"
|
||||
|
||||
#include "host.h"
|
||||
#include "hostgroup.h"
|
||||
#include "service.h"
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="checkresultmessage.cpp" />
|
||||
<ClCompile Include="cib.cpp" />
|
||||
<ClCompile Include="commentprocessor.cpp" />
|
||||
<ClCompile Include="downtimeprocessor.cpp" />
|
||||
<ClCompile Include="externalcommandprocessor.cpp" />
|
||||
<ClCompile Include="host.cpp" />
|
||||
<ClCompile Include="hostgroup.cpp" />
|
||||
|
@ -37,14 +35,13 @@
|
|||
<ClCompile Include="pluginchecktask.cpp" />
|
||||
<ClCompile Include="nullchecktask.cpp" />
|
||||
<ClCompile Include="service.cpp" />
|
||||
<ClCompile Include="service-comment.cpp" />
|
||||
<ClCompile Include="service-downtime.cpp" />
|
||||
<ClCompile Include="servicegroup.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="acknowledgement.h" />
|
||||
<ClInclude Include="checkresultmessage.h" />
|
||||
<ClInclude Include="cib.h" />
|
||||
<ClInclude Include="commentprocessor.h" />
|
||||
<ClInclude Include="downtimeprocessor.h" />
|
||||
<ClInclude Include="externalcommandprocessor.h" />
|
||||
<ClInclude Include="host.h" />
|
||||
<ClInclude Include="hostgroup.h" />
|
||||
|
|
|
@ -21,20 +21,19 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
int CommentProcessor::m_NextCommentID = 1;
|
||||
map<int, String> CommentProcessor::m_LegacyCommentCache;
|
||||
map<String, DynamicObject::WeakPtr> CommentProcessor::m_CommentCache;
|
||||
bool CommentProcessor::m_CommentCacheValid;
|
||||
Timer::Ptr CommentProcessor::m_CommentExpireTimer;
|
||||
int Service::m_NextCommentID = 1;
|
||||
map<int, String> Service::m_LegacyCommentCache;
|
||||
map<String, Service::WeakPtr> Service::m_CommentCache;
|
||||
bool Service::m_CommentCacheValid;
|
||||
Timer::Ptr Service::m_CommentExpireTimer;
|
||||
|
||||
int CommentProcessor::GetNextCommentID(void)
|
||||
int Service::GetNextCommentID(void)
|
||||
{
|
||||
return m_NextCommentID;
|
||||
}
|
||||
|
||||
String CommentProcessor::AddComment(const DynamicObject::Ptr& owner,
|
||||
CommentType entryType, const String& author, const String& text,
|
||||
double expireTime)
|
||||
String Service::AddComment(CommentType entryType, const String& author,
|
||||
const String& text, double expireTime)
|
||||
{
|
||||
Dictionary::Ptr comment = boost::make_shared<Dictionary>();
|
||||
comment->Set("entry_time", Utility::GetTime());
|
||||
|
@ -44,26 +43,26 @@ String CommentProcessor::AddComment(const DynamicObject::Ptr& owner,
|
|||
comment->Set("expire_time", expireTime);
|
||||
comment->Set("legacy_id", m_NextCommentID++);
|
||||
|
||||
Dictionary::Ptr comments = owner->Get("comments");
|
||||
Dictionary::Ptr comments = Get("comments");
|
||||
|
||||
if (!comments)
|
||||
comments = boost::make_shared<Dictionary>();
|
||||
|
||||
String id = Utility::NewUUID();
|
||||
comments->Set(id, comment);
|
||||
owner->Set("comments", comments);
|
||||
Set("comments", comments);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void CommentProcessor::RemoveAllComments(const DynamicObject::Ptr& owner)
|
||||
void Service::RemoveAllComments(void)
|
||||
{
|
||||
owner->Set("comments", Empty);
|
||||
Set("comments", Empty);
|
||||
}
|
||||
|
||||
void CommentProcessor::RemoveComment(const String& id)
|
||||
void Service::RemoveComment(const String& id)
|
||||
{
|
||||
DynamicObject::Ptr owner = GetOwnerByCommentID(id);
|
||||
Service::Ptr owner = GetOwnerByCommentID(id);
|
||||
|
||||
if (!owner)
|
||||
return;
|
||||
|
@ -76,7 +75,7 @@ void CommentProcessor::RemoveComment(const String& id)
|
|||
}
|
||||
}
|
||||
|
||||
String CommentProcessor::GetIDFromLegacyID(int id)
|
||||
String Service::GetCommentIDFromLegacyID(int id)
|
||||
{
|
||||
map<int, String>::iterator it = m_LegacyCommentCache.find(id);
|
||||
|
||||
|
@ -86,16 +85,16 @@ String CommentProcessor::GetIDFromLegacyID(int id)
|
|||
return it->second;
|
||||
}
|
||||
|
||||
DynamicObject::Ptr CommentProcessor::GetOwnerByCommentID(const String& id)
|
||||
Service::Ptr Service::GetOwnerByCommentID(const String& id)
|
||||
{
|
||||
ValidateCommentCache();
|
||||
|
||||
return m_CommentCache[id].lock();
|
||||
}
|
||||
|
||||
Dictionary::Ptr CommentProcessor::GetCommentByID(const String& id)
|
||||
Dictionary::Ptr Service::GetCommentByID(const String& id)
|
||||
{
|
||||
DynamicObject::Ptr owner = GetOwnerByCommentID(id);
|
||||
Service::Ptr owner = GetOwnerByCommentID(id);
|
||||
|
||||
if (!owner)
|
||||
return Dictionary::Ptr();
|
||||
|
@ -110,23 +109,23 @@ Dictionary::Ptr CommentProcessor::GetCommentByID(const String& id)
|
|||
return Dictionary::Ptr();
|
||||
}
|
||||
|
||||
bool CommentProcessor::IsCommentExpired(const Dictionary::Ptr& comment)
|
||||
bool Service::IsCommentExpired(const Dictionary::Ptr& comment)
|
||||
{
|
||||
double expire_time = comment->Get("expire_time");
|
||||
|
||||
return (expire_time != 0 && expire_time < Utility::GetTime());
|
||||
}
|
||||
|
||||
void CommentProcessor::InvalidateCommentCache(void)
|
||||
void Service::InvalidateCommentCache(void)
|
||||
{
|
||||
m_CommentCacheValid = false;
|
||||
m_CommentCache.clear();
|
||||
m_LegacyCommentCache.clear();
|
||||
}
|
||||
|
||||
void CommentProcessor::AddCommentsToCache(const DynamicObject::Ptr& owner)
|
||||
void Service::AddCommentsToCache(void)
|
||||
{
|
||||
Dictionary::Ptr comments = owner->Get("comments");
|
||||
Dictionary::Ptr comments = Get("comments");
|
||||
|
||||
if (!comments)
|
||||
return;
|
||||
|
@ -145,15 +144,15 @@ void CommentProcessor::AddCommentsToCache(const DynamicObject::Ptr& owner)
|
|||
|
||||
legacy_id = m_NextCommentID++;
|
||||
comment->Set("legacy_id", legacy_id);
|
||||
owner->Touch("comments");
|
||||
Touch("comments");
|
||||
}
|
||||
|
||||
m_LegacyCommentCache[legacy_id] = id;
|
||||
m_CommentCache[id] = owner;
|
||||
m_CommentCache[id] = GetSelf();
|
||||
}
|
||||
}
|
||||
|
||||
void CommentProcessor::ValidateCommentCache(void)
|
||||
void Service::ValidateCommentCache(void)
|
||||
{
|
||||
if (m_CommentCacheValid)
|
||||
return;
|
||||
|
@ -162,12 +161,9 @@ void CommentProcessor::ValidateCommentCache(void)
|
|||
m_LegacyCommentCache.clear();
|
||||
|
||||
DynamicObject::Ptr object;
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Host")->GetObjects()) {
|
||||
AddCommentsToCache(object);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
|
||||
AddCommentsToCache(object);
|
||||
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
||||
service->AddCommentsToCache();
|
||||
}
|
||||
|
||||
m_CommentCacheValid = true;
|
||||
|
@ -175,14 +171,14 @@ void CommentProcessor::ValidateCommentCache(void)
|
|||
if (!m_CommentExpireTimer) {
|
||||
m_CommentExpireTimer = boost::make_shared<Timer>();
|
||||
m_CommentExpireTimer->SetInterval(300);
|
||||
m_CommentExpireTimer->OnTimerExpired.connect(boost::bind(&CommentProcessor::CommentExpireTimerHandler));
|
||||
m_CommentExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentExpireTimerHandler));
|
||||
m_CommentExpireTimer->Start();
|
||||
}
|
||||
}
|
||||
|
||||
void CommentProcessor::RemoveExpiredComments(const DynamicObject::Ptr& owner)
|
||||
void Service::RemoveExpiredComments(void)
|
||||
{
|
||||
Dictionary::Ptr comments = owner->Get("comments");
|
||||
Dictionary::Ptr comments = Get("comments");
|
||||
|
||||
if (!comments)
|
||||
return;
|
||||
|
@ -201,19 +197,15 @@ void CommentProcessor::RemoveExpiredComments(const DynamicObject::Ptr& owner)
|
|||
comments->Remove(id);
|
||||
}
|
||||
|
||||
owner->Touch("comments");
|
||||
Touch("comments");
|
||||
}
|
||||
}
|
||||
|
||||
void CommentProcessor::CommentExpireTimerHandler(void)
|
||||
void Service::CommentExpireTimerHandler(void)
|
||||
{
|
||||
DynamicObject::Ptr object;
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Host")->GetObjects()) {
|
||||
RemoveExpiredComments(object);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
|
||||
RemoveExpiredComments(object);
|
||||
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
||||
service->RemoveExpiredComments();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,21 +21,20 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
int DowntimeProcessor::m_NextDowntimeID = 1;
|
||||
map<int, String> DowntimeProcessor::m_LegacyDowntimeCache;
|
||||
map<String, DynamicObject::WeakPtr> DowntimeProcessor::m_DowntimeCache;
|
||||
bool DowntimeProcessor::m_DowntimeCacheValid;
|
||||
Timer::Ptr DowntimeProcessor::m_DowntimeExpireTimer;
|
||||
int Service::m_NextDowntimeID = 1;
|
||||
map<int, String> Service::m_LegacyDowntimeCache;
|
||||
map<String, Service::WeakPtr> Service::m_DowntimeCache;
|
||||
bool Service::m_DowntimeCacheValid;
|
||||
Timer::Ptr Service::m_DowntimeExpireTimer;
|
||||
|
||||
int DowntimeProcessor::GetNextDowntimeID(void)
|
||||
int Service::GetNextDowntimeID(void)
|
||||
{
|
||||
return m_NextDowntimeID;
|
||||
}
|
||||
|
||||
String DowntimeProcessor::AddDowntime(const DynamicObject::Ptr& owner,
|
||||
const String& author, const String& comment,
|
||||
double startTime, double endTime,
|
||||
bool fixed, const String& triggeredBy, double duration)
|
||||
String Service::AddDowntime(const String& author, const String& comment,
|
||||
double startTime, double endTime, bool fixed,
|
||||
const String& triggeredBy, double duration)
|
||||
{
|
||||
Dictionary::Ptr downtime = boost::make_shared<Dictionary>();
|
||||
downtime->Set("entry_time", Utility::GetTime());
|
||||
|
@ -51,33 +50,33 @@ String DowntimeProcessor::AddDowntime(const DynamicObject::Ptr& owner,
|
|||
downtime->Set("legacy_id", m_NextDowntimeID++);
|
||||
|
||||
if (!triggeredBy.IsEmpty()) {
|
||||
DynamicObject::Ptr otherOwner = GetOwnerByDowntimeID(triggeredBy);
|
||||
Service::Ptr otherOwner = GetOwnerByDowntimeID(triggeredBy);
|
||||
Dictionary::Ptr otherDowntimes = otherOwner->Get("downtimes");
|
||||
Dictionary::Ptr otherDowntime = otherDowntimes->Get(triggeredBy);
|
||||
Dictionary::Ptr triggers = otherDowntime->Get("triggers");
|
||||
triggers->Set(triggeredBy, triggeredBy);
|
||||
otherOwner->Touch("downtimes");
|
||||
}
|
||||
|
||||
Dictionary::Ptr downtimes = owner->Get("downtimes");
|
||||
|
||||
Dictionary::Ptr downtimes = Get("downtimes");
|
||||
|
||||
if (!downtimes)
|
||||
downtimes = boost::make_shared<Dictionary>();
|
||||
|
||||
String id = Utility::NewUUID();
|
||||
downtimes->Set(id, downtime);
|
||||
owner->Set("downtimes", downtimes);
|
||||
Set("downtimes", downtimes);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void DowntimeProcessor::RemoveDowntime(const String& id)
|
||||
void Service::RemoveDowntime(const String& id)
|
||||
{
|
||||
DynamicObject::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
|
||||
if (!owner)
|
||||
return;
|
||||
|
||||
|
||||
Dictionary::Ptr downtimes = owner->Get("downtimes");
|
||||
|
||||
if (!downtimes)
|
||||
|
@ -87,22 +86,22 @@ void DowntimeProcessor::RemoveDowntime(const String& id)
|
|||
owner->Touch("downtimes");
|
||||
}
|
||||
|
||||
void DowntimeProcessor::TriggerDowntimes(const DynamicObject::Ptr& owner)
|
||||
void Service::TriggerDowntimes(void)
|
||||
{
|
||||
Dictionary::Ptr downtimes = owner->Get("downtimes");
|
||||
Dictionary::Ptr downtimes = Get("downtimes");
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
||||
|
||||
String id;
|
||||
BOOST_FOREACH(tie(id, tuples::ignore), downtimes) {
|
||||
TriggerDowntime(id);
|
||||
}
|
||||
}
|
||||
|
||||
void DowntimeProcessor::TriggerDowntime(const String& id)
|
||||
void Service::TriggerDowntime(const String& id)
|
||||
{
|
||||
DynamicObject::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
Dictionary::Ptr downtime = GetDowntimeByID(id);
|
||||
|
||||
double now = Utility::GetTime();
|
||||
|
@ -113,18 +112,20 @@ void DowntimeProcessor::TriggerDowntime(const String& id)
|
|||
|
||||
if (downtime->Get("trigger_time") == 0)
|
||||
downtime->Set("trigger_time", now);
|
||||
|
||||
|
||||
Dictionary::Ptr triggers = downtime->Get("triggers");
|
||||
String tid;
|
||||
BOOST_FOREACH(tie(tid, tuples::ignore), triggers) {
|
||||
TriggerDowntime(tid);
|
||||
}
|
||||
|
||||
|
||||
owner->Touch("downtimes");
|
||||
}
|
||||
|
||||
String DowntimeProcessor::GetIDFromLegacyID(int id)
|
||||
String Service::GetDowntimeIDFromLegacyID(int id)
|
||||
{
|
||||
ValidateDowntimeCache();
|
||||
|
||||
map<int, String>::iterator it = m_LegacyDowntimeCache.find(id);
|
||||
|
||||
if (it == m_LegacyDowntimeCache.end())
|
||||
|
@ -133,16 +134,16 @@ String DowntimeProcessor::GetIDFromLegacyID(int id)
|
|||
return it->second;
|
||||
}
|
||||
|
||||
DynamicObject::Ptr DowntimeProcessor::GetOwnerByDowntimeID(const String& id)
|
||||
Service::Ptr Service::GetOwnerByDowntimeID(const String& id)
|
||||
{
|
||||
ValidateDowntimeCache();
|
||||
|
||||
return m_DowntimeCache[id].lock();
|
||||
}
|
||||
|
||||
Dictionary::Ptr DowntimeProcessor::GetDowntimeByID(const String& id)
|
||||
Dictionary::Ptr Service::GetDowntimeByID(const String& id)
|
||||
{
|
||||
DynamicObject::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
Service::Ptr owner = GetOwnerByDowntimeID(id);
|
||||
|
||||
if (!owner)
|
||||
return Dictionary::Ptr();
|
||||
|
@ -157,7 +158,7 @@ Dictionary::Ptr DowntimeProcessor::GetDowntimeByID(const String& id)
|
|||
return Dictionary::Ptr();
|
||||
}
|
||||
|
||||
bool DowntimeProcessor::IsDowntimeActive(const Dictionary::Ptr& downtime)
|
||||
bool Service::IsDowntimeActive(const Dictionary::Ptr& downtime)
|
||||
{
|
||||
double now = Utility::GetTime();
|
||||
|
||||
|
@ -176,21 +177,21 @@ bool DowntimeProcessor::IsDowntimeActive(const Dictionary::Ptr& downtime)
|
|||
return (triggerTime + downtime->Get("duration") < now);
|
||||
}
|
||||
|
||||
bool DowntimeProcessor::IsDowntimeExpired(const Dictionary::Ptr& downtime)
|
||||
bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime)
|
||||
{
|
||||
return (downtime->Get("end_time") < Utility::GetTime());
|
||||
}
|
||||
|
||||
void DowntimeProcessor::InvalidateDowntimeCache(void)
|
||||
void Service::InvalidateDowntimeCache(void)
|
||||
{
|
||||
m_DowntimeCacheValid = false;
|
||||
m_DowntimeCache.clear();
|
||||
m_LegacyDowntimeCache.clear();
|
||||
}
|
||||
|
||||
void DowntimeProcessor::AddDowntimesToCache(const DynamicObject::Ptr& owner)
|
||||
void Service::AddDowntimesToCache(void)
|
||||
{
|
||||
Dictionary::Ptr downtimes = owner->Get("downtimes");
|
||||
Dictionary::Ptr downtimes = Get("downtimes");
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
@ -208,15 +209,15 @@ void DowntimeProcessor::AddDowntimesToCache(const DynamicObject::Ptr& owner)
|
|||
* this shouldn't usually happen - assign it a new ID. */
|
||||
legacy_id = m_NextDowntimeID++;
|
||||
downtime->Set("legacy_id", legacy_id);
|
||||
owner->Touch("downtimes");
|
||||
Touch("downtimes");
|
||||
}
|
||||
|
||||
m_LegacyDowntimeCache[legacy_id] = id;
|
||||
m_DowntimeCache[id] = owner;
|
||||
m_DowntimeCache[id] = GetSelf();
|
||||
}
|
||||
}
|
||||
|
||||
void DowntimeProcessor::ValidateDowntimeCache(void)
|
||||
void Service::ValidateDowntimeCache(void)
|
||||
{
|
||||
if (m_DowntimeCacheValid)
|
||||
return;
|
||||
|
@ -225,12 +226,9 @@ void DowntimeProcessor::ValidateDowntimeCache(void)
|
|||
m_LegacyDowntimeCache.clear();
|
||||
|
||||
DynamicObject::Ptr object;
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Host")->GetObjects()) {
|
||||
AddDowntimesToCache(object);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
|
||||
AddDowntimesToCache(object);
|
||||
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
||||
service->AddDowntimesToCache();
|
||||
}
|
||||
|
||||
m_DowntimeCacheValid = true;
|
||||
|
@ -238,14 +236,14 @@ void DowntimeProcessor::ValidateDowntimeCache(void)
|
|||
if (!m_DowntimeExpireTimer) {
|
||||
m_DowntimeExpireTimer = boost::make_shared<Timer>();
|
||||
m_DowntimeExpireTimer->SetInterval(300);
|
||||
m_DowntimeExpireTimer->OnTimerExpired.connect(boost::bind(&DowntimeProcessor::DowntimeExpireTimerHandler));
|
||||
m_DowntimeExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimeExpireTimerHandler));
|
||||
m_DowntimeExpireTimer->Start();
|
||||
}
|
||||
}
|
||||
|
||||
void DowntimeProcessor::RemoveExpiredDowntimes(const DynamicObject::Ptr& owner)
|
||||
void Service::RemoveExpiredDowntimes(void)
|
||||
{
|
||||
Dictionary::Ptr downtimes = owner->Get("downtimes");
|
||||
Dictionary::Ptr downtimes = Get("downtimes");
|
||||
|
||||
if (!downtimes)
|
||||
return;
|
||||
|
@ -264,19 +262,15 @@ void DowntimeProcessor::RemoveExpiredDowntimes(const DynamicObject::Ptr& owner)
|
|||
downtimes->Remove(id);
|
||||
}
|
||||
|
||||
owner->Touch("downtimes");
|
||||
Touch("downtimes");
|
||||
}
|
||||
}
|
||||
|
||||
void DowntimeProcessor::DowntimeExpireTimerHandler(void)
|
||||
void Service::DowntimeExpireTimerHandler(void)
|
||||
{
|
||||
DynamicObject::Ptr object;
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Host")->GetObjects()) {
|
||||
RemoveExpiredDowntimes(object);
|
||||
}
|
||||
|
||||
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
|
||||
RemoveExpiredDowntimes(object);
|
||||
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
||||
service->RemoveExpiredDowntimes();
|
||||
}
|
||||
}
|
||||
|
|
@ -56,14 +56,16 @@ Service::Service(const Dictionary::Ptr& serializedObject)
|
|||
{
|
||||
ServiceGroup::InvalidateMembersCache();
|
||||
Host::InvalidateServicesCache();
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
Service::InvalidateDowntimeCache();
|
||||
Service::InvalidateCommentCache();
|
||||
}
|
||||
|
||||
Service::~Service(void)
|
||||
{
|
||||
ServiceGroup::InvalidateMembersCache();
|
||||
Host::InvalidateServicesCache();
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
Service::InvalidateDowntimeCache();
|
||||
Service::InvalidateCommentCache();
|
||||
}
|
||||
|
||||
String Service::GetAlias(void) const
|
||||
|
@ -118,14 +120,14 @@ Dictionary::Ptr Service::GetMacros(void) const
|
|||
|
||||
Dictionary::Ptr Service::GetDowntimes(void) const
|
||||
{
|
||||
DowntimeProcessor::ValidateDowntimeCache();
|
||||
Service::ValidateDowntimeCache();
|
||||
|
||||
return Get("downtimes");
|
||||
}
|
||||
|
||||
Dictionary::Ptr Service::GetComments(void) const
|
||||
{
|
||||
CommentProcessor::ValidateCommentCache();
|
||||
Service::ValidateCommentCache();
|
||||
|
||||
return Get("comments");
|
||||
}
|
||||
|
@ -234,7 +236,7 @@ bool Service::IsInDowntime(void) const
|
|||
|
||||
Dictionary::Ptr downtime;
|
||||
BOOST_FOREACH(tie(tuples::ignore, downtime), downtimes) {
|
||||
if (DowntimeProcessor::IsDowntimeActive(downtime))
|
||||
if (Service::IsDowntimeActive(downtime))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -559,7 +561,7 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
|
|||
}
|
||||
|
||||
if (GetState() != StateOK)
|
||||
DowntimeProcessor::TriggerDowntimes(GetSelf());
|
||||
TriggerDowntimes();
|
||||
}
|
||||
|
||||
ServiceState Service::StateFromString(const String& state)
|
||||
|
@ -636,7 +638,9 @@ void Service::OnAttributeChanged(const String& name, const Value& oldValue)
|
|||
else if (name == "host_name" || name == "short_name")
|
||||
Host::InvalidateServicesCache();
|
||||
else if (name == "downtimes")
|
||||
DowntimeProcessor::InvalidateDowntimeCache();
|
||||
Service::InvalidateDowntimeCache();
|
||||
else if (name == "comments")
|
||||
Service::InvalidateCommentCache();
|
||||
}
|
||||
|
||||
void Service::BeginExecuteCheck(const function<void (void)>& callback)
|
||||
|
|
|
@ -48,6 +48,31 @@ enum ServiceStateType
|
|||
StateTypeHard
|
||||
};
|
||||
|
||||
/**
|
||||
* The acknowledgement type of a service.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
enum AcknowledgementType
|
||||
{
|
||||
AcknowledgementNone = 0,
|
||||
AcknowledgementNormal = 1,
|
||||
AcknowledgementSticky = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* The type of a service comment.
|
||||
*
|
||||
* @ingroup icinga
|
||||
*/
|
||||
enum CommentType
|
||||
{
|
||||
CommentUser = 1,
|
||||
CommentDowntime = 2,
|
||||
CommentFlapping = 3,
|
||||
CommentAcknowledgement = 4
|
||||
};
|
||||
|
||||
class CheckResultMessage;
|
||||
|
||||
/**
|
||||
|
@ -157,10 +182,76 @@ public:
|
|||
static boost::signal<void (const Service::Ptr&, const String&)> OnCheckerChanged;
|
||||
static boost::signal<void (const Service::Ptr&, const Value&)> OnNextCheckChanged;
|
||||
|
||||
/* Downtimes */
|
||||
static int GetNextDowntimeID(void);
|
||||
|
||||
String AddDowntime(const String& author, const String& comment,
|
||||
double startTime, double endTime, bool fixed,
|
||||
const String& triggeredBy, double duration);
|
||||
|
||||
static void RemoveDowntime(const String& id);
|
||||
|
||||
void TriggerDowntimes(void);
|
||||
static void TriggerDowntime(const String& id);
|
||||
|
||||
static String GetDowntimeIDFromLegacyID(int id);
|
||||
static Service::Ptr GetOwnerByDowntimeID(const String& id);
|
||||
static Dictionary::Ptr GetDowntimeByID(const String& id);
|
||||
|
||||
static bool IsDowntimeActive(const Dictionary::Ptr& downtime);
|
||||
static bool IsDowntimeExpired(const Dictionary::Ptr& downtime);
|
||||
|
||||
static void InvalidateDowntimeCache(void);
|
||||
static void ValidateDowntimeCache(void);
|
||||
|
||||
/* Comments */
|
||||
static int GetNextCommentID(void);
|
||||
|
||||
String AddComment(CommentType entryType, const String& author,
|
||||
const String& text, double expireTime);
|
||||
|
||||
void RemoveAllComments(void);
|
||||
static void RemoveComment(const String& id);
|
||||
|
||||
static String GetCommentIDFromLegacyID(int id);
|
||||
static Service::Ptr GetOwnerByCommentID(const String& id);
|
||||
static Dictionary::Ptr GetCommentByID(const String& id);
|
||||
|
||||
static bool IsCommentExpired(const Dictionary::Ptr& comment);
|
||||
|
||||
static void InvalidateCommentCache(void);
|
||||
static void ValidateCommentCache(void);
|
||||
|
||||
protected:
|
||||
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
||||
|
||||
private:
|
||||
/* Downtimes */
|
||||
static int m_NextDowntimeID;
|
||||
|
||||
static map<int, String> m_LegacyDowntimeCache;
|
||||
static map<String, Service::WeakPtr> m_DowntimeCache;
|
||||
static bool m_DowntimeCacheValid;
|
||||
static Timer::Ptr m_DowntimeExpireTimer;
|
||||
|
||||
static void DowntimeExpireTimerHandler(void);
|
||||
|
||||
void AddDowntimesToCache(void);
|
||||
void RemoveExpiredDowntimes(void);
|
||||
|
||||
/* Comments */
|
||||
static int m_NextCommentID;
|
||||
|
||||
static map<int, String> m_LegacyCommentCache;
|
||||
static map<String, Service::WeakPtr> m_CommentCache;
|
||||
static bool m_CommentCacheValid;
|
||||
static Timer::Ptr m_CommentExpireTimer;
|
||||
|
||||
static void CommentExpireTimerHandler(void);
|
||||
|
||||
void AddCommentsToCache(void);
|
||||
void RemoveExpiredComments(void);
|
||||
|
||||
void CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
||||
const ScriptTask::Ptr& task, const function<void (void)>& callback);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue