Full code of my scalar registration. Changed to register all scalars one by one
instead of in group.
The oid_wrapper class is a wrapper around oid that contains an oid pointer and
the length of that oid.
The scalar class cointains data on each scalars.
void
myclient::registerScalars() {
int scalar_counter = 0;
map<oid_wrapper, scalar>::iterator scalar_iterator;
for (scalar_iterator = scalars.begin();
scalar_iterator != scalars.end();
scalar_iterator++) {
const oid_wrapper _oid_wrapper = (*scalar_iterator).first;
const scalar _scalar = (*scalar_iterator).second;
const string scalar_name = _scalar.getName();
const oid *scalar_oid = _oid_wrapper.getOid();
const long scalar_length = _oid_wrapper.getLength();
const char *buffy = scalar_name.c_str();
int returnValue = netsnmp_register_scalar(
netsnmp_create_handler_registration(buffy,
handle_snmp,
scalar_oid,
OID_LENGTH(scalar_oid),
HANDLER_CAN_RONLY
));
if (returnValue == MIB_REGISTERED_OK) {
scalar_counter++;
} else if (returnValue == MIB_DUPLICATE_REGISTRATION) {
} else if (returnValue == MIB_REGISTRATION_FAILED) {
}
}
cout << "Number of scalars registered: " << scalar_counter << endl;
}
The output is always only 1.
/Sverre
----- Original Message -----
Fra: "Dave Shield" <[email protected]>
Til: "Sverre Moe" <[email protected]>
Kopi: "net-snmp-users" <[email protected]>
Sendt: 26. oktober 2012 14:13:04
Emne: Re: Debugging SNMP
On 26 October 2012 12:16, Sverre Moe <[email protected]> wrote:
> The first scalar group I tried to register got value 0(MIB_REGISTERED_OK).
>
> All the others got value -1(MIB_REGISTRATION_FAILED or
> MIB_DUPLICATE_REGISTRATION).
Do the other groups use the same "root" OID as the first registration,
or do they all use different roots?
The usual cause of a duplicate registration would be having two
invocations of netsnmp_register_xxx() with the same root OID
(i.e. the third/fourth parameters to the
netsnmp_create_handler_registration call)
If that's not the case, it's probably worth posting the full code
of the block used to register these groups.
Dave
CONFIDENTIALITY
This e-mail and any attachment contain KONGSBERG information which may be
proprietary, confidential or subject to export regulations, and is only meant
for the intended recipient(s). Any disclosure, copying, distribution or use is
prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in
error, please delete it immediately from your system and notify the sender
properly.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users