Пример #1
0
void CMonitorProcesses::slotLoad()
{
    // only bother with this if we are visible...
    if ( !isVisible() )
        return;

    if ( !bEnabled )
        return;

    // init coms with DM but don't even bother the DM until (if) we become visible... 
    if ( !hStats )
    {
        if ( uodbc_open_stats( &hStats, UODBC_STATS_READ ) != 0 )
        {
//            char szError[512];
//            QMessageBox::critical( this, tr( "Monitor Processes" ),  QString( "uodbc_open_stats failed\n%1" ).arg( uodbc_stats_error( szError, 512 ) ) );
//            bEnabled = false;
            return;
        }
    }

    // get current processes info...
    {
        uodbc_stats_retentry aPIDs[MAXPROCESSES];
        int nPIDs = uodbc_get_stats( hStats, 0, aPIDs, MAXPROCESSES );

        for ( int nPID = 0; nPID < MAXPROCESSES; nPID++ )
        {
            if ( nPID < nPIDs )
            {
                // get handle count for current process...
                uodbc_stats_retentry aHandles[MAXHANDLES];
                int nHandles = uodbc_get_stats( hStats, aPIDs[nPID].value.l_value, aHandles, MAXHANDLES );

                if ( nHandles > 0 )
                {
                    item( nPID, 0 )->setText( QString( "%1" ).arg( aPIDs[nPID].value.l_value ) );
                    for ( int nHandle = 0; nHandle < MAXHANDLES; nHandle++ )
                    {
                        item( nPID, nHandle + 1 )->setText( QString( "%1" ).arg( aHandles[nHandle].value.l_value ) );
                    }
                }
                else
                    clearRow( nPID );
            }
            else
            {
                // no need to clear remaining rows if no data in them...
                if ( nPID >= nRowsWithValues )
                {
                    nRowsWithValues = nPID;
                    return;
                }
                clearRow( nPID );
            }
        }
    }
}
Пример #2
0
void CStatSummary::showStats()
{
    if ( this->isVisible() )
    {
        if ( !hStats )
            if ( uodbc_open_stats( &hStats, UODBC_STATS_READ ) != 0 );

        if ( uodbc_get_stats( hStats, -1, aStats, 4 ) == 4 )
        {
            QString qs;
            
            if ( aStats[0].value.l_value > nSliderMax )
                nSliderMax = aStats[0].value.l_value;
            if ( aStats[1].value.l_value > nSliderMax )
                nSliderMax = aStats[1].value.l_value;
            if ( aStats[2].value.l_value > nSliderMax )
                nSliderMax = aStats[2].value.l_value;
            if ( aStats[3].value.l_value > nSliderMax )
                nSliderMax = aStats[3].value.l_value;
    
            qs.sprintf( "%d", aStats[0].value.l_value );
            pEnv->setText( qs );
            pEnvSlider->setMinValue( 0-nSliderMax );
            pEnvSlider->setValue( 0-aStats[0].value.l_value );
            
            qs.sprintf( "%d", aStats[1].value.l_value );
            pCon->setText( qs );
            pConSlider->setMinValue( 0-nSliderMax );
            pConSlider->setValue( 0-aStats[1].value.l_value );
    
            qs.sprintf( "%d", aStats[2].value.l_value );
            pSta->setText( qs );
            pStaSlider->setMinValue( 0-nSliderMax );
            pStaSlider->setValue( 0-aStats[2].value.l_value );
    
            qs.sprintf( "%d", aStats[3].value.l_value );
            pDes->setText( qs );
            pDesSlider->setMinValue( 0-nSliderMax );
            pDesSlider->setValue( 0-aStats[3].value.l_value );
        }
    }
/*
    else
    {
        char szError[501];
        szError[0] = '\0';
        pEnv->setText( uodbc_stats_error( szError, sizeof(szError)-1 ) );
    }
*/    
}
Пример #3
0
void ODBCDialog::updateStatistics()
{
	// Variables...
	int pidTotal = 0;
	bool statsFail = FALSE;
	int handleNum = 0;
	QString tempString;
	QString processUser = "";
	QString processName = "";
	QFile processFile;
	uid_t userID;
	struct passwd* passwdItem;

	// Set file name...
	processFile.setName("status");

	// Get statistics...
	if (!statsHandle)
	{
		if (uodbc_open_stats(&statsHandle, UODBC_STATS_READ) != 0)
		{
			statsFail = TRUE;
			statsHandle = 0;
		}
	}

	if (statsFail == FALSE)
	{
		// Get stats for summary tab...
		if (uodbc_get_stats(statsHandle, -1, statsResult, 4) == 4)
		{
			// Get progress bars max value...
			if (statsResult[0].value.l_value > progressMaxValue)
				progressMaxValue = statsResult[0].value.l_value;
			if (statsResult[1].value.l_value > progressMaxValue)
				progressMaxValue = statsResult[1].value.l_value;
			if (statsResult[2].value.l_value > progressMaxValue)
				progressMaxValue = statsResult[2].value.l_value;
			if (statsResult[3].value.l_value > progressMaxValue)
				progressMaxValue = statsResult[3].value.l_value;

			// Set progress bars and label values...
			envProgress->setProgress(statsResult[0].value.l_value, progressMaxValue);
			envLabel->setText(QString::number(statsResult[0].value.l_value));
			conProgress->setProgress(statsResult[1].value.l_value, progressMaxValue);
			conLabel->setText(QString::number(statsResult[1].value.l_value));
			staProgress->setProgress(statsResult[2].value.l_value, progressMaxValue);
			staLabel->setText(QString::number(statsResult[2].value.l_value));
			desProgress->setProgress(statsResult[3].value.l_value, progressMaxValue);
			desLabel->setText(QString::number(statsResult[3].value.l_value));

			// Get stats for details tab...
			pidTotal = uodbc_get_stats(statsHandle, 0, pidResults, MAXPROCESSES);
			detailsTable->setNumRows(pidTotal);

			// Update stat details table...
			for (int pidNumber = 0; pidNumber < pidTotal; pidNumber++)
        	{
				// Reset variables...
				processUser = "";
				processName = "";


				handleNum = uodbc_get_stats(statsHandle, pidResults[pidNumber].value.l_value, handleResult, MAXHANDLES);
				if (handleNum > 0)
				{
					// Get Process information (program name, username)...
					tempString = "/proc/";
					tempString.append(QString::number(pidResults[pidNumber].value.l_value));
					QDir::setCurrent(tempString);
					if (processFile.open(IO_ReadOnly))
					{
						while ((processFile.atEnd() == FALSE) && ((processName.isEmpty() == TRUE) || (processUser.isEmpty() == TRUE)))
						{
							processFile.readLine(tempString, 500);
							if (tempString.contains("Name:") > 0)
							{
								processName = tempString.right(tempString.length() - 6);
							}
							if (tempString.contains("Uid:") > 0)
							{
								processUser = tempString.mid(5, (tempString.find((char)9, 6) - 5));
								userID = processUser.toInt();
								passwdItem = getpwuid(userID);
								processUser = passwdItem->pw_name;
							}
						}
						processFile.close();
					}

					// Update the table...
					detailsTable->setText(pidNumber, 0, processUser);
					detailsTable->setText(pidNumber, 1, processName);
					detailsTable->setText(pidNumber, 2, QString::number(pidResults[pidNumber].value.l_value));
					for (int handle = 0; handle < MAXHANDLES; handle++)
					{
						detailsTable->setText(pidNumber, handle + 3, QString::number(handleResult[handle].value.l_value));
					}
				}
				else
				{
					clearDetailRow(pidNumber);
				}
			}
		}
		else
		{
			statsFail = TRUE;
		}
	}
}
Пример #4
0
DMHENV __alloc_env( void )
{
    DMHENV environment = NULL;

    mutex_entry( &mutex_lists );

    environment = calloc( sizeof( *environment ), 1 );

    if ( environment )
    {
        char tracing_string[ 64 ];
        char tracing_file[ 64 ];

#if defined ( COLLECT_STATS ) && defined( HAVE_SYS_SEM_H )
        if (uodbc_open_stats(&environment->sh, UODBC_STATS_WRITE) != 0)
        {
            ;
        }
        uodbc_update_stats(environment->sh, UODBC_STATS_TYPE_HENV, (void *)1);
#endif
        
        /*
         * add to list of env handles
         */

        environment -> next_class_list = enviroment_root;
        enviroment_root = environment;
        environment -> type = HENV_MAGIC;

        SQLGetPrivateProfileString( "ODBC", "Trace", "No",
                    tracing_string, sizeof( tracing_string ), 
                    "odbcinst.ini" );

        if ( tracing_string[ 0 ] == '1' ||
                toupper( tracing_string[ 0 ] ) == 'Y' ||
                    ( toupper( tracing_string[ 0 ] ) == 'O' &&
                    toupper( tracing_string[ 1 ] ) == 'N' ))
        {
            SQLGetPrivateProfileString( "ODBC", "TraceFile", "/tmp/sql.log",
                    tracing_file, sizeof( tracing_file ), 
                    "odbcinst.ini" );

            /*
             * start logging
             */

            SQLGetPrivateProfileString( "ODBC", "TracePid", "No",
                    tracing_string, sizeof( tracing_string ), 
                    "odbcinst.ini" );

            if ( tracing_string[ 0 ] == '1' ||
                        toupper( tracing_string[ 0 ] ) == 'Y' ||
                        ( toupper( tracing_string[ 0 ] ) == 'O' &&
                        toupper( tracing_string[ 1 ] ) == 'N' ))
            {
                dm_log_open( "ODBC", tracing_file, 1 );
            }
            else
            {
                dm_log_open( "ODBC", tracing_file, 0 );
            }

            sprintf( environment -> msg,
                    "\n\t\tExit:[SQL_SUCCESS]\n\t\t\tEnvironment = %p",	environment );

            dm_log_write( __FILE__,
                    __LINE__,
                    LOG_INFO,
                    LOG_INFO, environment -> msg );
        }
    }

    setup_error_head( &environment -> error, environment,
            SQL_HANDLE_ENV );

    mutex_exit( &mutex_lists );

    return environment;
}