Re: about agentx support in windows

This is a discussion on Re: about agentx support in windows within the SNMP Coders forums, part of the Networking and Network Related category; --===============1217022698== Content-Type: multipart/alternative; boundary="----=_Part_7001_24445659.1165334702258" ------=_Part_7001_24445659.1165334702258 Content-Type: text/plain; charset=ISO-8859-1; ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-05-2006
bhushan
 
Posts: n/a
Default Re: about agentx support in windows

--===============1217022698==
Content-Type: multipart/alternative;
boundary="----=_Part_7001_24445659.1165334702258"

------=_Part_7001_24445659.1165334702258
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I am using static version of library
Is there any problem with it ?
Thanks for replying
Please do reply
Regards
Bhushan


On 12/5/06, Alex Burger <alex_b@users.sourceforge.net> wrote:
>
>
> Are you using the DLL version of the library (netsnmp.dll) or did you
> compile static?
>
> Alex
>
>
> bhushan wrote:
> > hello friends
> > Greetings,
> > I have installed netsnmp-5.4 using win32( MVC++), i am writing code
> > for subagent which will send traps to AgentX master agent.
> > Problem with the code is it execute all api of netsnmp correctly
> > (put up code at end) but no trap received by main agent( even if no
> > packet received by main agent according to dump )
> > I am running main agent in debug mode(sorry if i use wrong phrase) i.e.
> > snmpd -Lo -f -d -C -c c:\usr\etc\snmp\snmpd.conf
> > so if trap come to main agent it dump out trap to stdout
> > for agentx support enabling i putted following line in my snmpd.conf
> > master agentx
> > agentXSocket tcp:127.0.0.1:755 <http://127.0.0.1:755>
> > so it receive data on this port
> > dump of my snmpd process when i start agent
> >
> > C:\NETSNMP\NET-SN~1.4\win32\bin\release>snmpd -Lo -f -d -C -c
> > c:\usr\etc\snmp\snmpd.conf
> > Turning on AgentX master support.
> >
> > Sending 93 bytes to UDP: [127.0.0.1 <http://127.0.0.1>]:162
> > 0000: 30 5B 02 01 01 04 06 70 75 62 6C 69 63 A7 4E

> 02 0[.....public=BAN.
> > 0016: 02 3A 8A 02 01 00 02 01 00 30 42 30 0D 06 08 2B
> > .:=E8......0B0...+
> > 0032: 06 01 02 01 01 03 00 43 01 1C 30 17 06 0A 2B

> 06 .......C..0...+.
> > 0048: 01 06 03 01 01 04 01 00 06 09 2B 06 01 06 03 01 .........
> > +.....
> > 0064: 01 05 01 30 18 06 0A 2B 06 01 06 03 01 01 04 03
> > ...0...+........
> > 0080: 00 06 0A 2B 06 01 04 01 BF 08 03 02 0D
> >
> >
> > This is subagent code which send trap to main agent
> >
> >
> > static oid snmptrap_oid[] =3D { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
> > int
> > send_trap( void)
> > {
> > netsnmp_variable_list *var_list =3D NULL;
> > int i;
> > oid data_oid[] =3D
> > { 1, 3, 6, 1, 4, 1, 16901, 0, 1 };
> >
> > oid ShortText_oid[] =3D
> > { 1, 3, 6, 1, 4, 1, 16901, 4, 0 };
> >
> > char *data =3D "testing trap in windows";
> > snmp_varlist_add_variable(&var_list,
> > snmptrap_oid,
> > OID_LENGTH(snmptrap_oid),//11*sizeof(oid),
> > ASN_OBJECT_ID,
> > ( u_char* ) data_oid,
> > sizeof(data_oid) );
> > snmp_varlist_add_variable( &var_list,
> > ShortText_oid,
> > OID_LENGTH(ShortText_oid) ,
> > ASN_OCTET_STR,
> > data , strlen(data));
> > send_v2trap(var_list);
> > snmp_free_varbind(var_list);
> > return SNMP_ERR_NOERROR;
> > }
> > int main (int argc, char **argv)
> > {
> > int agentx_subagent=3D1; /* change this if you want to be a SNMP mast=

er
> > agent */
> > int background =3D 1; /* change this if you want to run in the

> background */
> > int num_fds;
> > fd_set fdset;
> > int count;
> > int listen_fd;
> > int sock_fd;
> > int syslog =3D 1;
> > char *p =3D "c:\\usr\\etc\\snmp\\snmpd";
> > char *cptr=3D "tcp:localhost:705";
> > int keep_running =3D 0;
> >
> > /* we're an agentx subagent? */
> > if (agentx_subagent) {
> > /* make us a agentx client. */
> > netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
> > NETSNMP_DS_AGENT_ROLE, 1);
> > netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
> > NETSNMP_DS_AGENT_X_SOCKET, cptr);
> > }
> >
> > /* run in background, if requested */
> > if (background && netsnmp_daemonize(1, !syslog))
> > exit(1);
> >
> > /* initialize the agent library */
> >
> > while( init_agent("sub-agent") !=3D 0 ) {
> > sleep(2);
> > }
> > init_snmp("sub-agent");
> > send_trap();
> > return 0;
> > }
> > Please point if any mistake i made in code/ agent configuration
> > Thanks in advance
> > Regards
> > Bhushan. E . Sonawane
> >
> >
> > -----------------------------------------------------------------------=

-
> >
> >

> -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share

> your
> > opinions on IT & business topics through brief surveys - and earn cash
> >

> http://www.techsay.com/default.php?p...eforge&CID=3D=

DEVDEV
> >
> >
> > -----------------------------------------------------------------------=

-
> >
> > _______________________________________________
> > Net-snmp-coders mailing list
> > Net-snmp-coders@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/...et-snmp-coders

>
>



--=20
bhushan. E . Sonawane

------=_Part_7001_24445659.1165334702258
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

&nbsp;I am using static version of library <br>&nbsp;Is there any problem w=
ith it ?<br>&nbsp;Thanks for replying <br>&nbsp;Please do reply <br>&nbsp;R=
egards<br>&nbsp;Bhushan<br><br><br><div><span class=3D"gmail_quote">On 12/5=
/06, <b class=3D"gmail_sendername">
Alex Burger</b> &lt;<a href=3D"mailto:alex_b@users.sourceforge.net">alex_ b@=
users.sourceforge.net</a>&gt; wrote:</span><blockquote class=3D"gmail_quote=
" style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0=
..8ex; padding-left: 1ex;">
<br>Are you using the DLL version of the library (netsnmp.dll) or did you<b=
r>compile static?<br><br>Alex<br><br><br>bhushan wrote:<br>&gt; hello frien=
ds<br>&gt; Greetings,<br>&gt; I have installed netsnmp-5.4 using win32( MVC=
++), i am writing code
<br>&gt; for subagent which will send traps to AgentX master agent.<br>&gt;=
Problem with the code is it execute all api of netsnmp correctly<br>&gt; (=
put up code at end)&nbsp;&nbsp;but no trap received by main agent( even if =
no<br>
&gt; packet received by main agent according to dump )<br>&gt; I am running=
main agent in debug mode(sorry if i use wrong phrase) i.e.<br>&gt; snmpd -=
Lo -f -d -C -c c:\usr\etc\snmp\snmpd.conf<br>&gt; so if trap come to main a=
gent it dump out trap to stdout
<br>&gt; for agentx support enabling i putted following line in my snmpd.co=
nf<br>&gt; master agentx<br>&gt; agentXSocket tcp:<a href=3D"http://127.0.0=
..1:755">127.0.0.1:755</a> &lt;<a href=3D"http://127.0.0.1:755">http://127.0=
..0.1:755
</a>&gt;<br>&gt; so it receive data on this port<br>&gt; dump of my snmpd p=
rocess when i start agent<br>&gt;<br>&gt; C:\NETSNMP\NET-SN~1.4\win32\bin\r=
elease&gt;snmpd -Lo -f -d -C -c<br>&gt; c:\usr\etc\snmp\snmpd.conf<br>&gt; =
Turning on AgentX master support.
<br>&gt;<br>&gt; Sending 93 bytes to UDP: [<a href=3D"http://127.0.0.1">127=
..0.0.1</a> &lt;<a href=3D"http://127.0.0.1">http://127.0.0.1</a>&gt;]:162<b=
r>&gt; 0000: 30 5B 02 01&nbsp;&nbsp;01 04 06 70&nbsp;&nbsp;75 62 6C 69&nbsp=
;&nbsp;63 A7 4E 02&nbsp;&nbsp;&nbsp;&nbsp;0[.....public=BAN.
<br>&gt; 0016: 02 3A 8A 02&nbsp;&nbsp;01 00 02 01&nbsp;&nbsp;00 30 42 30&nb=
sp;&nbsp;0D 06 08 2B<br>&gt; .:=E8......0B0...+<br>&gt; 0032: 06 01 02 01&n=
bsp;&nbsp;01 03 00 43&nbsp;&nbsp;01 1C 30 17&nbsp;&nbsp;06 0A 2B 06&nbsp;&n=
bsp;&nbsp;&nbsp;.......C..0...+.<br>&gt; 0048: 01 06 03 01&nbsp;&nbsp;01 04=
01 00&nbsp;&nbsp;06 09 2B 06&nbsp;&nbsp;01 06 03 01&nbsp;&nbsp;&nbsp;&nbsp=
;.........
<br>&gt; +.....<br>&gt; 0064: 01 05 01 30&nbsp;&nbsp;18 06 0A 2B&nbsp;&nbsp=
;06 01 06 03&nbsp;&nbsp;01 01 04 03<br>&gt; ...0...+........<br>&gt; 0080: =
00 06 0A 2B&nbsp;&nbsp;06 01 04 01&nbsp;&nbsp;BF 08 03 02&nbsp;&nbsp;0D<br>=
&gt;<br>&gt;<br>&gt; This is subagent code which send trap to main agent
<br>&gt;<br>&gt;<br>&gt; static oid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;snmp=
trap_oid[] =3D { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };<br>&gt; int<br>&gt; sen=
d_trap( void)<br>&gt; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; netsnmp_variable_li=
st *var_list =3D NULL;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; int i;<br>&gt;&nbsp;=
&nbsp;&nbsp;&nbsp; oid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data_oid[] =3D
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; { 1, 3, 6, 1, 4, 1=
, 16901, 0, 1 };<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; oid&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShortText_oid[] =3D<br>&gt;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 1, 3, 6, 1, 4, 1, 16901, 4=
, 0 };<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; char *data =3D &quot;testing=
trap in windows&quot;;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; snmp_varlist_add_variable(&amp;var_list,<b=
r>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; snmptrap_oid,<br>&gt; OID_LENGTH(snmpt=
rap_oid),//11*sizeof(oid),<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp; ASN_OBJECT=
_ID,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( u_char* ) data_oid,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;sizeof(data_oid) );<br>&gt;&nbsp;&nbsp;&nbsp;&nbs=
p; snmp_varlist_add_variable( &amp;var_list,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShortText_oid,<br>&gt;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp; OID_LENGTH(=
ShortText_oid) ,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; ASN_OCTET_STR,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbs=
p; data , strlen(data));<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; send_v2trap(var_li=
st);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; snmp_free_varbind(var_list);<br>&gt;&n=
bsp;&nbsp;&nbsp;&nbsp; return SNMP_ERR_NOERROR;<br>&gt; }<br>&gt; int main =
(int argc, char **argv)<br>
&gt; {<br>&gt;&nbsp;&nbsp; int agentx_subagent=3D1; /* change this if you w=
ant to be a SNMP master<br>&gt; agent */<br>&gt;&nbsp;&nbsp; int background=
=3D 1; /* change this if you want to run in the background */<br>&gt;&nbsp=
;&nbsp; int num_fds;<br>&gt;&nbsp;&nbsp; fd_set fdset;
<br>&gt;&nbsp;&nbsp; int count;<br>&gt;&nbsp;&nbsp; int listen_fd;<br>&gt;&=
nbsp;&nbsp; int sock_fd;<br>&gt;&nbsp;&nbsp; int syslog =3D 1;<br>&gt;&nbsp=
;&nbsp; char *p =3D &quot;c:\\usr\\etc\\snmp\\snmpd&quot;;<br>&gt;&nbs p;&nb=
sp; char *cptr=3D &quot;tcp:localhost:705&quot;;<br>&gt;&nbsp;&nb sp; int ke=
ep_running =3D 0;
<br>&gt;<br>&gt;&nbsp;&nbsp; /* we're an agentx subagent? */<br>&gt;&nbsp;&=
nbsp; if (agentx_subagent) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* make us a a=
gentx client. */<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; netsnmp_ds_set_boolean(NET=
SNMP_DS_APPLICATION_ID,<br>&gt; NETSNMP_DS_AGENT_ROLE, 1);
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; netsnmp_ds_set_string(NETSNMP_DS_APPLICATI=
ON_ID,<br>&gt; NETSNMP_DS_AGENT_X_SOCKET, cptr);<br>&gt;&nbsp;&nbsp; }<br>&=
gt;<br>&gt;&nbsp;&nbsp; /* run in background, if requested */<br>&gt;&nbsp;=
&nbsp; if (background &amp;&amp; netsnmp_daemonize(1, !syslog))
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br>&gt;<br>&gt;&nbsp;=
&nbsp; /* initialize the agent library */<br>&gt;<br>&gt;&nbsp;&nbsp; while=
( init_agent(&quot;sub-agent&quot;) !=3D 0 ) {<br>&gt;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;sleep(2);<br>&gt;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp; init_snm=
p(&quot;sub-agent&quot;);
<br>&gt;&nbsp;&nbsp; send_trap();<br>&gt;&nbsp;&nbsp; return 0;<br>&gt; }<b=
r>&gt; Please point if any mistake i made in code/ agent configuration<br>&=
gt; Thanks in advance<br>&gt; Regards<br>&gt; Bhushan. E . Sonawane<br>&gt;=
<br>&gt;<br>&gt; ----------------------------------------------------------=
--------------
<br>&gt;<br>&gt; ----------------------------------------------------------=
---------------<br>&gt; Take Surveys. Earn Cash. Influence the Future of IT=
<br>&gt; Join SourceForge.net's Techsay panel and you'll get the chance to =
share your
<br>&gt; opinions on IT &amp; business topics through brief surveys - and e=
arn cash<br>&gt; <a href=3D"http://www.techsay.com/default.php?page=3Djoin.=
php&amp;p=3Dsourceforge&amp;CID=3DDEVDEV">http://www.techsay.com/default.ph=
p?page=3Djoin.php&amp;p=3Dsourceforge&amp;CID=3DDE VDEV
</a><br>&gt;<br>&gt;<br>&gt; ----------------------------------------------=
--------------------------<br>&gt;<br>&gt; ________________________________=
_______________<br>&gt; Net-snmp-coders mailing list<br>&gt; <a href=3D"mai=
lto:Net-snmp-coders@lists.sourceforge.net">
Net-snmp-coders@lists.sourceforge.net</a><br>&gt; <a href=3D"https://lists.=
sourceforge.net/lists/listinfo/net-snmp-coders">https://lists.sourceforge.n=
et/lists/listinfo/net-snmp-coders</a><br><br></blockquote></div><br><br cle=
ar=3D"all">
<br>-- <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbs=
p;&nbsp;bhushan. E . Sonawane

------=_Part_7001_24445659.1165334702258--


--===============1217022698==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?p...rge&CID=DEVDEV
--===============1217022698==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders

--===============1217022698==--

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 03:36 AM.


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