sourceforge tutorial sample code problem

This is a discussion on sourceforge tutorial sample code problem within the SNMP Users forums, part of the Networking and Network Related category; Hi, there! I compiled some sample code provided by sorceforge(http://net-snmp.sourceforge.net/tuto...app/index.html), but ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-23-2008
xiao ren
 
Posts: n/a
Default sourceforge tutorial sample code problem

Hi, there!

I compiled some sample code provided by sorceforge(http://net-snmp.sourceforge.net/tuto...app/index.html), but it will run into error when call the 'initialize()' function:

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)) { //########IT WILL RUN INTO ERROR HERE!!#########
snmp_perror("read_objid");
exit(1);
}
op++;
}
}

The program will report 'read_objid: Unknown Object Identifier (Sub-id not found: (top) -> system)'.

And I paste oid definition here:

struct oid {
const char *Name;
oid Oid[MAX_OID_LEN];
int OidLen;
} oids[] = {
{ "system.sysDescr.0" },
{ "interfaces.ifNumber.1" },
{ "interfaces.ifNumber.0" },
{ NULL }
};

It seems that read_objid function don't understand what is 'system.sysDesc.0', could anybody tell me why this error happend? Thanks!
--------------
xiao ren
2008-06-23


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
  #2 (permalink)  
Old 06-23-2008
Dave Shield
 
Posts: n/a
Default Re: sourceforge tutorial sample code problem

2008/6/23 xiao ren <reign99@21cn.com>:
> The program will report 'read_objid: Unknown Object Identifier (Sub-id not found: (top) -> system)'.


Have you installed the MIB files?
Where?

Dave

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
  #3 (permalink)  
Old 06-23-2008
xiao ren
 
Posts: n/a
Default Re: Re: sourceforge tutorial sample code problem

Hi, Dave

I don't install the MIB files, and I don't know how to install it. According to the tutorial, it seems to me that this 'asyncapp.c' sample don't need any further installation, just 'make and run'. Could you please show me where and how to install this MIB files? Thanks a lot!

------------------
xiao ren
2008-06-24

-------------------------------------------------------------
·¢¼þÈË£ºDave Shield
·¢ËÍÈÕÆÚ£º2008-06-23 23:52:52
ÊÕ¼þÈË£ºxiao ren
³*ËÍ£ºNet-snmp-users
Ö÷Ì⣺Re: sourceforge tutorial sample code problem

2008/6/23 xiao ren <reign99@21cn.com>:

> The program will report 'read_objid: Unknown Object Identifier (Sub-id not found: (top) -> system)'.


Have you installed the MIB files?
Where?

Dave

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
  #4 (permalink)  
Old 06-23-2008
xiao ren
 
Posts: n/a
Default Re: Re: sourceforge tutorial sample code problem

Hi, Dave

I replaced the function read_objid() to snmp_parse_oid() and the sample application works fine. Is read_objid() updated or something?

------------------
xiao ren
2008-06-24

-------------------------------------------------------------
·¢¼þÈË£ºDave Shield
·¢ËÍÈÕÆÚ£º2008-06-23 23:52:52
ÊÕ¼þÈË£ºxiao ren
³*ËÍ£ºNet-snmp-users
Ö÷Ì⣺Re: sourceforge tutorial sample code problem

2008/6/23 xiao ren <reign99@21cn.com>:

> The program will report 'read_objid: Unknown Object Identifier (Sub-id not found: (top) -> system)'.


Have you installed the MIB files?
Where?

Dave

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
  #5 (permalink)  
Old 06-24-2008
Dave Shield
 
Posts: n/a
Default Re: Re: sourceforge tutorial sample code problem

2008/6/23 xiao ren <reign99@21cn.com>:
> I don't install the MIB files


The MIB files are what defines the conversion between MIB object names
('system')
and numeric OIDs. If the MIB files aren't available, then the
library won't understand
object names.

> According to the tutorial, it seems to me that this 'asyncapp.c' sample don't need
>any further installation, just 'make and run'.


The application doesn't need anything special.
But it does assume that you've got the Net-SNMP library and accompanying
stuff installed.


> Could you please show me where and how to install this MIB files?


The MIB files would normally be handled as part of installing the basic
Net-SNMP software - either from source ("make install") or as part of
a binary package.



> I replaced the function read_objid() to snmp_parse_oid() and the sample
> application works fine. Is read_objid() updated or something?


Strange - snmp_parse_oid is effectively a wrapper round read_objid.
Both of them rely on having the MIB files available.

Still, if that works for you, then fair enough.

It might be worth trying read_objid with
oids[] = {
{ "SNMPv2-MIB::sysDescr.0" },
{ "IF-MIB::ifNumber.1" },
{ "IF-MIBifNumber.0" },
{ NULL }
};


That's all I can think of offhand.

Dave

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
  #6 (permalink)  
Old 06-24-2008
Mike Ayers
 
Posts: n/a
Default RE: Re: Re: sourceforge tutorial sample code problem


> From: net-snmp-users-bounces@lists.sourceforge.net
> [mailto:net-snmp-users-bounces@lists.sourceforge.net] On
> Behalf Of xiao ren
> Sent: Tuesday, June 24, 2008 2:07 AM


> And yes, I do install net-snmp lib from source, so I guess I
> have installed the MIB files already.


Part of "installed" involves locatability. This is usually done by setting the environment variables MIBDIRS and MIBS in a startup file (.bashrc, Windows "environment variables" dialog, etc.), but one can set those locally or use -M/-m flags.

> And read_objid function doesn't report error after I changed
> the oids structure according to your advice. Maybe I should
> always explicitly write the MIB name from which the oid originated?


You should always fully qualify your OIDs so the library can find them. Generally, the MIB::name reliably, produces fully qualified OIDs, but you can also use full numeric OIDs, depending on the situation.


HTH,

Mike


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0