[icinga-checkins] icinga.org: icinga2/master: Add check authority to service.

git at icinga.org git at icinga.org
Thu Sep 26 22:43:07 CEST 2013


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

Author: Michael Friedrich <Michael.Friedrich at netways.de>
Date:   Thu Sep 26 21:53:43 2013 +0200

Add check authority to service.

fixes #4762

---

 components/compat/statusdatawriter.cpp |    1 +
 lib/icinga/compatutility.cpp           |    4 ++++
 lib/icinga/service-check.cpp           |    3 +++
 lib/icinga/service.cpp                 |   13 +++++++++++++
 lib/icinga/service.h                   |    4 ++++
 5 files changed, 25 insertions(+)

diff --git a/components/compat/statusdatawriter.cpp b/components/compat/statusdatawriter.cpp
index 0c4bcc1..56a9850 100644
--- a/components/compat/statusdatawriter.cpp
+++ b/components/compat/statusdatawriter.cpp
@@ -334,6 +334,7 @@ void StatusDataWriter::DumpServiceStatusAttrs(std::ostream& fp, const Service::P
 	   << "\t" << "plugin_output=" << attrs->Get("plugin_output") << "\n"
 	   << "\t" << "long_plugin_output=" << attrs->Get("long_plugin_output") << "\n"
 	   << "\t" << "performance_data=" << attrs->Get("performance_data") << "\n"
+	   << "\t" << "check_source=" << attrs->Get("check_source") << "\n"
 	   << "\t" << "last_check=" << static_cast<long>(attrs->Get("last_check")) << "\n"
 	   << "\t" << "next_check=" << static_cast<long>(attrs->Get("next_check")) << "\n"
 	   << "\t" << "current_attempt=" << attrs->Get("current_attempt") << "\n"
diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp
index 103f8cf..1932b1d 100644
--- a/lib/icinga/compatutility.cpp
+++ b/lib/icinga/compatutility.cpp
@@ -285,6 +285,10 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se
 	attr->Set("next_notification", next_notification);
 	attr->Set("current_notification_number", notification_number);
 
+	String authority = service->GetCheckResultAuthority();
+	if (!authority.IsEmpty())
+		attr->Set("check_source", authority);
+
 	return attr;
 }
 
diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp
index 5d4fe64..ca22a56 100644
--- a/lib/icinga/service-check.cpp
+++ b/lib/icinga/service-check.cpp
@@ -603,6 +603,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author
 	olock.Lock();
 	SetLastCheckResult(cr);
 
+	if (!authority.IsEmpty())
+		SetCheckResultAuthority(authority);
+
 	bool was_flapping, is_flapping;
 
 	was_flapping = IsFlapping();
diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp
index 465befd..7dcb94c 100644
--- a/lib/icinga/service.cpp
+++ b/lib/icinga/service.cpp
@@ -328,6 +328,19 @@ std::set<Service::Ptr> Service::GetParentServices(void) const
 	return parents;
 }
 
+void Service::SetCheckResultAuthority(const String& authority)
+{
+	m_CheckResultAuthority = authority;
+}
+
+String Service::GetCheckResultAuthority(void) const
+{
+	if (m_CheckResultAuthority.IsEmpty())
+		return "(local)";
+	else
+		return m_CheckResultAuthority;
+}
+
 bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
 {
 	if (macro == "SERVICEDESC") {
diff --git a/lib/icinga/service.h b/lib/icinga/service.h
index 4d4203c..1fbcfc8 100644
--- a/lib/icinga/service.h
+++ b/lib/icinga/service.h
@@ -142,6 +142,9 @@ public:
 	void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0, const String& authority = String());
 	void ClearAcknowledgement(const String& authority = String());
 
+	void SetCheckResultAuthority(const String& authority);
+	String GetCheckResultAuthority(void) const;
+
 	/* Checks */
 	shared_ptr<CheckCommand> GetCheckCommand(void) const;
 	long GetMaxCheckAttempts(void) const;
@@ -352,6 +355,7 @@ private:
 	Value m_AcknowledgementExpiry;
 	String m_HostName;
 	Value m_Volatile;
+	String m_CheckResultAuthority;
 
 	/* Checks */
 	String m_CheckCommand;





More information about the icinga-checkins mailing list