boost::bind(&ReplicationComponent::RemoteObjectRemovedHandler, this, _3));
/* service status */
- m_Endpoint->RegisterTopicHandler("checker::ServiceStateChange",
- boost::bind(&ReplicationComponent::ServiceStateChangeRequestHandler, _3));
+ m_Endpoint->RegisterTopicHandler("checker::CheckResult",
+ boost::bind(&ReplicationComponent::CheckResultRequestHandler, _3));
}
/**
m_Endpoint->Unregister();
}
-void ReplicationComponent::ServiceStateChangeRequestHandler(const RequestMessage& request)
+void ReplicationComponent::CheckResultRequestHandler(const RequestMessage& request)
{
- ServiceStateChangeMessage params;
+ CheckResultMessage params;
if (!request.GetParams(¶ms))
return;
- String svcname;
- if (!params.GetService(&svcname))
- return;
-
+ String svcname = params.GetService();
Service::Ptr service = Service::GetByName(svcname);
- //CheckResult cr;
- //if (!params.GetCheckResult(&cr))
- // return;
+ Service::OnCheckResultReceived(service, params);
- //Service::OnCheckResultReceived(service, params);
- //service->ApplyCheckResult(cr);
+ Dictionary::Ptr cr = params.GetCheckResult();
+ if (!cr)
+ return;
- Dictionary::Ptr cr = service->GetLastCheckResult();
- if (cr) {
- Value active = cr->Get("active");
+ Value active = cr->Get("active");
- time_t ts;
- Value schedule_end = cr->Get("schedule_end");
+ time_t ts;
+ Value schedule_end = cr->Get("schedule_end");
- if (!schedule_end.IsEmpty())
- ts = static_cast<time_t>(schedule_end);
- else
- ts = static_cast<time_t>(Utility::GetTime());
+ if (!schedule_end.IsEmpty())
+ ts = static_cast<time_t>(schedule_end);
+ else
+ ts = static_cast<time_t>(Utility::GetTime());
- if (active.IsEmpty() || static_cast<long>(active))
- CIB::UpdateActiveChecksStatistics(ts, 1);
- else
- CIB::UpdatePassiveChecksStatistics(ts, 1);
- }
+ if (active.IsEmpty() || static_cast<long>(active))
+ CIB::UpdateActiveChecksStatistics(ts, 1);
+ else
+ CIB::UpdatePassiveChecksStatistics(ts, 1);
}
void ReplicationComponent::EndpointConnectedHandler(const Endpoint::Ptr& endpoint)
private:
Endpoint::Ptr m_Endpoint;
- static void ServiceStateChangeRequestHandler(const RequestMessage& request);
+ static void CheckResultRequestHandler(const RequestMessage& request);
void EndpointConnectedHandler(const Endpoint::Ptr& endpoint);
libicinga_la_SOURCES = \
acknowledgement.h \
+ checkresultmessage.cpp \
+ checkresultmessage.h \
cib.cpp \
cib.h \
commentprocessor.cpp \
servicegroup.cpp \
servicegroup.h \
service.h \
- servicestatechangemessage.cpp \
- servicestatechangemessage.h \
timeperiod.cpp \
timeperiod.h
using namespace icinga;
-bool ServiceStateChangeMessage::GetService(String *service) const
+String CheckResultMessage::GetService(void) const
{
- return Get("service", service);
+ String service;
+ Get("service", &service);
+ return service;
}
-void ServiceStateChangeMessage::SetService(const String& service)
+void CheckResultMessage::SetService(const String& service)
{
Set("service", service);
}
+Dictionary::Ptr CheckResultMessage::GetCheckResult(void) const
+{
+ Dictionary::Ptr cr;
+ Get("check_result", &cr);
+ return cr;
+}
+
+void CheckResultMessage::SetCheckResult(const Dictionary::Ptr& result)
+{
+ Set("check_result", result);
+}
+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#ifndef SERVICESTATECHANGEMESSAGE_H
-#define SERVICESTATECHANGEMESSAGE_H
+#ifndef CHECKRESULTMESSAGE_H
+#define CHECKRESULTMESSAGE_H
namespace icinga
{
*
* @ingroup icinga
*/
-class I2_ICINGA_API ServiceStateChangeMessage : public MessagePart
+class I2_ICINGA_API CheckResultMessage : public MessagePart
{
public:
- ServiceStateChangeMessage(void) : MessagePart() { }
- ServiceStateChangeMessage(const MessagePart& message) : MessagePart(message) { }
+ CheckResultMessage(void) : MessagePart() { }
+ CheckResultMessage(const MessagePart& message) : MessagePart(message) { }
- bool GetService(String *service) const;
+ String GetService(void) const;
void SetService(const String& service);
+
+ Dictionary::Ptr GetCheckResult(void) const;
+ void SetCheckResult(const Dictionary::Ptr& result);
};
}
-#endif /* SERVICESTATECHANGEMESSAGE_H */
+#endif /* CHECKRESULTMESSAGE_H */
#include "pluginchecktask.h"
#include "nullchecktask.h"
-#include "servicestatechangemessage.h"
+#include "checkresultmessage.h"
#include "cib.h"
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="checkresultmessage.cpp" />
<ClCompile Include="cib.cpp" />
<ClCompile Include="commentprocessor.cpp" />
<ClCompile Include="downtimeprocessor.cpp" />
<ClCompile Include="nullchecktask.cpp" />
<ClCompile Include="service.cpp" />
<ClCompile Include="servicegroup.cpp" />
- <ClCompile Include="servicestatechangemessage.cpp" />
<ClCompile Include="timeperiod.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="nullchecktask.h" />
<ClInclude Include="service.h" />
<ClInclude Include="servicegroup.h" />
- <ClInclude Include="servicestatechangemessage.h" />
<ClInclude Include="timeperiod.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
ApplyCheckResult(cr);
/* flush the current transaction so other instances see the service's
- * new state when they receive the ServiceStateChange message */
+ * new state when they receive the CheckResult message */
DynamicObject::FlushTx();
RequestMessage rm;
- rm.SetMethod("checker::ServiceStateChange");
+ rm.SetMethod("checker::CheckResult");
/* TODO: add _old_ state to message */
- ServiceStateChangeMessage params;
+ CheckResultMessage params;
params.SetService(GetName());
+ params.SetCheckResult(cr);
rm.SetParams(params);
EndpointManager::GetInstance()->SendMulticastMessage(rm);
}
+
};
class CheckResultMessage;
-class ServiceStatusMessage;
/**
* An Icinga service.
template<typename T>
bool Get(String key, T *value) const
{
- Value v =GetDictionary()->Get(key);
+ Value v = GetDictionary()->Get(key);
if (v.IsEmpty())
return false;