1
I am developing an application that performs collections SNMP on a given server. I am using the library SnmpSharpNet
.
I’m getting to do the normal snmpwalk in a certain OID.
However, there is a OID which lists the running processes of the server, and I can extract the process number.
With the case number, I make a append
of him at the end of another OID and then I perform a GET
to get the name of the process.
What I’m not able to do is, if the number of the process is greater than a certain number, for example 16535
, he is giving an error during the execution saying that the number is large.
From what I understand of the code, if the number is greater than 127
it transforms into several bytes:
// Convert the string MIB into a byte array of integer values
// Unfortunately, values over 128 require multiple bytes
// which also increases the MIB length
for (i = 0; i < orgmiblen; i++)
{
temp = Convert.ToInt16(mibvals[i]);
if (temp > 127)
{
mib[cnt] = Convert.ToByte(128 + (temp / 128));
mib[cnt + 1] = Convert.ToByte(temp - ((temp / 128) * 128));
cnt += 2;
miblen++;
} else
{
mib[cnt] = Convert.ToByte(temp);
cnt++;
}
}
And I couldn’t find a way to do that for big numbers, in case 16535
(which is the process number running on the server).
Any idea?