mirror of
https://github.com/tstack/lnav.git
synced 2024-10-26 13:16:11 +03:00
[bro] update opid metadata
This commit is contained in:
parent
4c7952a21d
commit
cb43a562a2
@ -473,7 +473,9 @@ gantt_source::rebuild_indexes()
|
||||
this->gs_time_order.emplace_back(std::move(pair.second));
|
||||
}
|
||||
this->gs_opid_width = std::min(this->gs_opid_width, MAX_OPID_WIDTH);
|
||||
this->gs_total_width = 22 + this->gs_opid_width + max_desc_width;
|
||||
this->gs_total_width
|
||||
= std::max<size_t>(22 + this->gs_opid_width + max_desc_width,
|
||||
1 + 23 + 10 + 23 + 1 /* header */);
|
||||
|
||||
this->tss_view->set_needs_update();
|
||||
}
|
||||
@ -527,15 +529,16 @@ gantt_source::text_selection_changed(textview_curses& tc)
|
||||
auto low_vl = this->gs_lss.row_for_time(row.or_value.otr_begin);
|
||||
auto high_tv = row.or_value.otr_end;
|
||||
high_tv.tv_sec += 1;
|
||||
auto high_vl = this->gs_lss.row_for_time(high_tv);
|
||||
auto high_vl = this->gs_lss.row_for_time(high_tv).value_or(
|
||||
this->gs_lss.text_line_count());
|
||||
|
||||
if (!low_vl || !high_vl) {
|
||||
if (!low_vl) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto preview_content = attr_line_t();
|
||||
auto msgs_remaining = size_t{MAX_PREVIEW_LINES};
|
||||
auto win = this->gs_lss.window_at(low_vl.value(), high_vl.value());
|
||||
auto win = this->gs_lss.window_at(low_vl.value(), high_vl);
|
||||
auto id_hash = hash_str(row.or_name.data(), row.or_name.length());
|
||||
for (const auto& msg_line : win) {
|
||||
if (!msg_line.get_logline().match_opid_hash(id_hash)) {
|
||||
@ -545,21 +548,22 @@ gantt_source::text_selection_changed(textview_curses& tc)
|
||||
const auto& sa = msg_line.get_attrs();
|
||||
auto opid_opt = get_string_attr(sa, logline::L_OPID);
|
||||
|
||||
if (opid_opt) {
|
||||
auto opid_range = opid_opt.value().saw_string_attr->sa_range;
|
||||
auto opid_sf = msg_line.to_string(opid_range);
|
||||
if (!opid_opt) {
|
||||
continue;
|
||||
}
|
||||
auto opid_range = opid_opt.value().saw_string_attr->sa_range;
|
||||
auto opid_sf = msg_line.to_string(opid_range);
|
||||
|
||||
if (opid_sf == row.or_name) {
|
||||
std::vector<attr_line_t> rows_al(1);
|
||||
if (opid_sf == row.or_name) {
|
||||
std::vector<attr_line_t> rows_al(1);
|
||||
|
||||
this->gs_log_view.listview_value_for_rows(
|
||||
this->gs_log_view, msg_line.get_vis_line(), rows_al);
|
||||
this->gs_log_view.listview_value_for_rows(
|
||||
this->gs_log_view, msg_line.get_vis_line(), rows_al);
|
||||
|
||||
preview_content.append(rows_al[0]).append("\n");
|
||||
msgs_remaining -= 1;
|
||||
if (msgs_remaining == 0) {
|
||||
break;
|
||||
}
|
||||
preview_content.append(rows_al[0]).append("\n");
|
||||
msgs_remaining -= 1;
|
||||
if (msgs_remaining == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,10 +360,22 @@ public:
|
||||
static std::unordered_map<const intern_string_t, logline_value_meta>
|
||||
FIELD_META;
|
||||
|
||||
static const intern_string_t get_opid_desc()
|
||||
{
|
||||
static const intern_string_t RETVAL = intern_string::lookup("std");
|
||||
|
||||
return RETVAL;
|
||||
}
|
||||
|
||||
bro_log_format()
|
||||
{
|
||||
this->lf_is_self_describing = true;
|
||||
this->lf_time_ordered = false;
|
||||
|
||||
auto desc_v = std::make_shared<std::vector<opid_descriptor>>();
|
||||
desc_v->emplace({});
|
||||
this->lf_opid_description_def->emplace(get_opid_desc(),
|
||||
opid_descriptors{desc_v});
|
||||
}
|
||||
|
||||
const intern_string_t get_name() const override
|
||||
@ -382,12 +394,15 @@ public:
|
||||
|
||||
scan_result_t scan_int(std::vector<logline>& dst,
|
||||
const line_info& li,
|
||||
shared_buffer_ref& sbr)
|
||||
shared_buffer_ref& sbr,
|
||||
scan_batch_context& sbc)
|
||||
{
|
||||
static const intern_string_t STATUS_CODE
|
||||
= intern_string::lookup("bro_status_code");
|
||||
static const intern_string_t TS = intern_string::lookup("bro_ts");
|
||||
static const intern_string_t UID = intern_string::lookup("bro_uid");
|
||||
static const intern_string_t ID_ORIG_H
|
||||
= intern_string::lookup("bro_id_orig_h");
|
||||
|
||||
separated_string ss(sbr.get_data(), sbr.length());
|
||||
struct timeval tv;
|
||||
@ -395,6 +410,8 @@ public:
|
||||
bool found_ts = false;
|
||||
log_level_t level = LEVEL_INFO;
|
||||
uint8_t opid = 0;
|
||||
auto opid_cap = string_fragment::invalid();
|
||||
auto host_cap = string_fragment::invalid();
|
||||
|
||||
ss.with_separator(this->blf_separator.get());
|
||||
|
||||
@ -425,9 +442,11 @@ public:
|
||||
level = LEVEL_ERROR;
|
||||
}
|
||||
} else if (UID == fd.fd_meta.lvm_name) {
|
||||
const auto sf = *iter;
|
||||
opid_cap = *iter;
|
||||
|
||||
opid = hash_str(sf.data(), sf.length());
|
||||
opid = hash_str(opid_cap.data(), opid_cap.length());
|
||||
} else if (ID_ORIG_H == fd.fd_meta.lvm_name) {
|
||||
host_cap = *iter;
|
||||
}
|
||||
|
||||
if (fd.fd_numeric_index) {
|
||||
@ -454,6 +473,29 @@ public:
|
||||
ll.set_ignore(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (opid_cap.is_valid()) {
|
||||
auto opid_iter = sbc.sbc_opids.find(opid_cap);
|
||||
|
||||
if (opid_iter == sbc.sbc_opids.end()) {
|
||||
auto opid_copy = opid_cap.to_owned(sbc.sbc_allocator);
|
||||
auto otr = opid_time_range{tv, tv};
|
||||
auto emplace_res = sbc.sbc_opids.emplace(opid_copy, otr);
|
||||
opid_iter = emplace_res.first;
|
||||
} else {
|
||||
opid_iter->second.otr_end = tv;
|
||||
}
|
||||
|
||||
opid_iter->second.otr_level_counts[level] += 1;
|
||||
|
||||
auto& otr = opid_iter->second;
|
||||
if (!otr.otr_description_id && host_cap.is_valid()
|
||||
&& otr.otr_description.empty())
|
||||
{
|
||||
otr.otr_description_id = get_opid_desc();
|
||||
otr.otr_description.emplace_back(0, host_cap.to_string());
|
||||
}
|
||||
}
|
||||
dst.emplace_back(li.li_file_range.fr_offset, tv, level, 0, opid);
|
||||
return scan_match{0};
|
||||
}
|
||||
@ -470,7 +512,7 @@ public:
|
||||
= lnav::pcre2pp::code::from_const(R"(^#separator\s+(.+))");
|
||||
|
||||
if (!this->blf_format_name.empty()) {
|
||||
return this->scan_int(dst, li, sbr);
|
||||
return this->scan_int(dst, li, sbr, sbc);
|
||||
}
|
||||
|
||||
if (dst.empty() || dst.size() > 20 || sbr.empty()
|
||||
@ -616,7 +658,7 @@ public:
|
||||
&& !this->blf_field_defs.empty())
|
||||
{
|
||||
dst.clear();
|
||||
return this->scan_int(dst, li, sbr);
|
||||
return this->scan_int(dst, li, sbr, sbc);
|
||||
}
|
||||
|
||||
this->blf_format_name.clear();
|
||||
|
@ -188,6 +188,7 @@ dist_noinst_SCRIPTS = \
|
||||
test_events.sh \
|
||||
test_format_installer.sh \
|
||||
test_format_loader.sh \
|
||||
test_gantt.sh \
|
||||
test_grep_proc.sh \
|
||||
test_json_format.sh \
|
||||
test_line_buffer.sh \
|
||||
@ -423,6 +424,7 @@ TESTS = \
|
||||
test_listview.sh \
|
||||
test_meta.sh \
|
||||
test_mvwattrline.sh \
|
||||
test_gantt.sh \
|
||||
test_grep_proc.sh \
|
||||
test_grep_proc2 \
|
||||
test_json_format.sh \
|
||||
|
@ -274,6 +274,8 @@ EXPECTED_FILES = \
|
||||
$(srcdir)/%reldir%/test_format_loader.sh_5992e2695b7e6cf1f3520dbb87af8fc2b8f27088.out \
|
||||
$(srcdir)/%reldir%/test_format_loader.sh_fca6c1fb9f3aaa69b3ffb2d1a8a86434b2f4a247.err \
|
||||
$(srcdir)/%reldir%/test_format_loader.sh_fca6c1fb9f3aaa69b3ffb2d1a8a86434b2f4a247.out \
|
||||
$(srcdir)/%reldir%/test_gantt.sh_3af11588ee36bab7e2caea0f7a24d3c9cafd2310.err \
|
||||
$(srcdir)/%reldir%/test_gantt.sh_3af11588ee36bab7e2caea0f7a24d3c9cafd2310.out \
|
||||
$(srcdir)/%reldir%/test_json_format.sh_168cac40c27f547044c89d39eb0ff2ef81da4b21.err \
|
||||
$(srcdir)/%reldir%/test_json_format.sh_168cac40c27f547044c89d39eb0ff2ef81da4b21.out \
|
||||
$(srcdir)/%reldir%/test_json_format.sh_1bb0fd243e916546aea22029245ac590dae17a86.err \
|
||||
@ -640,6 +642,8 @@ EXPECTED_FILES = \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_20a76db446a0a558dcbdf41033f97d4a22ca1bfa.out \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_2c3f66e78deb8721b1d1fe5a787e9958895401d7.err \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_2c3f66e78deb8721b1d1fe5a787e9958895401d7.out \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_34baa8050f8278d7b68c29e53bdd9f37da0f34c8.err \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_34baa8050f8278d7b68c29e53bdd9f37da0f34c8.out \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_3ed11101a413e47c3dfe219557b7a6df04a64253.err \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_3ed11101a413e47c3dfe219557b7a6df04a64253.out \
|
||||
$(srcdir)/%reldir%/test_sql_fs_func.sh_469380561dccd79c7249562067107c330838eaad.err \
|
||||
|
7
test/test_gantt.sh
Normal file
7
test/test_gantt.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
export YES_COLOR=1
|
||||
|
||||
run_cap_test ${lnav_test} -n \
|
||||
-c ':switch-to-view gantt' \
|
||||
${test_dir}/logfile_bro_http.log.0
|
@ -52,4 +52,4 @@ run_cap_test ./drive_sql "select joinpath('foo', 'bar', 'baz')"
|
||||
|
||||
run_cap_test ./drive_sql "select joinpath('foo', 'bar', 'baz', '/root')"
|
||||
|
||||
run_cap_test ${lnav_test} -n -c ";SELECT shell_exec('echo hi')"
|
||||
run_cap_test ${lnav_test} -Nn -c ";SELECT shell_exec('echo hi')"
|
||||
|
Loading…
Reference in New Issue
Block a user