On Mon, 2005-04-25 at 11:05, Shivali Gupta wrote:
> how can i detect that the specified OID is invalid.

By querying the agent.


> in this case "HOST-RESOURCES-MIB::hrStorageType.8"
> is an invalid OID since the valid ones range from
>  "HOST-RESOURCES-MIB::hrStorageType.1" to
>  "HOST-RESOURCES-MIB::hrStorageType.6".

That may be true for one particular host, it's not
true in general.  On the (sole) agent on my laptop
that's currently got HostRes support configured in,
this column ranges from 1-5, then jumps to 101-103.

There's no way of telling from the MIB file,
exactly which rows are present on a given agent.
You've got to send the query.


>  df =
>  read_objid("HOST-RESOURCES-MIB::hrStorageType.8",
>              id_oid1, &id_len1);

That converts the name "hrStorageType" into a numeric
OID.  A positive result (df == 1) means that this
conversion succeeded, and 'id_oid1' will contain
the numeric OID.  It does *not* indicate that there
is necessarily a value corresponding to that OID
on any given agent.
  It simply means that it's worth asking.



>  status = snmp_synch_response(sess_handle, pdu[nm-1],
>              &response);

A successful result here (status==0) means that the
query was sent, and the remote agent responded.
It doesn't necessarily mean that the remote agent
returned a value for this IUD - just that it returned
*something*, so it's worth looking at the 'response'
structure.


As Mark suggests, the first thing is to check
the 'response.errstat' field, which will tell you
whether the query succeeded or failed.
  If this was an SNMPv1 query, then a value of 2
(noSuchName) will indicate that the OID you asked
for doesn't exist on that agent.

  If this was an SNMPv2c or SNMPv3 query, then the
errstat field will probably be 0 (for success),
and you'd need to look at the response.variables
list.  The type field of that varbind will probably
be 0x81 (or 'noSuchInstance')


Dave



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to