------=_Part_2441_1852836651.1194302214846
Content-Type: text/plain; charset=gbk
Content-Transfer-Encoding: 7bit
Hi,
I wrote my own MIB file and compiled the module into the agent.When I ran "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib" and got "SYS-CONFIG-MIB::sysConfigMib = No Such Object available on this agent at this OID".
Before "make install",I ran the newly-compiled agent in a 'testing' mode:" $ agent/snmpd -f -L -d -p 9999",in another terminal I ran "snmpgetnext localhost:9999 -c public system" and I saw the agent received the packages but did not reply to them.
Where is the problem?Please help me.Thanks!
Here is my code:
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "sysConfigMib.h"
//reserved value allocate
static char def_potType[8] = "linux";
.. //some allocaeted values
/** Initializes the sysConfigMib module */
void
init_sysConfigMib(void)
{
static oid nodeType_oid[] = { 1, 3, 6, 1, 4, 1, 9953, 0, 10 };
.... //some oids
DEBUGMSGTL(("sysConfigMib", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("nodeType", handle_nodeType, nodeType_oid,
OID_LENGTH(nodeType_oid),
HANDLER_CAN_RWRITE));
.....// some scalar registration
}
int
handle_nodeType(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)def_nodeType
/* XXX: a pointer to the scalar's data */
,strlen(def_nodeType)
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
netsnmp_set_request_error(reqinfo, requests,SNMP_ERR_WRONGTYPE
);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
// if ( /* XXX if malloc, or whatever, failed: */ ) {
// netsnmp_set_request_error(reqinfo, requests,
// SNMP_ERR_RESOURCEUNAVAILABLE);
// }
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( strlen(def_nodeType) < strlen(requests->requestvb->val.string)/* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
SNMP_ERR_WRONGLENGTH);
}
strcpy(def_nodeType , (u_char *)requests->requestvb->val.string);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
// if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
// netsnmp_set_request_error(reqinfo, requests,
// SNMP_ERR_COMMITFAILED);
// }
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
// if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
// netsnmp_set_request_error(reqinfo, requests,
// SNMP_ERR_UNDOFAILED);
// }
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
...//functions
------=_Part_2441_1852836651.1194302214846
Content-Type: text/html; charset=gbk
Content-Transfer-Encoding: quoted-printable
Hi,<br>I wrote my own MIB file and compiled the module into the agent.When =
I ran "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib" and got =
"SYS-CONFIG-MIB::sysConfigMib =3D No Such Object available on this agent at=
this OID".<br>Before "make install",I ran the newly-compiled agent in a 't=
esting' mode:" $ agent/snmpd -f -L -d -p 9999",in another terminal I ran "s=
nmpgetnext localhost:9999 -c public system" and I saw the agent received th=
e packages but did not reply to them.<br>Where is the problem?Please help m=
e.Thanks!<br><br>Here is my code:<br>#include <net-snmp/net-snmp-config.=
h><br>#include <net-snmp/net-snmp-includes.h><br>#include <net-=
snmp/agent/net-snmp-agent-includes.h><br>#include "sysConfigMib.h"<br><b=
r>//reserved value allocate<br>static char def_potType[8] =3D "linux=
";<br>... //some allocaeted values<br><br>/** Initializes the sysConfigMib =
module */<br>void<br>init_sysConfigMib(void)<br>{<br> static oid no=
deType_oid[] =3D { 1, 3, 6, 1, 4, 1, 9953, 0, 10 };<br> .... //some oi=
ds <br> =
<br> DEBUGMSGTL(("=
sysConfigMib", "Initializing\n")); =
<br> =
<br> netsnmp_register=
_scalar(netsnmp_create_handler_registration =
<br> ("nodeType", handle_nodeType, n=
odeType_oid, <br> =
OID_LENGTH(nodeType_oid), =
<br> HANDLER_CAN_RWRITE)); =
<br> .....// some scalar r=
egistration <br>} =
=
<br> =
<br>int =
=
<br>handle_nodeType(netsnmp_mib_handler *handler, =
<br> netsnmp_handler_reg=
istration *reginfo, <br=
> netsnmp_agent_request_info *reqinfo, =
<br> netsnmp_request_info *=
requests) <br>{ =
=
<br> /* =
<br> =
* We are never called for a GETNEXT if it's registered as a =
<br> * "instance", as it's "magically" handl=
ed for us. <br> */ =
=
<br> =
<br> /* =
=
<br> * a instance handler also only hands us one r=
equest at a time, so <br> * we don'=
t need to loop over a list of requests; we'll only get one. =
<br> */ =
<br> =
=
<br> switch (reqinfo->mode) { =
<br> =
=
<br> case MODE_GET: =
<br> snmp_set_var=
_typed_value(requests->requestvb, ASN_OCTET_STR, =
<br> (u_char *)def_nodeType =
<br> =
/* XXX: a pointer to the scalar's data */ =
<br> ,strlen(def_nodeType) =
<br> =
/* =
<br> * XXX: the length of the dat=
a in bytes <br> =
*/ ); =
<br> break; =
<br> =
=
<br> /* =
<br> * SET REQUEST =
=
<br> * =
<br> * multiple states in the t=
ransaction. See: <br=
> * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actio=
ns.jpg <br> */ =
<br> =
case MODE_SET_RESERVE1: =
<br> netsnmp_set_request_error(req=
info, requests,SNMP_ERR_WRONGTYPE <br> =
); =
<br> } =
<br> =
break; =
<br> =
<br> case MO=
DE_SET_RESERVE2: =
<br> /* =
<br> * XXX=
malloc "undo" storage buffer =
<br> */ =
<br>// if ( /*=
XXX if malloc, or whatever, failed: */ ) { =
<br>// netsnmp_set_request_error(reqinfo, request=
s, <br>// =
SNMP_ERR_RESOURCEUNAVAILABLE); =
<br>// } =
<br> break; =
=
<br> =
<br> =
=
<br> case MODE_SET_FREE: =
<br> /* =
=
<br> * XXX: free resources allocated in RESERVE1 and/or =
<br> * RESERVE2. Something =
failed somewhere, and the states =
<br> * below won't be called. =
<br> */ =
<br=
> break; =
<br> =
<br> =
case MODE_SET_ACTION: =
<br> /* =
<br> =
* XXX: perform the value change here =
<br> */ =
<br> =
if ( strlen(def_nodeType) < strlen(requests->requestvb->val.string=
)/* XXX: error? */ ) { <br> netsnmp_set_request_error(=
reqinfo, requests, /* some error */ <br> =
SNMP_ERR_WRONGLENGTH); =
<br> } =
<br> =
strcpy(def_nodeType , (u_char *)requests->requestvb->val.string); =
<br> break; =
<br> =
=
<br> case MODE_SET_COMMIT: =
<br> =
/* =
<br> * XXX: delete temporary storage =
<br> =
*/ =
<br>// if ( /* XXX: error? */ ) {<br> =
/* =
<br> * try _really_really_ hard to nev=
er get to this point <br> =
*/<br>// netsnmp_set_request_error(reqinfo, requests, =
<br>// =
SNMP_ERR_COMMITFAILED); =
<br>// } =
<br> break; =
<=
br> =
<br> case MODE_SET_UNDO: =
<br>=
/* =
<br> * XXX: UNDO and return to prev=
ious value for the object <br> =
*/ =
<br>// if ( /* XXX: error? */ ) { =
<br> =
/* =
<br> * try _really_really_ hard to ne=
ver get to this point <br> =
*/ =
<br>// netsnmp_set_request_error(reqinfo,=
requests, <br>// =
SNMP_ERR_UNDOFAILED); =
<br>// } =
<br> break; =
=
<br> =
<br> default: =
=
<br> /* =
<br> * we should =
never get here, so this is a really bad error =
<br> */ =
<br> return SNMP_ERR_=
GENERR; =
<br> } =
<br> =
=
<br> return SNMP_ERR_NOERROR; =
<br>} <br>....//functions<br><br=
><!-- footer --><br>
<hr>
<table width=3D"100%%" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">
<tr>
<td width=3D"50" height=3D"50"><img src=3D"http://mimg.163.com/hd/163/1=
63footer/163footer_50.jpg" alt=3D"LOGO" width=3D"50" height=3D"50"></td>
<td style=3D"padding:5px;"><a style=3D"font-size:12px;color:black; line=
-height:20px;text-decoration:none;" href=3D"http://popme.163.com/link/00351=
5_0929_938.html">=B0=D1=B0=AE=D0=C4=D7=A2=C8=EB=C5=A3=C4=CC=A3=AC=B9=B2=CD=
=AC=C4=FD=BE=DB=D5=E2=B7=DD=C1=A6=C1=BF</a><br /><a style=3D"font-size:12px=
;line-height:20px; color:black; text-decoration:none;" href=3D"http://popme=
.163.com/link/003515_0929_938.html">=BF=EC=C0=B4=B2=CE=BC=D3=C3=C9=C5=A3=C3=
=E2=B7=D1=D4=F9=C4=CC=B0=AE=D0=C4=D0=D0=B6=AF </a></td>
</tr>
</table>
------=_Part_2441_1852836651.1194302214846--
--===============0584717587==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--===============0584717587==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Net-snmp-coders mailing list
Net-snm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
--===============0584717587==--
> Where is the problem?Please help me.Thanks!
Can you please try working through the checklist in the FAQ entry
I've added my code to this template and it still doesn't work. Why not?
http://www.net-snmp.org/wiki/index.php/FAQ:Coding_13
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
------=_Part_39843_18721722.1194405125112
Content-Type: text/plain; charset=gbk
Content-Transfer-Encoding: quoted-printable
Hi Dave,I followed the FAQ:Coding 13 you mentioned.In the third step "Is th=
e initialisation routine being run?",I ran "/usr/local/sbin/snmpd -f -L -Ds=
ysConfigMib",and got "
sysConfigMib: Initializing //DEBUGMSGTL information
Warning: no access control information configured.
It's unlikely this agent can serve any useful purpose in this state.
Run "snmpconf -g basic_setup" to help you configure the snmpd.conf file f=
or this agent.
NET-SNMP version 5.1.2
"
It is said to be the access control problem.The lines related in /etc/snmp/=
snmpd.conf:
"
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
access notConfigGroup "" any noauth exact all none none
"
Then I ran "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib" in =
another terminal window,and got "Timeout: No Response from localhost".
=D4=DA2007-11-06=A3=AC"Dave Shield" <D.T.S...@liverpool.ac.uk> =D0=B4=B5=
=C0=A3=BA
On 05/11/2007, wqs <wqs...@163.com> wrote:
> I wrote my own MIB file and compiled the module into the agent.
> When I ran "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib"
> and got "SYS-CONFIG-MIB::sysConfigMib =3D No Such Object ...
> Where is the problem?Please help me.Thanks!
Can you please try working through the checklist in the FAQ entry
I've added my code to this template and it still doesn't work. Why not?
http://www.net-snmp.org/wiki/index.php/FAQ:Coding_13
Dave
------=_Part_39843_18721722.1194405125112
Content-Type: text/html; charset=gbk
Content-Transfer-Encoding: quoted-printable
Hi Dave,I followed the FAQ:Coding 13 you mentioned.In the third step "Is th=
e initialisation routine being run?",I ran "/usr/local/sbin/snmpd -f -L -Ds=
ysConfigMib",and got "<br>sysConfigMib: Initializing //DEBUGMSGTL informati=
on<br>Warning: no access control information configured.<br> It's unlikely=
this agent can serve any useful purpose in this state.<br> Run "snmpconf =
-g basic_setup" to help you configure the snmpd.conf file for this agent.<b=
r>NET-SNMP version 5.1.2<br>"<br>It is said to be the access control proble=
m.The lines related in /etc/snmp/snmpd.conf:<br>"<br>com2sec notConfigUser =
default public<br>group notConfigGroup v1 notConfigUser<=
br>group notConfigGroup v2c notConfigUser<br>access notConfigG=
roup "" any noauth exact all none none<br>"<br><br>Then I ra=
n "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib" in another t=
erminal window,and got "Timeout: No Response from localhost".<br><br><br>=
=D4=DA2007-11-06=A3=AC"Dave Shield" <D.T.S...@liverpool.ac.uk> =D0=
=B4=B5=C0=A3=BA<br><br>On 05/11/2007, wqs <wqs...@163.com> wrote:<br=
>> I wrote my own MIB file and compiled the module into the agent.<br>&g=
t; When I ran "snmpwalk -v2c localhost -m ALL -t 3 -c public sysConfigMib"<=
br>> and got "SYS-CONFIG-MIB::sysConfigMib =3D No Such Object ...<br><br=
>> Where is the problem?Please help me.Thanks!<br><br>Can you please try=
working through the checklist in the FAQ entry<br> I've added my code t=
o this template and it still doesn't work. Why not?<br> http://www.=
net-snmp.org/wiki/index.php/FAQ:Coding_13<br><br>Dave<br>
------=_Part_39843_18721722.1194405125112--
--===============1814738225==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--===============1814738225==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Net-snmp-coders mailing list
Net-snm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
--===============1814738225==--
So your MIB is being initialised - good.
> Warning: no access control information configured.
> It's unlikely this agent can serve any useful purpose in this state.
There's your answer then - with no access control information,
then the agent won't report anything.
> The lines related in /etc/snmp/snmpd.conf:
> "
> com2sec notConfigUser default public
> group notConfigGroup v1 notConfigUser
> group notConfigGroup v2c notConfigUser
> access notConfigGroup "" any noauth exact all none none
> "
But is the agent actually reading this file?
If you've added your own MIB, then presumably you compiled it
yourself. If you accepted the defaults when you ran "configure",
then it will be looking under /usr/local/etc, /usr/local/share/snmp etc
rather than the main system locations.
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
------=_Part_279695_13518891.1194525284710
Content-Type: text/plain; charset=gbk
Content-Transfer-Encoding: quoted-printable
Great!It's the problem of snmpd.conf file location.Now everything works hap=
pily!Thank you Dave.
=D4=DA2007-11-07=A3=AC"Dave Shield" <D.T.S...@liverpool.ac.uk> =D0=B4=B5=
=C0=A3=BA
But is the agent actually reading this file?
If you've added your own MIB, then presumably you compiled it
yourself. If you accepted the defaults when you ran "configure",
then it will be looking under /usr/local/etc, /usr/local/share/snmp etc
rather than the main system locations.
Dave
------=_Part_279695_13518891.1194525284710
Content-Type: text/html; charset=gbk
Content-Transfer-Encoding: quoted-printable
Great!It's the problem of snmpd.conf file location.Now everything works hap=
pily!Thank you Dave.<br><br><br>=D4=DA2007-11-07=A3=AC"Dave Shield" <D.T=
.Shi...@liverpool.ac.uk> =D0=B4=B5=C0=A3=BA<br><br>But is the agent actu=
ally reading this file?<br><br>If you've added your own MIB, then presumabl=
y you compiled it<br>yourself. If you accepted the defaults when you ran =
"configure",<br>then it will be looking under /usr/local/etc, /usr/local/sh=
are/snmp etc<br>rather than the main system locations.<br><br>Dave<br><br><=
!-- footer --><br><hr>
<a style=3D"font-size:14px;line-height:15px; color:#000; text-decoration:no=
ne" href=3D"http://event.mail.163.com/chanel/click.htm?from=3DNO_23&domain=
=3D163" target=3D"_blank"><span style=3D"text-decoration:underline; color:b=
lue">=CD=F8 =D2=D7 =B9=C9 =B0=C9=A3=AC =C3=BF =CC=EC =D3=D0 500 =CD=F2 =B9=
=C9 =C3=F1 =D4=DA =B4=CB =CC=D6 =C2=DB >></span> </a>
------=_Part_279695_13518891.1194525284710--
--===============1465455275==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--===============1465455275==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Net-snmp-coders mailing list
Net-snm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
--===============1465455275==--