[AGENT++] Problem with several PDU:s

Bp Sm bpexjobb at hotmail.com
Wed Dec 3 11:47:36 CET 2003


Hello!

Thanks for all help before!

We have a problem, that probably is related to our code. When we use one PDU 
all seems to work fine, but when the program runs with several PDU:s, we get 
folowing error in the callback function “Closing session with outstanding 
request”.

Here we create an array of PDU:s and insert our VB:s into each PDU.

*****************************************************************
Pdu* arrayOfPDUs;
NrOfPDUs = CalcNumbersOfPDUs();
arrayOfPDUs = new Pdu[NrOfPDUs];
Vb *vbCritical = new Vb[(ports*2)];
int count = 0;
int n = 0;
for(int i=0; i<(ports*2); i+=2)
{
strcpy(InOctets, ifInOctets);
strcat(InOctets, arrayOfPorts[count].getPortNr());
	vbCritical[i].set_oid(InOctets);
	arrayOfPDUs[n] += vbCritical[i];
	strcpy(OutOctets, ifOutOctets);
	strcat(OutOctets, arrayOfPorts[count].getPortNr());
	vbCritical[i+1].set_oid(OutOctets);
	arrayOfPDUs[n] += vbCritical[i+1];
	count++;
	if(i % 50 == 0 && i != 0)
		n++;
}
******************************************************************

The snmp get requests is done by dynamically ask with different PDU:s in 
following for loop.

******************************************************************
for(int a = 0; a < NrOfPDUs; a++)
{
	if((status=snmp.get(arrayOfPDUs[a], target, callback, 0)) != 
SNMP_CLASS_SUCCESS)
	{
		cout << snmp.error_msg(status);
		return;
	}
}
******************************************************************

The SNMP-object seems to be destroyed, we get reason = -8, in our callback 
function.

******************************************************************
void callback( int reason, Snmp* session, Pdu &pdu, SnmpTarget &target, void 
* CallBackData)
{
	callbackVbs = pdu.get_vb_count();
	Vb *vbInOut = new Vb[callbackVbs];
	if( reason == SNMP_CLASS_ASYNC_RESPONSE)
	{
		for(int b=0; b<callbackVbs; b+=2)
		{
			pdu.get_vb(vbInOut[b], b);
			pdu.get_vb(vbInOut[b+1], b+1);
	arrayOfPorts[countObjects].CalcDiff(atof(vbInOut[b].get_printable_value()), 
atof(vbInOut[b+1].get_printable_value()));
			countObjects++;
		}

	}
	else
	{
		cout << snmp.error_msg( reason) << "\n";
	}
	delete [] vbInOut;

};
******************************************************************

/Greetings Per and Birger

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/




More information about the AGENTPP mailing list