Example #1
0
static void SendData(char *file)
{
    DataFile   = fopen(file, "r");
    bool error = mfalse;

    done      = mfalse;
    everError = mfalse;

    if (DataFile == NULL) {
        LogMsg(0, LogLevel, LogFile, "Could not Open %s for reading", file);
        done  = mtrue;
        error = mtrue;
    }

    int recordCounts[adviceClass_last];
    for (int i = 0; i < adviceClass_last; i++)
        recordCounts[i] = 0;

    if (strncmp(file, DISCO_ID, strlen(DISCO_ID)) == 0) {
        GetDiscoQ(file, &error);
        recordCounts[adviceDiscoQ]++;
    } else if (strncmp(file, RECONN_ID, strlen(RECONN_ID)) == 0) {
        GetReconnQ(file, &error);
        recordCounts[adviceReconnQ]++;
    } else {
        error = mtrue;
        LogMsg(0, LogLevel, LogFile, "Unknown type of file: %s", file);
        LogErrorPoint(recordCounts);
    }

    if (error == mtrue) {
        everError = mtrue;
        LogErrorPoint(recordCounts);
        error = mfalse;
    }

    fclose(DataFile);
    if (everError == mfalse) {
        if (removeOnDone == mtrue) {
            if (unlink(file))
                LogMsg(0, LogLevel, LogFile,
                       "Could not unlink %s, but spooled it with no errors",
                       file);
        }
    } else
        LogMsg(0, LogLevel, LogFile, "Error spooling file %s", file);
}
Example #2
0
int main(int argc, char *argv[]) {

    int recordCounts[SRVOVRFLW+1];
    for (int i=0;i<=SRVOVRFLW;i++)
	recordCounts[i] = 0;

    bool done = mfalse;
    bool error = mfalse;
    long rt;
    long count;
    long counter = 0;
    while (done == mfalse) {
	counter++;
	count = ScanPastMagicNumber(&rt);
	if (count > 0) {
	    LogMsg(0,LogLevel,LogFile,
		   "Out of sync with data file: %d words skipped to next sync point",
		   count);
	    LogErrorPoint(recordCounts);
	} else if (count < 0) {
	    LogMsg(0,LogLevel,LogFile,"End of data file");
	    LogErrorPoint(recordCounts);
	}
	printf("Record #%d:  Type=%d\n", counter, rt); 
	switch(rt) {
	case -1:
	    done = mtrue;
	    break;
	case SESSION_TAG:
	    error = PrintVmonSession();
	    recordCounts[SESSION]++;
	    break;
	case COMM_TAG:
	    error = PrintVmonCommEvent();
	    recordCounts[COMM]++;
	    break;
	case CLNTCALL_TAG:
	    error = PrintClientCalls();
	    recordCounts[CLNTCALL]++;
	    break;
	case CLNTMCALL_TAG:
	    error = PrintClientMCalls();
	    recordCounts[CLNTMCALL]++;
	    break;
	case CLNTRVM_TAG:
	    error = PrintClientRVM();
	    recordCounts[CLNTRVM]++;
	    break;
	case VCB_TAG:
 	    error = PrintVCB();
 	    recordCounts[VCB]++;
 	    break;
	case ADVICE_TAG:
	    error = PrintAdviceCalls();
	    recordCounts[ADVICE]++;
	    break;
	case MINICACHE_TAG:
	    error = PrintMiniCache();
	    recordCounts[MINICACHE]++;
	    break;
	case OVERFLOW_TAG:
	    error = PrintVmonOverflow();
	    recordCounts[OVERFLOW]++;
	    break;
	case SRVCALL_TAG:
	    error = PrintSrvCall();
	    recordCounts[SRVCALL]++;
	    break;
	case SRVRES_TAG:
	    error = PrintResEvent();
	    recordCounts[SRVRES]++;
	    break;
	case SRVRVMRES_TAG:
	    error = PrintRvmResEvent();
	    recordCounts[SRVRVMRES]++;
	    break;
	case SRVOVRFLW_TAG:
	    error = PrintSrvOvrflw();
	    recordCounts[SRVOVRFLW]++;
	    break;
	case IOTINFO_TAG:
	    error = PrintIotInfoCall();
	    recordCounts[IOTINFO]++;
	    break;
	case IOTSTAT_TAG:
	    error = PrintIotStatsCall();
	    recordCounts[IOTSTAT]++;
	    break;
	case SUBTREE_TAG:
	    error = PrintSubtreeStatsCall();
	    recordCounts[SUBTREE]++;
	    break;
	case REPAIR_TAG:
	    error = PrintRepairStatsCall();
	    recordCounts[REPAIR]++;
	    break;
	case RWSSTAT_TAG:
	    error = PrintRwsStatsCall();
	    recordCounts[RWSSTAT]++;
	    break;
	case MAGIC_NUMBER:
	    printf("Magic Number found\n");
	    break;
	default:
	    LogMsg(0,LogLevel,LogFile,"parselog: bogus rt (%d)",rt);
	    error = mtrue;
	    break;
	}
	if (error == mtrue) {
	    LogErrorPoint(recordCounts);
	    error = mfalse;
	}
    }
}
Example #3
0
static void SendData(char *file)
{
    DataFile = fopen(file, "r");
    bool error = mfalse;

    done = mfalse;
    everError = mfalse;
    
    if (DataFile == NULL)
    {
	LogMsg(0,LogLevel,LogFile,"Could not Open %s for reading",file);
	done = mtrue;
	error = mtrue;
    }
    
    int recordCounts[dataClass_last_tag];
    for (int i=0;i<dataClass_last_tag;i++)
	recordCounts[i] = 0;

    long rt;
    long count;
    while (done == mfalse) {
	count = ScanPastMagicNumber(&rt);
	if (count > 0) {
	    LogMsg(0,LogLevel,LogFile,
		   "Out of sync with data file: %d words skipped to next sync point",
		   count);
	    everError = mtrue;
	    LogErrorPoint(recordCounts);
	} else if (count < 0) {
	    LogMsg(0,LogLevel,LogFile,"End of data file");
	    LogErrorPoint(recordCounts);
	}
	switch(rt) {
	case -1:
	    done = mtrue;
	    break;
	case SESSION_TAG:
	    GetSession(&error);
	    recordCounts[SESSION]++;
	    break;    
	case COMM_TAG:
	    GetComm(&error);
	    recordCounts[COMM]++;
	    break;
	case CLNTCALL_TAG:
	    GetClientCall(&error);
	    recordCounts[CLNTCALL]++;
	    break;
	case CLNTMCALL_TAG:
	    GetClientMCall(&error);
	    recordCounts[CLNTMCALL]++;
	    break;
	case CLNTRVM_TAG:
	    GetClientRVM(&error);
	    recordCounts[CLNTRVM]++;
	    break;
	case VCB_TAG:
	    GetVCB(&error);
	    recordCounts[VCB]++;
	    break;
	case ADVICE_TAG:
	    GetAdvice(&error);
	    recordCounts[ADVICE]++;
	    break;
	case MINICACHE_TAG:
	    GetMiniCache(&error);
	    recordCounts[MINICACHE]++;
	    break;
	case OVERFLOW_TAG:
	    GetOverflow(&error);
	    recordCounts[OVERFLOW]++;
	    break;
	case SRVCALL_TAG:
	    GetSrvCall(&error);
	    recordCounts[SRVCALL]++;
	    break;
	case SRVRES_TAG:
	    GetResEvent(&error);
	    recordCounts[SRVRES]++;
	    break;
	case SRVRVMRES_TAG:
	    GetRvmResEvent(&error);
	    recordCounts[SRVRVMRES]++;
	    break;
	case SRVOVRFLW_TAG:
	    GetSrvOverflow(&error);
	    recordCounts[SRVOVRFLW]++;
	    break;
	case IOTINFO_TAG:
	    GetIotInfo(&error);
	    recordCounts[IOTINFO]++;
	    break;
	case IOTSTAT_TAG:
	    GetIotStats(&error);
	    recordCounts[IOTSTAT]++;
	    break;
	case SUBTREE_TAG:
	    GetSubtree(&error);
	    recordCounts[SUBTREE]++;
	    break;
	case REPAIR_TAG:
	    GetRepair(&error);
	    recordCounts[REPAIR]++;
	    break;
	case RWSSTAT_TAG:
	    GetRwsStats(&error);
	    recordCounts[RWSSTAT]++;
	    break;
	default:
	    LogMsg(1,LogLevel,LogFile,"main: bogus rt (%d)", rt);
	    error = mtrue;
	}
	if (error == mtrue) {
	    everError = mtrue;
	    LogErrorPoint(recordCounts);
	    error = mfalse;
	}
    }
    fclose(DataFile);
    if (everError == mfalse) 
    {
	if (removeOnDone == mtrue)
	{
	    if (unlink(file))
		LogMsg(0,LogLevel,LogFile,"Could not unlink %s, but spooled it with no errors",
		       file);
	}
    } else
	LogMsg(0,LogLevel,LogFile,"Error spooling file %s",file);
}