snmp API: read_objid should not return an error in the case - SNMP
This is a discussion on snmp API: read_objid should not return an error in the case - SNMP ; I am learning snmp API by tutorials
( http://net-snmp.sourceforge.net/wiki....php/Tutorials ). One of
them prints an error in place where is no one as I suppose,
http://net-snmp.sourceforge.net/wiki...nc_Application
here is the function from that tutorial:
void initialize (void)
{
struct oid *op ...
-
snmp API: read_objid should not return an error in the case
I am learning snmp API by tutorials
(http://net-snmp.sourceforge.net/wiki....php/Tutorials). One of
them prints an error in place where is no one as I suppose,
http://net-snmp.sourceforge.net/wiki...nc_Application
here is the function from that tutorial:
void initialize (void)
{
struct oid *op = oids;
/* Win32: init winsock */
SOCK_STARTUP;
/* initialize library */
init_snmp("asynchapp");
/* parse the oids */
while (op->Name) {
op->OidLen = sizeof(op->Oid)/sizeof(op->Oid[0]);
if (!read_objid(op->Name, op->Oid, &op->OidLen)) {
snmp_perror("read_objid");
exit(1);
}
op++;
}
}
Below cut of the code reproduces an assumed fault:
#include
#include
#include
int main(int argc, char ** argv)
{
oid anOID[MAX_OID_LEN];
size_t anOID_len = MAX_OID_LEN;
init_snmp("snmptest");
if(!read_objid("system.sysDescr.0", anOID, &anOID_len))
snmp_perror("read_objid");
else
puts("no errors");
}
the output:
No log handling enabled - turning on stderr logging
read_objid: Unknown Object Identifier (Sub-id not found: (top) -> system)
What is wrong there?
Thanks in advance.
--
/BR, Alexander
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: snmp API: read_objid should not return an error in the case
2008/7/18 Alexander Bubnov :
> I am learning snmp API by tutorials
> (http://net-snmp.sourceforge.net/wiki....php/Tutorials). One of
> them prints an error in place where is no one as I suppose,
> http://net-snmp.sourceforge.net/wiki...nc_Application
>
Might be stating the obvious but ensure that the MIBS and MIBDIR
environment variables are setup, for testing use MIBS=ALL - makes life
simpler than wondering what's loaded and what isn't...
Have a look at the snmptranslate documentation and use it to check
what mibs are loaded (hint: call snmptranslate with the flags to
translate names to OID and pass it the name of the object you are
trying to get.).
--
Richard Horton
Users are like a virus: Each causing a thousand tiny crises until the
host finally dies.
http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
http://www.pbase.com/arimus - My online photogallery
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: snmp API: read_objid should not return an error in the case
I guess the cause is not in path of mib because snmptranslate works
fine with that name:
~/trial/snmp> snmptranslate -IR sysDescr.0
SNMPv2-MIB::sysDescr.0
~/trial/snmp> snmptranslate -On SNMPv2-MIB::sysDescr.0
..1.3.6.1.2.1.1.1.0
~/trial/snmp> snmptranslate -Tp -IR system
+--system(1)
|
+-- -R-- String sysDescr(1)
| Textual Convention: DisplayString
| Size: 0..255
+-- -R-- ObjID sysObjectID(2)
+-- -R-- TimeTicks sysUpTime(3)
| |
| +--sysUpTimeInstance(0)
|
+-- -RW- String sysContact(4)
| Textual Convention: DisplayString
| Size: 0..255
+-- -RW- String sysName(5)
| Textual Convention: DisplayString
| Size: 0..255
+-- -RW- String sysLocation(6)
| Textual Convention: DisplayString
| Size: 0..255
+-- -R-- INTEGER sysServices(7)
| Range: 0..127
+-- -R-- TimeTicks sysORLastChange(8)
| Textual Convention: TimeStamp
|
+--sysORTable(9)
|
+--sysOREntry(1)
| Index: sysORIndex
|
+-- ---- INTEGER sysORIndex(1)
| Range: 1..2147483647
+-- -R-- ObjID sysORID(2)
+-- -R-- String sysORDescr(3)
| Textual Convention: DisplayString
| Size: 0..255
+-- -R-- TimeTicks sysORUpTime(4)
Textual Convention: TimeStamp
and if I pass "SNMPv2-MIB::sysDescr.0" instead of "system.sysDescr.0"
read_objid works as I expected:
#include
#include
#include
int main(int argc, char ** argv)
{
oid anOID[MAX_OID_LEN];
size_t anOID_len = MAX_OID_LEN;
init_snmp("snmptest");
/*if(!read_objid("system.sysDescr.0", anOID, &anOID_len))*/
if(!read_objid("SNMPv2-MIB::sysDescr.0", anOID, &anOID_len))
snmp_perror("read_objid");
else
puts("no errors");
}
~/trial/snmp> ./a.out
no errors
It is possible read_objid() uses different format from get_node() function...
2008/7/18 Richard Horton :
> 2008/7/18 Alexander Bubnov :
>> I am learning snmp API by tutorials
>> (http://net-snmp.sourceforge.net/wiki....php/Tutorials). One of
>> them prints an error in place where is no one as I suppose,
>> http://net-snmp.sourceforge.net/wiki...nc_Application
>>
>
> Might be stating the obvious but ensure that the MIBS and MIBDIR
> environment variables are setup, for testing use MIBS=ALL - makes life
> simpler than wondering what's loaded and what isn't...
>
> Have a look at the snmptranslate documentation and use it to check
> what mibs are loaded (hint: call snmptranslate with the flags to
> translate names to OID and pass it the name of the object you are
> trying to get.).
>
>
>
>
> --
> Richard Horton
> Users are like a virus: Each causing a thousand tiny crises until the
> host finally dies.
> http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
> http://www.pbase.com/arimus - My online photogallery
>
--
/BR, Alexander
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
RE: snmp API: read_objid should not return an error in the case
> From: net-snmp-users-bounces@lists.sourceforge.net
> [mailto:net-snmp-users-bounces@lists.sourceforge.net] On
> Behalf Of Alexander Bubnov
> Sent: Friday, July 18, 2008 3:16 AM
> I guess the cause is not in path of mib because snmptranslate works
> fine with that name:
The snmptranslate -IR randomizes access, whicvh allows "system" to be recognized:
[SNIP]
lap> snmptranslate system
No log handling enabled - turning on stderr logging
system: Unknown Object Identifier (Sub-id not found: (top) -> system)
lap> snmptranslate -IR system
SNMPv2-MIB::system
lap>
[/SNIP]
In your code you should specify MIB and name, i.e. "SNMPv2-MIB::system". You should *always* use fully qualified name in code - using the OID is best.
HTH,
Mike
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
-
Re: snmp API: read_objid should not return an error in the case
Hi!
a lot of thanks!
2008/7/18 Mike Ayers :
>> From: net-snmp-users-bounces@lists.sourceforge.net
>> [mailto:net-snmp-users-bounces@lists.sourceforge.net] On
>> Behalf Of Alexander Bubnov
>> Sent: Friday, July 18, 2008 3:16 AM
>
>> I guess the cause is not in path of mib because snmptranslate works
>> fine with that name:
>
> The snmptranslate -IR randomizes access, whicvh allows "system" to be recognized:
>
> [SNIP]
> lap> snmptranslate system
> No log handling enabled - turning on stderr logging
> system: Unknown Object Identifier (Sub-id not found: (top) -> system)
> lap> snmptranslate -IR system
> SNMPv2-MIB::system
> lap>
> [/SNIP]
>
> In your code you should specify MIB and name, i.e. "SNMPv2-MIB::system". You should *always* use fully qualified name in code - using the OID is best.
>
>
> HTH,
>
> Mike
>
--
/BR, Alexander
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users