[icinga-checkins] icinga.org: icinga2/next: Additional fixes for log table including test queries.

git at icinga.org git at icinga.org
Wed Nov 6 18:54:54 CET 2013


Module: icinga2
Branch: next
Commit: 90cf04f0881e0075a05208b2007ec92c41a25921
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=90cf04f0881e0075a05208b2007ec92c41a25921

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Wed Nov  6 18:43:03 2013 +0100

Additional fixes for log table including test queries.

Refs #4433

---

 components/livestatus/logtable.cpp                 |    8 ++++--
 test/livestatus/queries/custom/thruk_alert_history |   19 ++++++++++++++
 test/livestatus/queries/custom/thruk_comments      |    7 ++++++
 test/livestatus/queries/log/avail                  |   12 +++++++++
 test/livestatus/queries/log/avail_svc              |   13 ++++++++++
 test/livestatus/queries/log/trend                  |   26 ++++++++++++++++++++
 6 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/components/livestatus/logtable.cpp b/components/livestatus/logtable.cpp
index 8af7f13..c5f9a67 100644
--- a/components/livestatus/logtable.cpp
+++ b/components/livestatus/logtable.cpp
@@ -55,7 +55,7 @@ LogTable::LogTable(const unsigned long& from, const unsigned long& until)
 	/* store from & until for FetchRows */
 	m_TimeFrom = from;
 	m_TimeUntil = until;
-	
+
 	/* create log file index - TODO config option */
 	CreateLogIndex(Application::GetLocalStateDir() + "/log/icinga2/compat");
 
@@ -97,6 +97,9 @@ LogTable::LogTable(const unsigned long& from, const unsigned long& until)
 
 			Dictionary::Ptr bag = GetLogEntryAttributes(type, options);
 
+			if (!bag)
+				continue;
+
 			bag->Set("time", time);
 			bag->Set("lineno", lineno);
 			bag->Set("message", String(line)); /* complete line */
@@ -549,7 +552,8 @@ Dictionary::Ptr LogTable::GetLogEntryAttributes(const String& type, const String
 		 boost::algorithm::contains(type, "active mode...") ||
 		 boost::algorithm::contains(type, "standby mode...")) {
 		log_class = LogClassProgram;
-	}
+	} else
+		return Dictionary::Ptr();
 
 	Dictionary::Ptr bag = boost::make_shared<Dictionary>();
 
diff --git a/test/livestatus/queries/custom/thruk_alert_history b/test/livestatus/queries/custom/thruk_alert_history
new file mode 100644
index 0000000..de04c46
--- /dev/null
+++ b/test/livestatus/queries/custom/thruk_alert_history
@@ -0,0 +1,19 @@
+GET log
+Columns: class time type state host_name service_description plugin_output message options state_type contact_name
+Filter: time >= 1383692400
+Filter: time <= 1383778800
+Filter: type = SERVICE ALERT
+And: 1
+Filter: type = HOST ALERT
+And: 1
+Filter: type = SERVICE FLAPPING ALERT
+Filter: type = HOST FLAPPING ALERT
+Filter: type = SERVICE DOWNTIME ALERT
+Filter: type = HOST DOWNTIME ALERT
+Filter: message ~ starting\.\.\.
+Filter: message ~ shutting\ down\.\.\.
+Or: 8
+And: 3
+OutputFormat: json
+ResponseHeader: fixed16
+
diff --git a/test/livestatus/queries/custom/thruk_comments b/test/livestatus/queries/custom/thruk_comments
new file mode 100644
index 0000000..fc454ab
--- /dev/null
+++ b/test/livestatus/queries/custom/thruk_comments
@@ -0,0 +1,7 @@
+GET comments
+Columns: author comment entry_time entry_type expires expire_time host_name id persistent service_description source type
+Filter: host_name = localhost
+Filter: service_description = processes
+OutputFormat: json
+ResponseHeader: fixed16
+
diff --git a/test/livestatus/queries/log/avail b/test/livestatus/queries/log/avail
new file mode 100644
index 0000000..b37162c
--- /dev/null
+++ b/test/livestatus/queries/log/avail
@@ -0,0 +1,12 @@
+GET log
+Columns: time type message class
+Filter: type = HOST ALERT
+Filter: state_type = HARD
+Filter: type = INITIAL HOST STATE
+Filter: state_type = HARD
+Filter: type = CURRENT HOST STATE
+Filter: state_type = HARD
+Filter: type = HOST DOWNTIME ALERT
+Or: 7
+ResponseHeader: fixed16
+
diff --git a/test/livestatus/queries/log/avail_svc b/test/livestatus/queries/log/avail_svc
new file mode 100644
index 0000000..9e3712b
--- /dev/null
+++ b/test/livestatus/queries/log/avail_svc
@@ -0,0 +1,13 @@
+GET log
+Columns: time type message class
+Filter: type = HOST DOWNTIME ALERT
+Filter: type = SERVICE ALERT
+Filter: state_type = HARD
+Filter: type = INITIAL SERVICE STATE
+Filter: state_type = HARD
+Filter: type = CURRENT SERVICE STATE
+Filter: state_type = HARD
+Filter: type = SERVICE DOWNTIME ALERT
+Or: 8
+ResponseHeader: fixed16
+
diff --git a/test/livestatus/queries/log/trend b/test/livestatus/queries/log/trend
new file mode 100644
index 0000000..bd44d89
--- /dev/null
+++ b/test/livestatus/queries/log/trend
@@ -0,0 +1,26 @@
+GET log
+Columns: time type message
+Filter: host_name = localhost
+Filter: type = HOST ALERT
+Filter: state_type = HARD
+Filter: type = INITIAL HOST STATE
+Filter: state_type = HARD
+Filter: type = CURRENT HOST STATE
+Filter: state_type = HARD
+Filter: type = HOST DOWNTIME ALERT
+Or: 7
+And: 2
+Filter: host_name = localhost
+Filter: type = SERVICE ALERT
+Filter: state_type = HARD
+Filter: type = INITIAL SERVICE STATE
+Filter: state_type = HARD
+Filter: type = CURRENT SERVICE STATE
+Filter: state_type = HARD
+Filter: type = SERVICE DOWNTIME ALERT
+Or: 7
+And: 2
+Filter: class = 2
+Or: 3
+ResponseHeader: fixed16
+





More information about the icinga-checkins mailing list