mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +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 = \
|
||||
checkresult.cpp \
|
||||
checkresult.h \
|
||||
checkresultmessage.cpp \
|
||||
checkresultmessage.h \
|
||||
cib.cpp \
|
||||
cib.h \
|
||||
configobjectadapter.cpp \
|
||||
@ -24,9 +26,7 @@ libcib_la_SOURCES = \
|
||||
service.cpp \
|
||||
service.h \
|
||||
servicegroup.cpp \
|
||||
servicegroup.h \
|
||||
servicestatusmessage.cpp \
|
||||
servicestatusmessage.h
|
||||
servicegroup.h
|
||||
|
||||
libcib_la_CPPFLAGS = \
|
||||
-DI2_CIB_BUILD \
|
||||
|
@ -21,47 +21,17 @@
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
bool ServiceStatusMessage::GetService(string *service) const
|
||||
bool CheckResultMessage::GetService(string *service) const
|
||||
{
|
||||
return Get("service", service);
|
||||
}
|
||||
|
||||
void ServiceStatusMessage::SetService(const string& service)
|
||||
void CheckResultMessage::SetService(const string& service)
|
||||
{
|
||||
Set("service", service);
|
||||
}
|
||||
|
||||
bool ServiceStatusMessage::GetState(ServiceState *state) 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
|
||||
bool CheckResultMessage::GetCheckResult(CheckResult *cr) const
|
||||
{
|
||||
Dictionary::Ptr obj;
|
||||
if (Get("result", &obj)) {
|
||||
@ -71,7 +41,7 @@ bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServiceStatusMessage::SetCheckResult(CheckResult cr)
|
||||
void CheckResultMessage::SetCheckResult(CheckResult cr)
|
||||
{
|
||||
Set("result", cr.GetDictionary());
|
||||
}
|
@ -17,13 +17,13 @@
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SERVICESTATUSMESSAGE_H
|
||||
#define SERVICESTATUSMESSAGE_H
|
||||
#ifndef CHECKRESULTMESSAGE_H
|
||||
#define CHECKRESULTMESSAGE_H
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
||||
class I2_CIB_API ServiceStatusMessage : public MessagePart
|
||||
class I2_CIB_API CheckResultMessage : public MessagePart
|
||||
{
|
||||
public:
|
||||
ServiceStatusMessage(void) : MessagePart() { }
|
||||
@ -32,16 +32,10 @@ public:
|
||||
bool GetService(string *service) const;
|
||||
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;
|
||||
void SetCheckResult(CheckResult cr);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SERVICESTATUSMESSAGE_H */
|
||||
#endif /* CHECKRESULTMESSAGE_H */
|
@ -22,7 +22,7 @@
|
||||
using namespace icinga;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
static void UpdateTaskStatistics(long tv, int num);
|
||||
static int GetTaskStatistics(long timespan);
|
||||
|
||||
static boost::signal<void (const ServiceStatusMessage&)> OnServiceStatusUpdate;
|
||||
static boost::signal<void (const CheckResultMessage&)> OnCheckResultReceived;
|
||||
|
||||
private:
|
||||
static RingBuffer m_TaskStatistics;
|
||||
|
@ -93,7 +93,7 @@
|
||||
<ClInclude Include="nullchecktask.h" />
|
||||
<ClInclude Include="service.h" />
|
||||
<ClInclude Include="servicegroup.h" />
|
||||
<ClInclude Include="servicestatusmessage.h" />
|
||||
<ClInclude Include="checkresultmessage.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="checkresult.cpp" />
|
||||
@ -110,9 +110,9 @@
|
||||
<ClCompile Include="nullchecktask.cpp" />
|
||||
<ClCompile Include="service.cpp" />
|
||||
<ClCompile Include="servicegroup.cpp" />
|
||||
<ClCompile Include="servicestatusmessage.cpp" />
|
||||
<ClCompile Include="checkresultmessage.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -41,7 +41,7 @@
|
||||
<ClInclude Include="servicegroup.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="servicestatusmessage.h">
|
||||
<ClInclude Include="checkresultmessage.h">
|
||||
<Filter>Headerdateien</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nullchecktask.h">
|
||||
@ -76,7 +76,7 @@
|
||||
<ClCompile Include="servicegroup.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="servicestatusmessage.cpp">
|
||||
<ClCompile Include="checkresultmessage.cpp">
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2-cib.cpp">
|
||||
@ -86,4 +86,4 @@
|
||||
<Filter>Quelldateien</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "nagioschecktask.h"
|
||||
#include "nullchecktask.h"
|
||||
|
||||
#include "servicestatusmessage.h"
|
||||
#include "checkresultmessage.h"
|
||||
|
||||
#include "cib.h"
|
||||
|
||||
|
@ -110,7 +110,7 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
|
||||
RequestMessage rm;
|
||||
rm.SetMethod("checker::CheckResult");
|
||||
|
||||
ServiceStatusMessage params;
|
||||
CheckResultMessage params;
|
||||
params.SetService(service.GetName());
|
||||
params.SetCheckResult(result);
|
||||
|
||||
|
@ -60,8 +60,8 @@ void CIBSyncComponent::Start(void)
|
||||
boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3));
|
||||
|
||||
/* service status */
|
||||
m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus",
|
||||
boost::bind(&CIBSyncComponent::ServiceStatusRequestHandler, _2, _3));
|
||||
m_Endpoint->RegisterTopicHandler("checker::CheckResult",
|
||||
boost::bind(&CIBSyncComponent::CheckResultRequestHandler, _2, _3));
|
||||
|
||||
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
||||
}
|
||||
@ -77,14 +77,12 @@ void CIBSyncComponent::Stop(void)
|
||||
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))
|
||||
return;
|
||||
|
||||
CIB::OnServiceStatusUpdate(params);
|
||||
|
||||
string svcname;
|
||||
if (!params.GetService(&svcname))
|
||||
return;
|
||||
@ -92,8 +90,11 @@ void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender,
|
||||
Service service = Service::GetByName(svcname);
|
||||
|
||||
CheckResult cr;
|
||||
if (params.GetCheckResult(&cr))
|
||||
service.ApplyCheckResult(cr);
|
||||
if (!params.GetCheckResult(&cr))
|
||||
return;
|
||||
|
||||
CIB::OnCheckResultReceived(params);
|
||||
service.ApplyCheckResult(cr);
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
@ -37,7 +37,7 @@ private:
|
||||
VirtualEndpoint::Ptr m_Endpoint;
|
||||
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 SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
|
||||
|
@ -43,8 +43,6 @@ void DelegationComponent::Start(void)
|
||||
m_Endpoint = boost::make_shared<VirtualEndpoint>();
|
||||
m_Endpoint->RegisterPublication("checker::AssignService");
|
||||
m_Endpoint->RegisterPublication("checker::ClearServices");
|
||||
m_Endpoint->RegisterTopicHandler("checker::CheckResult",
|
||||
boost::bind(&DelegationComponent::CheckResultRequestHandler, this, _2, _3));
|
||||
m_Endpoint->RegisterPublication("delegation::ServiceStatus");
|
||||
EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
|
||||
|
||||
@ -295,27 +293,4 @@ void DelegationComponent::DelegationTimerHandler(void)
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user