Ejemplo n.º 1
0
/*
 * display the statistics windows
 */
static void curses_show_stats(void)
{
   DEBUG_MSG("curses_show_stats");

   /* if the object already exist, set the focus to it */
   if (wdg_stats) {
      wdg_set_focus(wdg_stats);
      return;
   }
   
   wdg_create_object(&wdg_stats, WDG_WINDOW, WDG_OBJ_WANT_FOCUS);
   
   wdg_set_title(wdg_stats, "Statistics:", WDG_ALIGN_LEFT);
   wdg_set_size(wdg_stats, 1, 2, 70, 21);
   wdg_set_color(wdg_stats, WDG_COLOR_SCREEN, EC_COLOR);
   wdg_set_color(wdg_stats, WDG_COLOR_WINDOW, EC_COLOR);
   wdg_set_color(wdg_stats, WDG_COLOR_BORDER, EC_COLOR_BORDER);
   wdg_set_color(wdg_stats, WDG_COLOR_FOCUS, EC_COLOR_FOCUS);
   wdg_set_color(wdg_stats, WDG_COLOR_TITLE, EC_COLOR_TITLE);
   wdg_draw_object(wdg_stats);
 
   wdg_set_focus(wdg_stats);
  
   /* display the stats */
   refresh_stats(); 

   /* add the callback on idle to refresh the stats */
   wdg_add_idle_callback(refresh_stats);

   /* add the destroy callback */
   wdg_add_destroy_key(wdg_stats, CTRL('Q'), curses_stop_stats);
}
Ejemplo n.º 2
0
Stats *
add_new_stats(username_t username, Stats * st, long long tick_id) {
	User_stats *us = (User_stats *) g_hash_table_lookup(users, username);
    struct governor_config data_cfg;
    get_config_data( &data_cfg );
	//pthread_mutex_lock(&mtx_account);
	if (!us) {
		us = add_user_stats(username, accounts, users);
	}

	if(data_cfg.debug_user && !us->account->need_dbg){
		int len = strlen(data_cfg.debug_user);
		if(!strncmp(data_cfg.debug_user, us->account->id, len)){
			us->account->need_dbg = 1;
		}
	}
	/*if(check_if_user_restricted(username, accounts) && data_cfg.use_lve){
		return NULL;
	}*/
	Stats *stt = NULL;
	if(us){
		if (us->tick == tick_id){
			stt = refresh_stats(st, us);
		} else {
			us->tick = get_current_tick();
			stt = push_stats(st, us);
		}
	}
	//pthread_mutex_unlock(&mtx_account);
	return stt;
}
Ejemplo n.º 3
0
Tasksettings::Tasksettings(Settingsstore* store, Taskaccessmanager* taskaccessmanager, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Tasksettings)
{
    ui->setupUi(this);
    my_task_uid = -1;//default value to recognize if task uid has been set already...
    storage = store;
    taskaccess = taskaccessmanager;
    taskpriority = new Taskpriority();
    taskpriority->hide();
    taskevent = new Taskevent(taskaccess);
    taskevent->hide();
    QObject::connect(ui->pushButtonBack, SIGNAL(clicked()), this, SLOT(hide_me()));
    QObject::connect(ui->pushButtonRefresh, SIGNAL(clicked()), this, SLOT(refresh_info()));
    QObject::connect(ui->pushButtonClose, SIGNAL(clicked()), this, SLOT(close_task()));
    QObject::connect(ui->pushButtonKill, SIGNAL(clicked()), this, SLOT(kill_task()));
    QObject::connect(ui->pushButtonPriority, SIGNAL(clicked()), this, SLOT(set_task_priority()));
    QObject::connect(ui->pushButtonEvent, SIGNAL(clicked()), this, SLOT(send_system_event()));

    refresh_interval = 1000;
    timer_refresh = new QTimer();
    timer_refresh->setInterval(refresh_interval);
    QObject::connect(timer_refresh, SIGNAL(timeout()), this, SLOT(refresh_stats()));
}
Ejemplo n.º 4
0
void QPplot_gui::update_all() {
  int size;
  std::pair<double*,double*> curve = qpploter_->plotting_data(size);
  refresh_plot(  curve, size);
  refresh_stats();  
}
Ejemplo n.º 5
0
/*
 * display the statistics windows
 */
