[icinga-checkins] icinga.org: icinga2/master: GelfWriter: Change _state to human-readable string

git at icinga.org git at icinga.org
Wed Nov 12 17:58:31 CET 2014


Module: icinga2
Branch: master
Commit: 43267d77592083eb8944e5a08017562ab84d1df6
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=43267d77592083eb8944e5a08017562ab84d1df6

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Wed Nov 12 17:58:13 2014 +0100

GelfWriter: Change _state to human-readable string

refs #7619

---

 lib/perfdata/gelfwriter.cpp |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp
index 404dbef..32a1e2f 100644
--- a/lib/perfdata/gelfwriter.cpp
+++ b/lib/perfdata/gelfwriter.cpp
@@ -100,7 +100,7 @@ void GelfWriter::CheckResultHandler(const Checkable::Ptr& checkable, const Check
 
 	fields->Set("_hostname", host->GetName());
 	fields->Set("_type", "CHECK RESULT");
-	fields->Set("_state", service ? static_cast<int>(service->GetState()) : static_cast<int>(host->GetState()));
+	fields->Set("_state", service ? Service::StateToString(service->GetState()) : Host::StateToString(host->GetState()));
 
 	fields->Set("_current_check_attempt", checkable->GetCheckAttempt());
 	fields->Set("_max_check_attempts", checkable->GetMaxCheckAttempts());
@@ -151,7 +151,7 @@ void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification
 		fields->Set("short_message", "(" << (host->IsReachable() ? Host::StateToString(host->GetState()) : "UNREACHABLE") << ")");
 	}
 
-	fields->Set("_state", service ? static_cast<int>(service->GetState()) : static_cast<int>(host->GetState()));
+	fields->Set("_state", service ? Service::StateToString(service->GetState()) : Host::StateToString(host->GetState()));
 
 	fields->Set("_hostname", host->GetName());
 	fields->Set("_command", command_name);
@@ -174,7 +174,7 @@ void GelfWriter::StateChangeHandler(const Checkable::Ptr& checkable, const Check
 
 	Dictionary::Ptr fields = new Dictionary();
 
-	fields->Set("_state", service ? static_cast<int>(service->GetState()) : static_cast<int>(host->GetState()));
+	fields->Set("_state", service ? Service::StateToString(service->GetState()) : Host::StateToString(host->GetState()));
 	fields->Set("_type", "STATE CHANGE");
 	fields->Set("_current_check_attempt", checkable->GetCheckAttempt());
 	fields->Set("_max_check_attempts", checkable->GetMaxCheckAttempts());



More information about the icinga-checkins mailing list