예제 #1
0
void WinSettings::browse_button_clicked()
{
    QString dir = get_dir(this);

    /*Check if the path is correct. If dir == "", the cancel button was pressed*/
    if(dir != "")
    {
        /* Get the index from the button(Sender)*/
        int id = sender()->property("index").toInt();

        /*Set the correct lineText*/
        switch (id) {
        case BENCH_DIR:

            /* Check if all the required files */
            if (!exist_required_files(dir))
            {
                QString * arr_required_files = load_requried_files("");
                QString message_error = "There aren't required files in selected folder. \n They are: \n";

                for (int i = 0; i<NUM_REQUIRED_FILE; i++)
                    message_error +=  arr_required_files[i] + '\n';

                QMessageBox::warning(this,"ERROR", message_error, QMessageBox::Ok);
                return;
            }
            //Control passed, can change the dir_bench and the text
            dir_bench=dir;
            ui->line_bench_dir->setText(dir_bench);
            user_has_saved=false;
            //update BASE_DIR and Size of file to use
            ui->txt_file_size->setText(read_value_from_file(NUM_BLOCKS_CREATE_SEQ_M));
            ui->line_base_dir->setText(read_value_from_file(BASE_DIR_M));
            break;

        case BASE_DIR:
            if (dir != "")
                //delete the "/"
                dir.truncate(dir.length()-1);
                ui->line_base_dir->setText(dir);
                user_has_saved=false;
            break;

        default:
            break;
        }

    }
}
예제 #2
0
void WinSettings::update_advanced_interface()
{
    ui->slc_5->setText(QString::number(test_sets.n_read));
    ui->slc_6->setText(QString::number(test_sets.n_write));
    ui->slc_3->setText(QString::number((test_sets.n_iteration)));
    ui->slc_2->setCurrentIndex(test_sets.type_rw);
    ui->slc_3->setEnabled(true);
    ui->slc_1->setEnabled(true);

    if (test_sets.type_test != STARTUP)
    {
        ui->slc_1->setEnabled(false);
        ui->slc_3->setEnabled(false);
    }

    ui->txt_file_size->setText(read_value_from_file(NUM_BLOCKS_CREATE_SEQ_M));
    ui->line_base_dir->setText(read_value_from_file(BASE_DIR_M));
    ui->line_bench_dir->setText(dir_bench);
    pre_txt_size=ui->txt_file_size->text();
    pre_bench_dir=dir_bench;

    return;
}
예제 #3
0
string process_internal_monitor(DeviceInfo info, MYSQL *mysql)
{
	string test_result = "U", temp, temp2;
	float disk_total, disk_used;
	unsigned int nCPUs, sum;
	list<SNMPPair> WinCPUList;

	switch(info.test_id)
	{
		// count lines in a file
		case 1:		test_result = count_file_lines(info);
					break;
		
		// TNT "good" modems (that is, available modems - suspect modems)
		case 2:		test_result = snmp_diff(info, ".1.3.6.1.4.1.529.15.1.0", ".1.3.6.1.4.1.529.15.3.0");
					break;
					
		// UCD CPU combined load (user + system)
		case 3:		temp = snmp_get(info, ".1.3.6.1.4.1.2021.11.9.0");
					temp2 = snmp_get(info, ".1.3.6.1.4.1.2021.11.10.0");
					if ( (temp != "U") && (temp2 != "U") )
					{
						test_result = inttostr(strtoint(temp) + strtoint(temp2));
					}
					break;

		// Windows disk usage %
		case 4:
					temp = snmp_get(info, expand_parameters(info, ".1.3.6.1.2.1.25.2.3.1.5.%dskIndex%"));
					disk_total = (float) strtoul(temp.c_str(), NULL, 10);
					temp = snmp_get(info, expand_parameters(info, ".1.3.6.1.2.1.25.2.3.1.6.%dskIndex%"));
					disk_used  = (float) strtoul(temp.c_str(), NULL, 10);
					if (disk_total != 0)
						test_result = inttostr((int) (100*disk_used/disk_total));
					break;

		// UCD Swap utilization %
		case 5:
					temp = snmp_get(info, ".1.3.6.1.4.1.2021.4.3.0");
					disk_total = (float) strtoul(temp.c_str(), NULL, 10);
					temp = snmp_get(info, ".1.3.6.1.4.1.2021.4.4.0");
					disk_used  = (float) strtoul(temp.c_str(), NULL, 10);
					if (disk_total != 0)
						test_result = inttostr((int) (100 - 100*disk_used/disk_total));
					break;
		
		// read value from file
		case 6:		test_result = read_value_from_file(info);
					break;
		
		// report SNMP avoidance status
		case 7:		test_result = inttostr(info.snmp_avoid);
					break;

		// Windows CPU usage %
		case 8:
				WinCPUList = snmp_walk(info, ".1.3.6.1.2.1.25.3.3.1.2"); // hrProcessorLoad

				nCPUs = 0; sum = 0;
				for (list<SNMPPair>::iterator current = WinCPUList.begin();
				     current != WinCPUList.end();
				     current++) {

					nCPUs++;
					sum += strtoul(current->value.c_str(), NULL, 10);
				}
				if (nCPUs > 0) {
					test_result = inttostr(sum / nCPUs);
				} else {
					test_result = "U";
				}
				break;

		default:	debuglogger(DEBUG_MONITOR, LEVEL_WARNING, &info, "Unknown Internal Test (" + inttostr(info.test_id) + ")");
	}

	return test_result;
}