void ConfigObject::SetCommitTimestamp(time_t ts)
{
- GetProperties()->SetProperty("__tx", ts);
+ GetProperties()->SetProperty("__tx", static_cast<long>(ts));
}
time_t ConfigObject::GetCommitTimestamp(void) const
service.cpp \
service.h \
servicegroup.cpp \
- servicegroup.h
+ servicegroup.h \
+ servicestatusmessage.cpp \
+ servicestatusmessage.h
libcib_la_CPPFLAGS = \
-DI2_CIB_BUILD \
using namespace icinga;
+CheckResult::CheckResult(void)
+ : MessagePart()
+{ }
+
+CheckResult::CheckResult(const MessagePart& message)
+ : MessagePart(message)
+{ }
+
void CheckResult::SetScheduleStart(time_t ts)
{
SetProperty("schedule_start", static_cast<long>(ts));
class I2_CIB_API CheckResult : public MessagePart
{
public:
- CheckResult(void) : MessagePart() { }
- CheckResult(const MessagePart& message) : MessagePart(message) { }
+ CheckResult(void);
+ CheckResult(const MessagePart& message);
void SetScheduleStart(time_t ts);
time_t GetScheduleStart(void) const;
<ClInclude Include="nagioschecktask.h" />
<ClInclude Include="service.h" />
<ClInclude Include="servicegroup.h" />
+ <ClInclude Include="servicestatusmessage.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="checkresult.cpp" />
<ClCompile Include="nagioschecktask.cpp" />
<ClCompile Include="service.cpp" />
<ClCompile Include="servicegroup.cpp" />
+ <ClCompile Include="servicestatusmessage.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
#include "checktask.h"
#include "nagioschecktask.h"
+#include "servicestatusmessage.h"
+
#endif /* I2CIB_H */
return value;
}
-long Service::GetFreshnessInterval(void) const
-{
- long value;
- if (!GetConfigObject()->GetProperty("freshness_interval", &value));
- value = GetCheckInterval() * 3;
-
- return value;
-}
-
Dictionary::Ptr Service::GetDependencies(void) const
{
Dictionary::Ptr value;
long GetMaxCheckAttempts(void) const;
long GetCheckInterval(void) const;
long GetRetryInterval(void) const;
- long GetFreshnessInterval(void) const;
Dictionary::Ptr GetDependencies(void) const;
Dictionary::Ptr GetGroups(void) const;
Dictionary::Ptr GetCheckers(void) const;
--- /dev/null
+#include "i2-cib.h"
+
+using namespace icinga;
+
+bool ServiceStatusMessage::GetService(string *service) const
+{
+ return GetProperty("service", service);
+}
+
+void ServiceStatusMessage::SetService(const string& service)
+{
+ SetProperty("service", service);
+}
+
+bool ServiceStatusMessage::GetState(ServiceState *state) const
+{
+ long value;
+ if (GetProperty("state", &value)) {
+ *state = static_cast<ServiceState>(value);
+ return true;
+ }
+ return false;
+}
+
+void ServiceStatusMessage::SetState(ServiceState state)
+{
+ SetProperty("state", static_cast<long>(state));
+}
+
+bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
+{
+ long value;
+ if (GetProperty("state_type", &value)) {
+ *type = static_cast<ServiceStateType>(value);
+ return true;
+ }
+ return false;
+}
+
+void ServiceStatusMessage::SetStateType(ServiceStateType type)
+{
+ SetProperty("state_type", static_cast<long>(type));
+}
+
+bool ServiceStatusMessage::GetCurrentCheckAttempt(long *attempt) const
+{
+ return GetProperty("current_attempt", attempt);
+}
+
+void ServiceStatusMessage::SetCurrentCheckAttempt(long attempt)
+{
+ SetProperty("current_attempt", attempt);
+}
+
+bool ServiceStatusMessage::GetNextCheck(time_t *ts) const
+{
+ long value;
+ if (GetProperty("next_check", &value)) {
+ *ts = value;
+ return true;
+ }
+ return false;
+}
+
+void ServiceStatusMessage::SetNextCheck(time_t ts)
+{
+ SetProperty("next_check", static_cast<long>(ts));
+}
+
+bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
+{
+ Dictionary::Ptr obj;
+ if (GetProperty("result", &obj)) {
+ *cr = CheckResult(MessagePart(obj));
+ return true;
+ }
+ return false;
+}
+
+void ServiceStatusMessage::SetCheckResult(CheckResult cr)
+{
+ SetProperty("result", cr.GetDictionary());
+}
\ No newline at end of file
--- /dev/null
+#ifndef SERVICESTATUSMESSAGE_H
+#define SERVICESTATUSMESSAGE_H
+
+namespace icinga
+{
+
+class I2_CIB_API ServiceStatusMessage : public MessagePart
+{
+public:
+ ServiceStatusMessage(void) : MessagePart() { }
+ ServiceStatusMessage(const MessagePart& message) : MessagePart(message) { }
+
+ 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 GetCurrentCheckAttempt(long *attempt) const;
+ void SetCurrentCheckAttempt(long attempt);
+
+ bool GetNextCheck(time_t *ts) const;
+ void SetNextCheck(time_t ts);
+
+ bool GetCheckResult(CheckResult *cr) const;
+ void SetCheckResult(CheckResult cr);
+};
+
+}
+
+#endif /* SERVICESTATUSMESSAGE_H */
RequestMessage rm;
rm.SetMethod("checker::CheckResult");
- MessagePart params;
- params.SetProperty("service", service.GetName());
- params.SetProperty("state", static_cast<long>(service.GetState()));
- params.SetProperty("state_type", static_cast<long>(service.GetStateType()));
- params.SetProperty("current_attempt", static_cast<long>(service.GetCurrentCheckAttempt()));
- params.SetProperty("next_check", static_cast<long>(service.GetNextCheck()));
- params.SetProperty("result", result.GetDictionary());
+ ServiceStatusMessage params;
+ params.SetService(service.GetName());
+ params.SetState(service.GetState());
+ params.SetStateType(service.GetStateType());
+ params.SetCurrentCheckAttempt(service.GetCurrentCheckAttempt());
+ params.SetNextCheck(service.GetNextCheck());
+ params.SetCheckResult(result);
rm.SetParams(params);
m_SyncingConfig = true;
object->Unregister();
m_SyncingConfig = false;
- } catch (const std::exception& ex) {
+ } catch (const std::exception&) {
m_SyncingConfig = false;
throw;
}
void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
{
- MessagePart params;
+ ServiceStatusMessage params;
if (!request.GetParams(¶ms))
return;
string svcname;
- if (!params.GetProperty("service", &svcname))
+ if (params.GetService(&svcname))
return;
Service service = Service::GetByName(svcname);
#include "i2-discovery.h"
using namespace icinga;
+
+DiscoveryMessage::DiscoveryMessage(void)
+ : MessagePart()
+{ }
+
+DiscoveryMessage::DiscoveryMessage(const MessagePart& message)
+ : MessagePart(message)
+{ }
+
+bool DiscoveryMessage::GetIdentity(string *value) const
+{
+ return GetProperty("identity", value);
+}
+
+void DiscoveryMessage::SetIdentity(const string& value)
+{
+ SetProperty("identity", value);
+}
+
+bool DiscoveryMessage::GetNode(string *value) const
+{
+ return GetProperty("node", value);
+}
+
+void DiscoveryMessage::SetNode(const string& value)
+{
+ SetProperty("node", value);
+}
+
+bool DiscoveryMessage::GetService(string *value) const
+{
+ return GetProperty("service", value);
+}
+
+void DiscoveryMessage::SetService(const string& value)
+{
+ SetProperty("service", value);
+}
+
+bool DiscoveryMessage::GetSubscriptions(MessagePart *value) const
+{
+ return GetProperty("subscriptions", value);
+}
+
+void DiscoveryMessage::SetSubscriptions(MessagePart value)
+{
+ SetProperty("subscriptions", value);
+}
+
+bool DiscoveryMessage::GetPublications(MessagePart *value) const
+{
+ return GetProperty("publications", value);
+}
+
+void DiscoveryMessage::SetPublications(MessagePart value)
+{
+ SetProperty("publications", value);
+}
\ No newline at end of file
*/
class DiscoveryMessage : public MessagePart
{
-
public:
- DiscoveryMessage(void) : MessagePart() { }
- DiscoveryMessage(const MessagePart& message) : MessagePart(message) { }
-
- inline bool GetIdentity(string *value) const
- {
- return GetProperty("identity", value);
- }
-
- inline void SetIdentity(const string& value)
- {
- SetProperty("identity", value);
- }
-
- inline bool GetNode(string *value) const
- {
- return GetProperty("node", value);
- }
-
- inline void SetNode(const string& value)
- {
- SetProperty("node", value);
- }
-
- inline bool GetService(string *value) const
- {
- return GetProperty("service", value);
- }
+ DiscoveryMessage(void);
+ DiscoveryMessage(const MessagePart& message);
- inline void SetService(const string& value)
- {
- SetProperty("service", value);
- }
+ bool GetIdentity(string *value) const;
+ void SetIdentity(const string& value);
- inline bool GetSubscriptions(MessagePart *value) const
- {
- return GetProperty("subscriptions", value);
- }
+ bool GetNode(string *value) const;
+ void SetNode(const string& value);
- inline void SetSubscriptions(MessagePart value)
- {
- SetProperty("subscriptions", value);
- }
+ bool GetService(string *value) const;
+ void SetService(const string& value);
- inline bool GetPublications(MessagePart *value) const
- {
- return GetProperty("publications", value);
- }
+ bool GetSubscriptions(MessagePart *value) const;
+ void SetSubscriptions(MessagePart value);
- inline void SetPublications(MessagePart value)
- {
- SetProperty("publications", value);
- }
+ bool GetPublications(MessagePart *value) const;
+ void SetPublications(MessagePart value);
};
}