mirror of https://github.com/Icinga/icinga2.git
Implemented ServiceStatusMessage class.
This commit is contained in:
parent
5dc74ecf0e
commit
d577406a66
|
@ -101,7 +101,7 @@ string ConfigObject::GetSource(void) const
|
|||
|
||||
void ConfigObject::SetCommitTimestamp(time_t ts)
|
||||
{
|
||||
GetProperties()->SetProperty("__tx", ts);
|
||||
GetProperties()->SetProperty("__tx", static_cast<long>(ts));
|
||||
}
|
||||
|
||||
time_t ConfigObject::GetCommitTimestamp(void) const
|
||||
|
|
|
@ -24,7 +24,9 @@ libcib_la_SOURCES = \
|
|||
service.cpp \
|
||||
service.h \
|
||||
servicegroup.cpp \
|
||||
servicegroup.h
|
||||
servicegroup.h \
|
||||
servicestatusmessage.cpp \
|
||||
servicestatusmessage.h
|
||||
|
||||
libcib_la_CPPFLAGS = \
|
||||
-DI2_CIB_BUILD \
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
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));
|
||||
|
|
|
@ -7,8 +7,8 @@ namespace icinga
|
|||
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;
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
<ClInclude Include="nagioschecktask.h" />
|
||||
<ClInclude Include="service.h" />
|
||||
<ClInclude Include="servicegroup.h" />
|
||||
<ClInclude Include="servicestatusmessage.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="checkresult.cpp" />
|
||||
|
@ -103,6 +104,7 @@
|
|||
<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">
|
||||
|
|
|
@ -29,4 +29,6 @@
|
|||
#include "checktask.h"
|
||||
#include "nagioschecktask.h"
|
||||
|
||||
#include "servicestatusmessage.h"
|
||||
|
||||
#endif /* I2CIB_H */
|
||||
|
|
|
@ -84,15 +84,6 @@ long Service::GetRetryInterval(void) const
|
|||
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;
|
||||
|
|
|
@ -40,7 +40,6 @@ public:
|
|||
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;
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#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());
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#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 */
|
|
@ -145,13 +145,13 @@ void CheckerComponent::ResultTimerHandler(void)
|
|||
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);
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
|
|||
m_SyncingConfig = true;
|
||||
object->Unregister();
|
||||
m_SyncingConfig = false;
|
||||
} catch (const std::exception& ex) {
|
||||
} catch (const std::exception&) {
|
||||
m_SyncingConfig = false;
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -292,12 +292,12 @@ void DelegationComponent::DelegationTimerHandler(void)
|
|||
|
||||
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);
|
||||
|
|
|
@ -1,3 +1,61 @@
|
|||
#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);
|
||||
}
|
|
@ -9,60 +9,24 @@ namespace icinga
|
|||
*/
|
||||
class DiscoveryMessage : public MessagePart
|
||||
{
|
||||
|
||||
public:
|
||||
DiscoveryMessage(void) : MessagePart() { }
|
||||
DiscoveryMessage(const MessagePart& message) : MessagePart(message) { }
|
||||
DiscoveryMessage(void);
|
||||
DiscoveryMessage(const MessagePart& message);
|
||||
|
||||
inline bool GetIdentity(string *value) const
|
||||
{
|
||||
return GetProperty("identity", value);
|
||||
}
|
||||
bool GetIdentity(string *value) const;
|
||||
void SetIdentity(const string& value);
|
||||
|
||||
inline void SetIdentity(const string& value)
|
||||
{
|
||||
SetProperty("identity", value);
|
||||
}
|
||||
bool GetNode(string *value) const;
|
||||
void SetNode(const string& value);
|
||||
|
||||
inline bool GetNode(string *value) const
|
||||
{
|
||||
return GetProperty("node", value);
|
||||
}
|
||||
bool GetService(string *value) const;
|
||||
void SetService(const string& value);
|
||||
|
||||
inline void SetNode(const string& value)
|
||||
{
|
||||
SetProperty("node", value);
|
||||
}
|
||||
bool GetSubscriptions(MessagePart *value) const;
|
||||
void SetSubscriptions(MessagePart value);
|
||||
|
||||
inline bool GetService(string *value) const
|
||||
{
|
||||
return GetProperty("service", value);
|
||||
}
|
||||
|
||||
inline void SetService(const string& value)
|
||||
{
|
||||
SetProperty("service", value);
|
||||
}
|
||||
|
||||
inline bool GetSubscriptions(MessagePart *value) const
|
||||
{
|
||||
return GetProperty("subscriptions", value);
|
||||
}
|
||||
|
||||
inline void SetSubscriptions(MessagePart value)
|
||||
{
|
||||
SetProperty("subscriptions", value);
|
||||
}
|
||||
|
||||
inline bool GetPublications(MessagePart *value) const
|
||||
{
|
||||
return GetProperty("publications", value);
|
||||
}
|
||||
|
||||
inline void SetPublications(MessagePart value)
|
||||
{
|
||||
SetProperty("publications", value);
|
||||
}
|
||||
bool GetPublications(MessagePart *value) const;
|
||||
void SetPublications(MessagePart value);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue