Additional fixes for log table including test queries.

Refs #4433
This commit is contained in:
Michael Friedrich 2013-11-06 18:43:03 +01:00
parent 0e9c527f5a
commit 90cf04f088
6 changed files with 83 additions and 2 deletions

View File

@ -55,7 +55,7 @@ LogTable::LogTable(const unsigned long& from, const unsigned long& until)
/* store from & until for FetchRows */ /* store from & until for FetchRows */
m_TimeFrom = from; m_TimeFrom = from;
m_TimeUntil = until; m_TimeUntil = until;
/* create log file index - TODO config option */ /* create log file index - TODO config option */
CreateLogIndex(Application::GetLocalStateDir() + "/log/icinga2/compat"); 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); Dictionary::Ptr bag = GetLogEntryAttributes(type, options);
if (!bag)
continue;
bag->Set("time", time); bag->Set("time", time);
bag->Set("lineno", lineno); bag->Set("lineno", lineno);
bag->Set("message", String(line)); /* complete line */ 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, "active mode...") ||
boost::algorithm::contains(type, "standby mode...")) { boost::algorithm::contains(type, "standby mode...")) {
log_class = LogClassProgram; log_class = LogClassProgram;
} } else
return Dictionary::Ptr();
Dictionary::Ptr bag = boost::make_shared<Dictionary>(); Dictionary::Ptr bag = boost::make_shared<Dictionary>();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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