]> granicus.if.org Git - icinga2/commitdiff
GelfWriter: Add 'source' configuration attribute
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 11 Nov 2014 13:05:28 +0000 (14:05 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 11 Nov 2014 13:16:48 +0000 (14:16 +0100)
refs #7619

lib/perfdata/gelfwriter.cpp
lib/perfdata/gelfwriter.ti
lib/perfdata/perfdata-type.conf

index 4bcc06316d58da685543c6abb3f3b52b38d7ec27..9e6bdb95fd273b31361498b0f38e1cf1d41824fd 100644 (file)
@@ -79,6 +79,9 @@ void GelfWriter::CheckResultHandler(const Checkable::Ptr& checkable, const Check
 {
        CONTEXT("GELF Processing check result for '" + checkable->GetName() + "'");
 
+       Log(LogDebug, "GelfWriter")
+           << "GELF Processing check result for '" << checkable->GetName() << "'";
+
        Dictionary::Ptr fields = new Dictionary();
        Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
        Host::Ptr host;
@@ -94,7 +97,7 @@ void GelfWriter::CheckResultHandler(const Checkable::Ptr& checkable, const Check
        fields->Set("short_message", cr->GetOutput());
        fields->Set("_type", "CHECK RESULT");
 
-       SendLogMessage(ComposeGelfMessage(fields, "icinga"));
+       SendLogMessage(ComposeGelfMessage(fields, GetSource()));
 }
 
 void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
@@ -134,7 +137,7 @@ void GelfWriter::NotificationToUserHandler(const Notification::Ptr& notification
        fields->Set("_state", notification_type_str);
        fields->Set("_comment", author_comment);
 
-       SendLogMessage(ComposeGelfMessage(fields, "icinga"));
+       SendLogMessage(ComposeGelfMessage(fields, GetSource()));
 }
 
 void GelfWriter::StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type)
@@ -165,7 +168,7 @@ void GelfWriter::StateChangeHandler(const Checkable::Ptr& checkable, const Check
                fields->Set("_check_source", cr->GetCheckSource());
        }
 
-       SendLogMessage(ComposeGelfMessage(fields, "icinga"));
+       SendLogMessage(ComposeGelfMessage(fields, GetSource()));
 }
 
 String GelfWriter::ComposeGelfMessage(const Dictionary::Ptr& fields, const String& source)
index a3c49ab79b003f220530d49d8576253217ba64dd..f5e4d20de22dc561bbe4975cf388d5b107e2b7b8 100644 (file)
@@ -30,6 +30,9 @@ class GelfWriter : DynamicObject
        [config] String port {
                default {{{ return "12201"; }}}
        };
+       [config] String source {
+               default {{{ return "icinga2"; }}}
+       };
 };
 
 }
index d5bdff5b658a039d6b57e4a819b0555d8acf94aa..611c89591ece06c9104b25623d5faba54bd36018 100644 (file)
@@ -36,6 +36,7 @@
 
 %type GelfWriter {
         %attribute %string "host",
-        %attribute %string "port"
+        %attribute %string "port",
+        %attribute %string "source"
 }