This is a discussion on about agentx support in windows within the SNMP Coders forums, part of the Networking and Network Related category; --===============0987993007== Content-Type: multipart/alternative; boundary="----=_Part_32008_10969374.1165241411559" ------=_Part_32008_10969374.1165241411559 Content-Type: text/plain; charset=ISO-8859-1; ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
--===============0987993007==
Content-Type: multipart/alternative; boundary="----=_Part_32008_10969374.1165241411559" ------=_Part_32008_10969374.1165241411559 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 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]: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 master 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 ------=_Part_32008_10969374.1165241411559 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline hello friends <br>Greetings, <br>I have installed netsnmp-5.4 using win32( = MVC++), i am writing code <br>for subagent which will send traps to AgentX = master agent. <br>Problem with the code is it execute all api of netsnmp co= rrectly <br>(put up code at end) but no trap received by main agent( even if = no <br>packet received by main agent according to dump ) <br>I am running m= ain agent in debug mode(sorry if i use wrong phrase) i.e.<br>snmpd -Lo -f -= d -C -c c:\usr\etc\snmp\snmpd.conf=20 <br>so if trap come to main agent it dump out trap to stdout<br>for agentx = support enabling i putted following line in my snmpd.conf<br>master agentx<= br>agentXSocket tcp:<a href=3D"http://127.0.0.1:755">127.0.0.1:755</a><br> so it receive data on this port <br>dump of my snmpd process when i start a= gent <br><br>C:\NETSNMP\NET-SN~1.4\win32\bin\release>snmpd -Lo -f -d -C = -c c:\usr\etc\snmp\snmpd.conf<br>Turning on AgentX master support.<br><br> Sending 93 bytes to UDP: [<a href=3D"http://127.0.0.1">127.0.0.1</a>]:162<b= r>0000: 30 5B 02 01 01 04 06 70 75 62 6C 69 63 A7 4E 02&n= bsp; 0[.....public=BAN.<br>0016: 02 3A 8A 02 01 00 02 01&= nbsp; 00 30 42 30 0D 06 08 2B .:=E8......0B0...+ <br>0032: 06 01 02 01 01 03 00 43 01 1C 30 17 06 0A 2B 06= .......C..0...+.<br>0048: 01 06 03 01 01 04 01 00&= nbsp; 06 09 2B 06 01 06 03 01 ......... = +.....<br>0064: 01 05 01 30 18 06 0A 2B 06 01 06 03 01 0= 1 04 03 ...0...+........ <br>0080: 00 06 0A 2B 06 01 04 01 BF 08 03 02 0D<br><br><= br>This is subagent code which send trap to main agent <br><br><br>static o= id snmptrap_oid[] =3D { 1, 3, 6, 1, 6, 3, 1, = 1, 4, 1, 0 };<br>int<br>send_trap( void) <br>{<br> netsnmp_variable_list *var_list =3D NULL;<br>&n= bsp; int i;<br> oid &n= bsp; &nbs p; data_oid[] =3D<br>&nbs= p; { 1, 3, 6, 1, 4, 1, 16901, 0, 1 };<b= r> <br> oid &nbs= p; ShortText_oid[] =3D<br> &= nbsp; { 1, 3, 6, 1, 4, 1, 16901, 4, 0 }; <br><br> char *data =3D "testing trap in windows&quo= t;;<br> snmp_varlist_add_variable(&var_list,<br> = ; & nbsp; &n= bsp; &nbs p;  = ; snmptrap_oid, OID_LENGTH(snmptrap_oid),//11*sizeof(oid)= ,<br> &nb sp; &nbs= p; &= nbsp; ASN_OBJECT_ID, <br> &nbs p;  = ; & nbsp; &n= bsp; ( u_char* ) data_oid,<br> &nb= sp;   ; = &n bsp; sizeof(data_oi= d) );<br> snmp_varlist_add_variable( &var_list,<br>&n= bsp; &nbs p;  = ; & nbsp; ShortText_oid= ,<br> &nb sp; &nbs= p; OID_LE= NGTH(ShortText_oid) , <br> &nbs p;  = ; & nbsp; ASN_OCT= ET_STR,<br> &nb sp; &nbs= p; = data , strlen(data));<br> send_v2trap(var_list);<br> = ; snmp_free_varbind(var_list);<br> return SNM= P_ERR_NOERROR;<br>}<br>int main (int argc, char **argv) <br>{<br> int agentx_subagent=3D1; /* change this if you want to be a= SNMP master agent */<br> int background =3D 1; /* change this if you= want to run in the background */<br> int num_fds;<br> fd_set f= dset;<br> int count; <br> int listen_fd; <br> int sock_fd;<br> int= syslog =3D 1;<br> char *p =3D "c:\\usr\\etc\\snmp\\snmpd";= <br> char *cptr=3D "tcp:localhost:705";<br> int keep_= running =3D 0;<br><br> /* we're an agentx subagent? */ <br> if (agentx_subagent) {<br> /* make us a agentx= client. */<br> netsnmp_ds_set_boolean(NETSNMP_DS_APPLICA= TION_ID, NETSNMP_DS_AGENT_ROLE, 1);<br> netsnmp_ds_set_st= ring(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, cptr); <br> }<br><br> /* run in background, if requested */<br> = if (background && netsnmp_daemonize(1, !syslog))<br> &nb= sp; exit(1);<br> <br> /* initialize the agent librar= y */<br><br> while( init_agent("sub-agent") !=3D 0 ) { <br> sleep(2);<br> }<br> init_snmp(&quo= t;sub-agent");<br> send_trap();<br> return 0;<br>}<br>Plea= se point if any mistake i made in code/ agent configuration <br>Thanks in a= dvance<br>Regards<br>Bhushan. E . Sonawane ------=_Part_32008_10969374.1165241411559-- --===============0987993007== 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 --===============0987993007== 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 --===============0987993007==-- |