mirror of https://github.com/Icinga/icinga2.git
Move CompatUtility::GetHostStateString() logic into DB IDO and CompatLogger features
This commit is contained in:
parent
5222f7d058
commit
7a012c062a
|
@ -142,7 +142,7 @@ void CompatLogger::CheckResultHandler(const Checkable::Ptr& checkable, const Che
|
|||
|
||||
msgbuf << "HOST ALERT: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< attempt_after << ";"
|
||||
<< output << ""
|
||||
|
@ -258,7 +258,7 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||
if (service)
|
||||
notification_type_str = Service::StateToString(service->GetState());
|
||||
else
|
||||
notification_type_str = CompatUtility::GetHostStateString(host);
|
||||
notification_type_str = GetHostStateString(host);
|
||||
}
|
||||
|
||||
String author_comment = "";
|
||||
|
@ -290,7 +290,7 @@ void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification
|
|||
<< user->GetName() << ";"
|
||||
<< host->GetName() << ";"
|
||||
<< notification_type_str << " "
|
||||
<< "(" << CompatUtility::GetHostStateString(host) << ");"
|
||||
<< "(" << GetHostStateString(host) << ");"
|
||||
<< command_name << ";"
|
||||
<< output << ";"
|
||||
<< author_comment
|
||||
|
@ -422,7 +422,7 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||
} else {
|
||||
msgbuf << "HOST EVENT HANDLER: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< current_attempt << ";"
|
||||
<< event_command_name;
|
||||
|
@ -435,6 +435,14 @@ void CompatLogger::EventCommandHandler(const Checkable::Ptr& checkable)
|
|||
}
|
||||
}
|
||||
|
||||
String CompatLogger::GetHostStateString(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return "UNREACHABLE"; /* hardcoded compat state */
|
||||
|
||||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
void CompatLogger::WriteLine(const String& line)
|
||||
{
|
||||
ASSERT(OwnsLock());
|
||||
|
@ -499,7 +507,7 @@ void CompatLogger::ReopenFile(bool rotate)
|
|||
std::ostringstream msgbuf;
|
||||
msgbuf << "CURRENT HOST STATE: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< host->GetCheckAttempt() << ";"
|
||||
<< output << "";
|
||||
|
|
|
@ -62,6 +62,8 @@ private:
|
|||
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
||||
void EventCommandHandler(const Checkable::Ptr& service);
|
||||
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
|
||||
Timer::Ptr m_RotationTimer;
|
||||
void RotationTimerHandler();
|
||||
void ScheduleNextRotation();
|
||||
|
|
|
@ -1025,7 +1025,7 @@ void DbEvents::AddCheckResultLogHistory(const Checkable::Ptr& checkable, const C
|
|||
} else {
|
||||
msgbuf << "HOST ALERT: "
|
||||
<< host->GetName() << ";"
|
||||
<< CompatUtility::GetHostStateString(host) << ";"
|
||||
<< GetHostStateString(host) << ";"
|
||||
<< Host::StateTypeToString(host->GetStateType()) << ";"
|
||||
<< attempt_after << ";"
|
||||
<< output << ""
|
||||
|
@ -1522,6 +1522,14 @@ int DbEvents::GetHostState(const Host::Ptr& host)
|
|||
return currentState;
|
||||
}
|
||||
|
||||
String DbEvents::GetHostStateString(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return "UNREACHABLE"; /* hardcoded compat state */
|
||||
|
||||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
std::pair<unsigned long, unsigned long> DbEvents::ConvertTimestamp(double time)
|
||||
{
|
||||
unsigned long time_sec = static_cast<long>(time);
|
||||
|
|
|
@ -134,6 +134,7 @@ private:
|
|||
static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled);
|
||||
|
||||
static int GetHostState(const Host::Ptr& host);
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
||||
static int MapNotificationReasonType(NotificationType type);
|
||||
static int MapExternalCommandType(const String& name);
|
||||
|
|
|
@ -81,15 +81,6 @@ String CompatUtility::GetCommandName(const Command::Ptr& command)
|
|||
return GetCommandNamePrefix(command) + command->GetName();
|
||||
}
|
||||
|
||||
/* Used in StatusDataWriter and DB IDO. */
|
||||
String CompatUtility::GetHostStateString(const Host::Ptr& host)
|
||||
{
|
||||
if (host->GetState() != HostUp && !host->IsReachable())
|
||||
return "UNREACHABLE"; /* hardcoded compat state */
|
||||
|
||||
return Host::StateToString(host->GetState());
|
||||
}
|
||||
|
||||
/* Used in DB IDO, StatusDataWriter and Livestatus. */
|
||||
String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
|
||||
{
|
||||
|
|
|
@ -39,9 +39,6 @@ public:
|
|||
static String GetCommandLine(const Command::Ptr& command);
|
||||
static String GetCommandName(const Command::Ptr& command);
|
||||
|
||||
/* host */
|
||||
static String GetHostStateString(const Host::Ptr& host);
|
||||
|
||||
/* service */
|
||||
static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
|
||||
|
||||
|
|
Loading…
Reference in New Issue