void gtkui_show_stats(void)
{
   GtkWidget *table, *label;

   DEBUG_MSG("gtkui_show_stats");

   /* if the object already exist, set the focus to it */
   if (stats_window) {
      /* show stats window */
      if(GTK_IS_WINDOW (stats_window))
         gtk_window_present(GTK_WINDOW (stats_window));
      else
         gtkui_page_present(stats_window);
      return;
   }
   
   stats_window = gtkui_page_new("Statistics", &gtkui_stop_stats, &gtkui_stats_detach);

   /* alright, this is a lot of code but it'll keep everything lined up nicely */
   /* if you need to add a row, don't forget to increase the number in gtk_table_new */
   table = gtk_table_new(12, 2, FALSE); /* rows, cols, size */
   gtk_table_set_col_spacings(GTK_TABLE (table), 10);
   gtk_container_add(GTK_CONTAINER (stats_window), table);

   packets_recv = gtk_label_new("      ");
   gtk_label_set_selectable(GTK_LABEL (packets_recv), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_recv), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_recv, 1, 2, 0, 1);
   label        = gtk_label_new( "Received packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

   packets_drop = gtk_label_new("      ");
   gtk_label_set_selectable(GTK_LABEL (packets_drop), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_drop), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_drop, 1, 2, 1, 2);
   label        = gtk_label_new("Dropped packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

   packets_forw = gtk_label_new("       0  bytes:        0 ");
   gtk_label_set_selectable(GTK_LABEL (packets_forw), TRUE);
   gtk_misc_set_alignment(GTK_MISC (packets_forw), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), packets_forw, 1, 2, 2, 3);
   label        = gtk_label_new("Forwarded packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);

   queue_len    = gtk_label_new("0/0 ");
   gtk_label_set_selectable(GTK_LABEL (queue_len), TRUE);
   gtk_misc_set_alignment(GTK_MISC (queue_len), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), queue_len, 1, 2, 3, 4);
   label        = gtk_label_new("Current queue length:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);

   sample_rate  = gtk_label_new("0     ");
   gtk_label_set_selectable(GTK_LABEL (sample_rate), TRUE);
   gtk_misc_set_alignment(GTK_MISC (sample_rate), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), sample_rate, 1, 2, 4, 5);
   label        = gtk_label_new("Sampling rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5);

   recv_bottom  = gtk_label_new("pck:        0  bytes:        0");
   gtk_label_set_selectable(GTK_LABEL (recv_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (recv_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), recv_bottom, 1, 2, 5, 6);
   label        = gtk_label_new("Bottom Half received packet:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6);

   recv_top     = gtk_label_new("pck:        0  bytes:        0");
   gtk_label_set_selectable(GTK_LABEL (recv_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (recv_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), recv_top, 1, 2, 6, 7);
   label        = gtk_label_new("Top Half received packet:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 6, 7);

   interesting  = gtk_label_new("0.00 %");
   gtk_label_set_selectable(GTK_LABEL (interesting), TRUE);
   gtk_misc_set_alignment(GTK_MISC (interesting), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), interesting, 1, 2, 7, 8);
   label        = gtk_label_new("Interesting packets:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 7, 8);

   rate_bottom  = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (rate_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (rate_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), rate_bottom, 1, 2, 8, 9);
   label        = gtk_label_new("Bottom Half packet rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 8, 9);

   rate_top     = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (rate_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (rate_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), rate_top, 1, 2, 9, 10);
   label        = gtk_label_new("Top Half packet rate:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 9, 10);

   through_bottom = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (through_bottom), TRUE);
   gtk_misc_set_alignment(GTK_MISC (through_bottom), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), through_bottom, 1, 2, 10, 11);
   label        = gtk_label_new("Bottom Half throughput:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 10, 11);

   through_top  = gtk_label_new("worst:        0  adv:        0 b/s");
   gtk_label_set_selectable(GTK_LABEL (through_top), TRUE);
   gtk_misc_set_alignment(GTK_MISC (through_top), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), through_top, 1, 2, 11, 12);
   label        = gtk_label_new("Top Half throughput:");
   gtk_label_set_selectable(GTK_LABEL (label), TRUE);
   gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 11, 12);

   gtk_widget_show_all(table);
   gtk_widget_show(stats_window);
  
   /* display the stats */
   refresh_stats(NULL); 

   /* refresh the stats window every 200 ms */
   /* GTK has a gtk_idle_add also but it calls too much and uses 100% cpu */
   stats_idle = gtk_timeout_add(200, refresh_stats, NULL);
}
Ejemplo n.º 6
0
void Histogram_gui::changeCurve(const QString & s)
{
	std::map<float,int>::iterator itr;

	int total = histogram_->rawDataSize();
	int i = 0;
	QwtText tfp("Probability");
	tfp.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QwtText tff("Frequency");
	tff.setFont(plot_->axisFont(QwtPlot::yLeft));	

	QColor blueColor(Qt::blue);
	const QPen pen(blueColor);
	std::pair<double*,double*> curve = histogram_->plotting_data();
	if (!curve.first) {
		appli_message("No data present");
		return;
	}

	if (s == "cdf") {
	    std::map<float, int> freqCount = histogram_->frequency();

		_cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);


		plot_->setAxisTitle(QwtPlot::yLeft, tfp);
		plot_->enableAxis(QwtPlot::yRight,false);

		curve_grid_->enableY(true);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		
		plot_->enableAxis(QwtPlot::yLeft);

		curve_id_->setStyle(QwtPlotCurve::NoCurve);
		_cdfCurve->setStyle(QwtPlotCurve::Lines);

		double * x = new double[freqCount.size()+1];
		double * y = new double[freqCount.size()+1];

		y[0] = 0;
		for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
			x[i+1] = itr->first;
			y[i+1] = y[i]+(double)(itr->second)/(double)(total);
		}
		x[0] = x[1];

		_cdfCurve->setPen(pen);
		_cdfCurve->setData(  x, y, freqCount.size()+1 );
		refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
		refresh_stats();


		delete []x;
		delete []y;
	}
	else if (s == "pdf") {
	        //_cdfCurve->detach();
		
		plot_->enableAxis(QwtPlot::yRight, false);
		plot_->setAxisTitle(QwtPlot::yLeft, tff);
		plot_->enableAxis(QwtPlot::xBottom);
		
		curve_id_->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);
		curve_grid_->setYAxis(QwtPlot::yLeft);
		curve_grid_->enableY(true);

		curve_grid_->setXAxis(QwtPlot::xBottom);
		curve_grid_->enableX(true);

		_cdfCurve->setStyle(QwtPlotCurve::NoCurve);
		curve_id_->setStyle(QwtPlotCurve::Histogram);

		int size = histogram_->bins()+1;
		double* x = new double[size+1];
		double* y = new double[size+1];
		for( int i =0 ; i < size ; i++ ) {
			x[i+1] = curve.first[i];
			y[i+1] = curve.second[i];
		}
		x[0] = x[1];
		y[0] = 0.0;

		refresh_plot(  std::make_pair( x,y ), size+1 );
		refresh_stats();
		delete []x;
		delete []y;
	}
	else {

	    std::map<float, int> freqCount = histogram_->frequency();

	    _cdfCurve->setAxis(QwtPlot::xBottom, QwtPlot::yRight);

	    plot_->enableAxis(QwtPlot::yRight, true);
	    plot_->enableAxis(QwtPlot::yLeft, true);
				   
	    curve_grid_->setYAxis(QwtPlot::yLeft);


	    plot_->setAxisTitle(QwtPlot::yLeft, tff);
	    plot_->setAxisTitle(QwtPlot::yRight, tfp);

	    _cdfCurve->setStyle(QwtPlotCurve::Lines);
	    curve_id_->setStyle(QwtPlotCurve::Histogram);

	    double * x = new double[freqCount.size()+1];
	    double * y = new double[freqCount.size()+1];

	    y[0] = 0;
	    for (itr = freqCount.begin(); itr != freqCount.end(); ++itr,++i) {
	      x[i+1] = itr->first;
	      y[i+1] = y[i]+(double)(itr->second)/(double)(total);
	    }
	    x[0] = x[1];

	    _cdfCurve->setPen(pen);
	    _cdfCurve->setData( x, y, freqCount.size()+1 );
	    refresh_plot( _cdfCurve, std::make_pair( x,y ), freqCount.size()+1 );
	    //refresh_stats();


	    int size = histogram_->bins()+1;
	    double* x1 = new double[size+1];
	    double* y1 = new double[size+1];
	    for( int i =0 ; i < size ; i++ ) {
	      x1[i+1] = curve.first[i];
	      y1[i+1] = curve.second[i];
	    }
	    x1[0] = x1[1];
	    y1[0] = 0.0;

	    refresh_plot(  std::make_pair( x1,y1 ), size+1 );
	    refresh_stats();

	    delete []x1;
	    delete []y1;
	    delete []x;
	    delete []y;

	}
		  //plot_->replot();

}
Ejemplo n.º 7
0
Stats Connection::get_stats(){  // Tested
	refresh_stats();
	return stats;
} // Tested