Ejemplo n.º 1
0
void sinsp_cursesui::spy_selection(string field, string val, bool is_dig)
{
	//
	// Perform the drill down
	//
#ifndef NOCURSESUI
	sinsp_table_field* rowkey = m_datatable->get_row_key(m_viz->m_selct);
#else
	sinsp_table_field* rowkey = NULL;
#endif
	sinsp_table_field rowkeybak;
	if(rowkey != NULL)
	{
		rowkeybak.m_val = new uint8_t[rowkey->m_len];
		memcpy(rowkeybak.m_val, rowkey->m_val, rowkey->m_len);
		rowkeybak.m_len = rowkey->m_len;
	}

	uint32_t srtcol;
	srtcol = m_datatable->get_sorting_col();

	ASSERT(m_selected_view < (int32_t)m_views.size());

	m_sel_hierarchy.push_back(field, val, m_views.at(m_selected_view)->m_filter,
		m_selected_view, m_selected_sidemenu_entry, 
		&rowkeybak, srtcol, m_manual_filter, m_is_filter_sysdig, 
		m_datatable->is_sorting_ascending());

	if(is_dig)
	{
		m_selected_view = VIEW_ID_DIG;
	}
	else
	{
		m_selected_view = VIEW_ID_SPY;
	}

	if(!m_inspector->is_live())
	{
		m_eof = 0;
		m_last_progress_evt = 0;
		restart_capture(false);
	}
	else
	{
		try
		{
			start(true, false);
		}
		catch(...)
		{
			restart_capture(false);
		}
	}

#ifndef NOCURSESUI
	render();
#endif
}
Ejemplo n.º 2
0
bool sinsp_cursesui::drillup()
{
	if(m_sel_hierarchy.size() > 0)
	{
		//
		// unpause the thing if it's paused
		//
		if(m_paused)
		{
			pause();
		}

		//
		// Do the drillup
		//
		string field;
		sinsp_ui_selection_info* sinfo = m_sel_hierarchy.at(m_sel_hierarchy.size() - 1);

		m_manual_filter = "";

		if(m_sel_hierarchy.size() > 1)
		{
			sinsp_ui_selection_info* psinfo = m_sel_hierarchy.at(m_sel_hierarchy.size() - 2);
			field = psinfo->m_field;
		}

		sinsp_table_field rowkey = sinfo->m_rowkey;

		m_selected_view = sinfo->m_prev_selected_view;
		m_selected_sidemenu_entry = sinfo->m_prev_selected_sidemenu_entry;
		m_manual_filter = sinfo->m_prev_manual_filter;
		m_is_filter_sysdig = sinfo->m_prev_is_filter_sysdig;
		bool is_sorting_ascending = sinfo->m_prev_is_sorting_ascending;


		ASSERT(m_selected_view < (int32_t)m_views.size());

		m_sel_hierarchy.pop_back();
		//m_views[m_selected_view].m_filter = m_sel_hierarchy.tofilter();


		if(!m_inspector->is_live())
		{
			m_eof = 0;
			m_last_progress_evt = 0;
			restart_capture(false);
		}
		else
		{
			try
			{
				start(true, false);
			}
			catch(...)
			{
				restart_capture(false);
			}
		}
#ifndef NOCURSESUI
		if(rowkey.m_val != NULL)
		{
			m_viz->m_last_key.copy(&rowkey);
			m_viz->m_last_key.m_isvalid = true;
			m_viz->m_selection_changed = true;
		}
		else
		{
			m_viz->m_last_key.m_isvalid = false;
		}

		m_viz->m_drilled_up = true;
		populate_sidemenu(field, &m_sidemenu_viewlist);

		//
		// If sorting is different from the default one, restore it
		//
		if(sinfo->m_prev_sorting_col != m_views.at(m_selected_view)->m_sortingcol)
		{
			m_datatable->set_sorting_col(sinfo->m_prev_sorting_col);
		}

		m_datatable->set_is_sorting_ascending(is_sorting_ascending);

		//
		// If filtering is different from the default one, apply it
		//
		if(m_manual_filter != "" && !m_is_filter_sysdig)
		{
			m_datatable->set_freetext_filter(m_manual_filter);
		}

		clear();
		m_viz->render(true);

		render();
#endif

		delete[] rowkey.m_val;
		return true;
	}

	return false;
}
Ejemplo n.º 3
0
// returns false if there is no suitable drill down view for this field
bool sinsp_cursesui::do_drilldown(string field, string val, uint32_t new_view_num, filtercheck_field_info* info)
{
	//
	// unpause the thing if it's paused
	//
	if(m_paused)
	{
		pause();
	}

	//
	//	escape string parameters
	//
	if(info->m_type & PT_CHARBUF)
	{
		string escape = "\"";
		val = escape + val + escape;
	}

	//
	// Do the drilldown
	//
#ifndef NOCURSESUI
	sinsp_table_field* rowkey = m_datatable->get_row_key(m_viz->m_selct);
#else
	sinsp_table_field* rowkey = NULL;
#endif
	sinsp_table_field rowkeybak;
	if(rowkey != NULL)
	{
		rowkeybak.m_val = new uint8_t[rowkey->m_len];
		memcpy(rowkeybak.m_val, rowkey->m_val, rowkey->m_len);
		rowkeybak.m_len = rowkey->m_len;
	}

	uint32_t srtcol;
	srtcol = m_datatable->get_sorting_col();

	m_sel_hierarchy.push_back(field, val, m_views.at(m_selected_view)->m_filter,
		m_selected_view, m_selected_sidemenu_entry, 
		&rowkeybak, srtcol, m_manual_filter, m_is_filter_sysdig,
		m_datatable->is_sorting_ascending());

	m_selected_view = new_view_num;

	//
	// Reset the filter
	//
	m_manual_filter = "";

	if(!m_inspector->is_live())
	{
		m_eof = 0;
		m_last_progress_evt = 0;
		restart_capture(false);
	}
	else
	{
		try
		{
			start(true, false);
		}
		catch(...)
		{
			restart_capture(false);
		}
	}

#ifndef NOCURSESUI
	clear();
	populate_sidemenu(field, &m_sidemenu_viewlist);
//	m_selected_sidemenu_entry = 0;
	m_viz->render(true);
	render();
#endif

	return true;
}
Ejemplo n.º 4
0
void sinsp_cursesui::switch_view(bool is_spy_switch)
{
	string field;

	if(m_sel_hierarchy.size() > 0)
	{
		sinsp_ui_selection_info* psinfo = m_sel_hierarchy.at(m_sel_hierarchy.size() - 1);
		field = psinfo->m_field;
	}

#ifndef NOCURSESUI
	if(!m_raw_output)
	{
		//
		// Clear the screen to make sure all the crap is removed
		//
		clear();

		//
		// If we're currently visualizing the spy box, reset it and return immediately
		//
		if(is_spy_switch)
		{
			if(m_spy_box)
			{
				m_spy_box->reset();
			}
		}
	}
#endif

	//
	// Clear the manual filter, but not if this is a sysdig filter and we're in the same
	// view (applying sysdig filters causes the same view to the reloaded, and in that
	// case we want to preserve the filter).
	//
	if(m_prev_selected_view != m_selected_view)
	{
		m_manual_filter = "";
	}

	//
	// If this is a file, we need to restart the capture.
	// If it's a live capture, we restart only if start() fails, which usually
	// happens in case one of the filter fields requested thread state.
	//
	if(!m_inspector->is_live())
	{
		m_eof = 0;
		m_last_progress_evt = 0;
		restart_capture(is_spy_switch);
	}
	else
	{
		//
		// When live, also make sure to unpause the viz, otherwise the screen 
		// will stay empty.
		//
		if(m_paused)
		{
			pause();
		}

		try
		{
			start(true, is_spy_switch);
		}
		catch(...)
		{
			restart_capture(is_spy_switch);
		}
	}

#ifndef NOCURSESUI
	if(!m_raw_output)
	{
		delete m_sidemenu;
		m_sidemenu = NULL;

		if(m_viz != NULL)
		{
			m_viz->render(true);
		}

		render();
	}
#endif
}
Ejemplo n.º 5
0
void MainWindow::createactions()
{
    open_action = new QAction(tr("open"), this);
    open_action->setShortcut(QKeySequence::New);
    open_action->setStatusTip(tr("open new pcap file"));
    connect(open_action, SIGNAL(triggered()), this, SLOT(open()));

    save_action = new QAction(tr("save"), this);
    save_action->setShortcut(QKeySequence::Open);
    save_action->setStatusTip(tr("save data to disk"));
    connect(save_action, SIGNAL(triggered()), this, SLOT(save()));

    for(int i = 0; i < max_recentfiles; ++i)
    {
        recentfiles_actions[i] = new QAction(this);
        recentfiles_actions[i]->setVisible(false);
        connect(recentfiles_actions[i], SIGNAL(triggered()),
                this, SLOT(open_recent()));
    }

    close_action = new QAction(tr("close"), this);
    close_action->setStatusTip(tr("close current file"));
    connect(close_action, SIGNAL(triggered()), this, SLOT(close_file()));

    exit_action = new QAction(tr("quit"), this);
    exit_action->setShortcut(tr("Ctrl+Q"));
    exit_action->setStatusTip(tr("quit program"));
    connect(exit_action, SIGNAL(triggered()), this, SLOT(close()));

    start_action = new QAction(tr("start"), this);
    start_action->setStatusTip(tr("start to capture package"));
    connect(start_action, SIGNAL(triggered()),
            this, SLOT(start_capture()));

    restart_action = new QAction(tr("restart"), this);
    restart_action->setStatusTip(tr("restart to capture package"));
    connect(restart_action, SIGNAL(triggered()),
            this, SLOT(restart_capture()));

    stop_action = new QAction(tr("stop"), this);
    stop_action->setStatusTip(tr("stop"));
    connect(stop_action, SIGNAL(triggered()),
            this, SLOT(stop_capture()));

    avalible_action = new QAction(tr("available packages"), this);
    avalible_action->setStatusTip(tr("show packages that program cannot analysis"));
    connect(avalible_action, SIGNAL(triggered()),
            this, SLOT(show_avalible()));

    manual_action = new QAction(tr("help"), this);
    manual_action->setStatusTip(tr("help"));
    connect(manual_action, SIGNAL(triggered()),
            this, SLOT(show_manual()));

    about_action = new QAction(tr("about"), this);
    about_action->setStatusTip(tr("about"));
    connect(about_action, SIGNAL(triggered()),
            this, SLOT(about()));

    aboutqt_action = new QAction(tr("about Qt"), this);
    aboutqt_action->setStatusTip(tr("about Qt"));
    connect(aboutqt_action, SIGNAL(triggered()),
            qApp, SLOT(aboutQt()));
}