MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ExecuteGetHelper

Method ExecuteGetHelper

lib/livestatus/livestatusquery.cpp:439–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439void LivestatusQuery::ExecuteGetHelper(const Stream::Ptr& stream)
440{
441 Log(LogNotice, "LivestatusQuery")
442 << "Table: " << m_Table;
443
444 Table::Ptr table = Table::GetByName(m_Table, m_CompatLogPath, m_LogTimeFrom, m_LogTimeUntil);
445
446 if (!table) {
447 SendResponse(stream, LivestatusErrorNotFound, "Table '" + m_Table + "' does not exist.");
448
449 return;
450 }
451
452 std::vector<LivestatusRowValue> objects = table->FilterRows(m_Filter, m_Limit);
453 std::vector<String> columns;
454
455 if (m_Columns.size() > 0)
456 columns = m_Columns;
457 else
458 columns = table->GetColumnNames();
459
460 std::ostringstream result;
461 bool first_row = true;
462 BeginResultSet(result);
463
464 if (m_Aggregators.empty()) {
465 typedef std::pair<String, Column> ColumnPair;
466
467 std::vector<ColumnPair> column_objs;
468 column_objs.reserve(columns.size());
469
470 for (const String& columnName : columns)
471 column_objs.emplace_back(columnName, table->GetColumn(columnName));
472
473 ArrayData header;
474
475 for (const LivestatusRowValue& object : objects) {
476 ArrayData row;
477
478 row.reserve(column_objs.size());
479
480 for (const ColumnPair& cv : column_objs) {
481 if (m_ColumnHeaders)
482 header.push_back(cv.first);
483
484 row.push_back(cv.second.ExtractValue(object.Row, object.GroupByType, object.GroupByObject));
485 }
486
487 if (m_ColumnHeaders) {
488 AppendResultRow(result, new Array(std::move(header)), first_row);
489 m_ColumnHeaders = false;
490 }
491
492 AppendResultRow(result, new Array(std::move(row)), first_row);
493 }
494 } else {
495 std::map<std::vector<Value>, std::vector<AggregatorState *> > allStats;
496

Callers

nothing calls this directly

Calls 13

LogClass · 0.85
FilterRowsMethod · 0.80
GetColumnNamesMethod · 0.80
GetColumnMethod · 0.80
push_backMethod · 0.80
findMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
ExtractValueMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
ApplyMethod · 0.45

Tested by

no test coverage detected