mirror of
https://github.com/Icinga/icinga2.git
synced 2025-06-27 00:44:29 +02:00
Removed delegation::ServiceStatus message (obsoleted by the domain concept)
This commit is contained in:
parent
d3be282f2b
commit
d1e7c15178
@ -6,6 +6,8 @@ pkglib_LTLIBRARIES = \
|
|||||||
libcib_la_SOURCES = \
|
libcib_la_SOURCES = \
|
||||||
checkresult.cpp \
|
checkresult.cpp \
|
||||||
checkresult.h \
|
checkresult.h \
|
||||||
|
checkresultmessage.cpp \
|
||||||
|
checkresultmessage.h \
|
||||||
cib.cpp \
|
cib.cpp \
|
||||||
cib.h \
|
cib.h \
|
||||||
configobjectadapter.cpp \
|
configobjectadapter.cpp \
|
||||||
@ -24,9 +26,7 @@ libcib_la_SOURCES = \
|
|||||||
service.cpp \
|
service.cpp \
|
||||||
service.h \
|
service.h \
|
||||||
servicegroup.cpp \
|
servicegroup.cpp \
|
||||||
servicegroup.h \
|
servicegroup.h
|
||||||
servicestatusmessage.cpp \
|
|
||||||
servicestatusmessage.h
|
|
||||||
|
|
||||||
libcib_la_CPPFLAGS = \
|
libcib_la_CPPFLAGS = \
|
||||||
-DI2_CIB_BUILD \
|
-DI2_CIB_BUILD \
|
||||||
|
@ -21,47 +21,17 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
bool ServiceStatusMessage::GetService(string *service) const
|
bool CheckResultMessage::GetService(string *service) const
|
||||||
{
|
{
|
||||||
return Get("service", service);
|
return Get("service", service);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceStatusMessage::SetService(const string& service)
|
void CheckResultMessage::SetService(const string& service)
|
||||||
{
|
{
|
||||||
Set("service", service);
|
Set("service", service);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceStatusMessage::GetState(ServiceState *state) const
|
bool CheckResultMessage::GetCheckResult(CheckResult *cr) const
|
||||||
{
|
|
||||||
long value;
|
|
||||||
if (Get("state", &value)) {
|
|
||||||
*state = static_cast<ServiceState>(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceStatusMessage::SetState(ServiceState state)
|
|
||||||
{
|
|
||||||
Set("state", static_cast<long>(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
|
|
||||||
{
|
|
||||||
long value;
|
|
||||||
if (Get("state_type", &value)) {
|
|
||||||
*type = static_cast<ServiceStateType>(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceStatusMessage::SetStateType(ServiceStateType type)
|
|
||||||
{
|
|
||||||
Set("state_type", static_cast<long>(type));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
|
|
||||||
{
|
{
|
||||||
Dictionary::Ptr obj;
|
Dictionary::Ptr obj;
|
||||||
if (Get("result", &obj)) {
|
if (Get("result", &obj)) {
|
||||||
@ -71,7 +41,7 @@ bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceStatusMessage::SetCheckResult(CheckResult cr)
|
void CheckResultMessage::SetCheckResult(CheckResult cr)
|
||||||
{
|
{
|
||||||
Set("result", cr.GetDictionary());
|
Set("result", cr.GetDictionary());
|
||||||
}
|
}
|
@ -17,13 +17,13 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef SERVICESTATUSMESSAGE_H
|
#ifndef CHECKRESULTMESSAGE_H
|
||||||
#define SERVICESTATUSMESSAGE_H
|
#define CHECKRESULTMESSAGE_H
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
|
||||||
class I2_CIB_API ServiceStatusMessage : public MessagePart
|
class I2_CIB_API CheckResultMessage : public MessagePart
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServiceStatusMessage(void) : MessagePart() { }
|
ServiceStatusMessage(void) : MessagePart() { }
|
||||||
@ -32,16 +32,10 @@ public:
|
|||||||
bool GetService(string *service) const;
|
bool GetService(string *service) const;
|
||||||
void SetService(const string& service);
|
void SetService(const string& service);
|
||||||
|
|
||||||
bool GetState(ServiceState *state) const;
|
|
||||||
void SetState(ServiceState state);
|
|
||||||
|
|
||||||
bool GetStateType(ServiceStateType *type) const;
|
|
||||||
void SetStateType(ServiceStateType type);
|
|
||||||
|
|
||||||
bool GetCheckResult(CheckResult *cr) const;
|
bool GetCheckResult(CheckResult *cr) const;
|
||||||
void SetCheckResult(CheckResult cr);
|
void SetCheckResult(CheckResult cr);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SERVICESTATUSMESSAGE_H */
|
#endif /* CHECKRESULTMESSAGE_H */
|
@ -22,7 +22,7 @@
|
|||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
RingBuffer CIB::m_TaskStatistics(15 * 60);
|
RingBuffer CIB::m_TaskStatistics(15 * 60);
|
||||||
boost::signal<void (const ServiceStatusMessage&)> CIB::OnServiceStatusUpdate;
|
boost::signal<void (const CheckResultMessage&)> CIB::OnCheckResultReceived;
|
||||||
|
|
||||||
void CIB::UpdateTaskStatistics(long tv, int num)
|
void CIB::UpdateTaskStatistics(long tv, int num)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
static void UpdateTaskStatistics(long tv, int num);
|
static void UpdateTaskStatistics(long tv, int num);
|
||||||
static int GetTaskStatistics(long timespan);
|
static int GetTaskStatistics(long timespan);
|
||||||
|
|
||||||
static boost::signal<void (const ServiceStatusMessage&)> OnServiceStatusUpdate;
|
static boost::signal<void (const CheckResultMessage&)> OnCheckResultReceived;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RingBuffer m_TaskStatistics;
|
static RingBuffer m_TaskStatistics;
|
||||||
|
@ -93,7 +93,7 @@
|
|||||||
<ClInclude Include="nullchecktask.h" />
|
<ClInclude Include="nullchecktask.h" />
|
||||||
<ClInclude Include="service.h" />
|
<ClInclude Include="service.h" />
|
||||||
<ClInclude Include="servicegroup.h" />
|
<ClInclude Include="servicegroup.h" />
|
||||||
<ClInclude Include="servicestatusmessage.h" />
|
<ClInclude Include="checkresultmessage.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="checkresult.cpp" />
|
<ClCompile Include="checkresult.cpp" />
|
||||||
@ -110,7 +110,7 @@
|
|||||||
<ClCompile Include="nullchecktask.cpp" />
|
<ClCompile Include="nullchecktask.cpp" />
|
||||||
<ClCompile Include="service.cpp" />
|
<ClCompile Include="service.cpp" />
|
||||||
<ClCompile Include="servicegroup.cpp" />
|
<ClCompile Include="servicegroup.cpp" />
|
||||||
<ClCompile Include="servicestatusmessage.cpp" />
|
<ClCompile Include="checkresultmessage.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<ClInclude Include="servicegroup.h">
|
<ClInclude Include="servicegroup.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="servicestatusmessage.h">
|
<ClInclude Include="checkresultmessage.h">
|
||||||
<Filter>Headerdateien</Filter>
|
<Filter>Headerdateien</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="nullchecktask.h">
|
<ClInclude Include="nullchecktask.h">
|
||||||
@ -76,7 +76,7 @@
|
|||||||
<ClCompile Include="servicegroup.cpp">
|
<ClCompile Include="servicegroup.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="servicestatusmessage.cpp">
|
<ClCompile Include="checkresultmessage.cpp">
|
||||||
<Filter>Quelldateien</Filter>
|
<Filter>Quelldateien</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="i2-cib.cpp">
|
<ClCompile Include="i2-cib.cpp">
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "nagioschecktask.h"
|
#include "nagioschecktask.h"
|
||||||
#include "nullchecktask.h"
|
#include "nullchecktask.h"
|
||||||
|
|
||||||
#include "servicestatusmessage.h"
|
#include "checkresultmessage.h"
|
||||||
|
|
||||||
#include "cib.h"
|
#include "cib.h"
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
|||||||
RequestMessage rm;
|
RequestMessage rm;
|
||||||
rm.SetMethod("checker::CheckResult");
|
rm.SetMethod("checker::CheckResult");
|
||||||
|
|
||||||
ServiceStatusMessage params;
|
CheckResultMessage params;
|
||||||
params.SetService(service.GetName());
|
params.SetService(service.GetName());
|
||||||
params.SetCheckResult(result);
|
params.SetCheckResult(result);
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ void CIBSyncComponent::Start(void)
|
|||||||
boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3));
|
boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3));
|
||||||
|
|
||||||
/* service status */
|
/* service status */
|
||||||
m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus",
|
m_Endpoint->RegisterTopicHandler("checker::CheckResult",
|
||||||
boost::bind(&CIBSyncComponent::ServiceStatusRequestHandler, _2, _3));
|
boost::bind(&CIBSyncComponent::CheckResultRequestHandler, _2, _3));
|
||||||
|
|
||||||
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
||||||
}
|
}
|
||||||
@ -77,14 +77,12 @@ void CIBSyncComponent::Stop(void)
|
|||||||
endpointManager->UnregisterEndpoint(m_Endpoint);
|
endpointManager->UnregisterEndpoint(m_Endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
void CIBSyncComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
||||||
{
|
{
|
||||||
ServiceStatusMessage params;
|
CheckResultMessage params;
|
||||||
if (!request.GetParams(¶ms))
|
if (!request.GetParams(¶ms))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CIB::OnServiceStatusUpdate(params);
|
|
||||||
|
|
||||||
string svcname;
|
string svcname;
|
||||||
if (!params.GetService(&svcname))
|
if (!params.GetService(&svcname))
|
||||||
return;
|
return;
|
||||||
@ -92,8 +90,11 @@ void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender,
|
|||||||
Service service = Service::GetByName(svcname);
|
Service service = Service::GetByName(svcname);
|
||||||
|
|
||||||
CheckResult cr;
|
CheckResult cr;
|
||||||
if (params.GetCheckResult(&cr))
|
if (!params.GetCheckResult(&cr))
|
||||||
service.ApplyCheckResult(cr);
|
return;
|
||||||
|
|
||||||
|
CIB::OnCheckResultReceived(params);
|
||||||
|
service.ApplyCheckResult(cr);
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
|
@ -37,7 +37,7 @@ private:
|
|||||||
VirtualEndpoint::Ptr m_Endpoint;
|
VirtualEndpoint::Ptr m_Endpoint;
|
||||||
bool m_SyncingConfig;
|
bool m_SyncingConfig;
|
||||||
|
|
||||||
static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
|
static void CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
|
||||||
|
|
||||||
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
|
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
|
||||||
void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
|
void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
|
||||||
|
@ -43,8 +43,6 @@ void DelegationComponent::Start(void)
|
|||||||
m_Endpoint = boost::make_shared<VirtualEndpoint>();
|
m_Endpoint = boost::make_shared<VirtualEndpoint>();
|
||||||
m_Endpoint->RegisterPublication("checker::AssignService");
|
m_Endpoint->RegisterPublication("checker::AssignService");
|
||||||
m_Endpoint->RegisterPublication("checker::ClearServices");
|
m_Endpoint->RegisterPublication("checker::ClearServices");
|
||||||
m_Endpoint->RegisterTopicHandler("checker::CheckResult",
|
|
||||||
boost::bind(&DelegationComponent::CheckResultRequestHandler, this, _2, _3));
|
|
||||||
m_Endpoint->RegisterPublication("delegation::ServiceStatus");
|
m_Endpoint->RegisterPublication("delegation::ServiceStatus");
|
||||||
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
||||||
|
|
||||||
@ -295,27 +293,4 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||||||
Logger::Write(LogInformation, "delegation", msgbuf.str());
|
Logger::Write(LogInformation, "delegation", msgbuf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
|
|
||||||
{
|
|
||||||
ServiceStatusMessage params;
|
|
||||||
if (!request.GetParams(¶ms))
|
|
||||||
return;
|
|
||||||
|
|
||||||
string svcname;
|
|
||||||
if (!params.GetService(&svcname))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Service service = Service::GetByName(svcname);
|
|
||||||
|
|
||||||
/* validate that this is an authentic check result */
|
|
||||||
if (!service.IsAllowedChecker(sender->GetIdentity()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* send state update */
|
|
||||||
RequestMessage rm;
|
|
||||||
rm.SetMethod("delegation::ServiceStatus");
|
|
||||||
rm.SetParams(params);
|
|
||||||
EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, rm);
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPORT_COMPONENT(delegation, DelegationComponent);
|
EXPORT_COMPONENT(delegation, DelegationComponent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user