This is a discussion on Failed to connect to the agentx master agent within the SNMP Coders forums, part of the Networking and Network Related category; --===============0572539865== Content-Type: multipart/alternative; boundary="----=_Part_22120_20981239.1165398840059" ------=_Part_22120_20981239.1165398840059 Content-Type: text/plain; charset=ISO-8859-1; ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
--===============0572539865==
Content-Type: multipart/alternative; boundary="----=_Part_22120_20981239.1165398840059" ------=_Part_22120_20981239.1165398840059 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hello friends, I have installed netsnmp version 5.2.3 on windows I have written code for suagent which will send trap to main agent i.e. agentX. so this is my code for subagent which send trap to main agent #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #define SUB_AGENT 1 #include <time.h> #include <signal.h> #define MAX_PENDING_CONN 5 #define BUFF_LEN 1024 static oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; int send_Event_trap( ) { netsnmp_variable_list *var_list = NULL; int i; int num_devices; oid Event_oid[] = { 1, 3, 6, 1, 4, 1, 16901, 0, 1 }; char data_str[]="testing windows trap"; oid EventShortText_oid[] = { 1, 3, 6, 1, 4, 1, 16901, 4, 0 }; snmp_varlist_add_variable(&var_list, snmptrap_oid, OID_LENGTH(snmptrap_oid), ASN_OBJECT_ID, ( u_char* ) Event_oid, sizeof(Event_oid) ); snmp_varlist_add_variable( &var_list, EventShortText_oid, OID_LENGTH(EventShortText_oid), ASN_OCTET_STR, data_str , strlen(data_str)); send_v2trap(var_list); snmp_free_varbind(var_list); return SNMP_ERR_NOERROR; } //////////////////////////////// int send_trap() { send_Event_trap (); return 0; } int main (int argc, char **argv) { int agentx_subagent=1; /* change this if you want to be a SNMP master agent */ int background = 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 keep_running = 0; if (agentx_subagent) { netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, SUB_AGENT); // My comment // Setting host,port for communication netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "udp:localhost:705"); } init_agent("sub-agent"); if (!agentx_subagent) { init_vacm_vars(); init_usmUser(); } init_snmp("sub-agent"); if (!agentx_subagent) init_master_agent(); keep_running = 1; send_trap( ); return 0; } so when i run this code it throws following warning No log handling enabled - turning on stderr logging Warning: Failed to connect to the agentx master agent (udp:localhost:705): Unknown host (udp:localhost:705) In my snmpd.conf i also set entry like this master agentx agentXSocket udp:localhost:705 this is netstat shows when my snmpd start C:\Documents and Settings\Administrator.ATN-80>netstat -a Active Connections Proto Local Address Foreign Address State TCP atn-80:1367 192.168.1.13:epmap TIME_WAIT TCP atn-80:1368 192.168.1.13:1026 TIME_WAIT TCP atn-80:1369 192.168.1.13:1026 TIME_WAIT UDP atn-80:snmp *:* UDP atn-80:microsoft-ds *:* UDP atn-80:isakmp *:* UDP atn-80:1025 *:* UDP atn-80:1026 *:* UDP atn-80:1045 *:* UDP atn-80:4500 *:* UDP atn-80:ntp *:* UDP atn-80:705 *:* UDP atn-80:1027 *:* UDP atn-80:1053 *:* UDP atn-80:1137 *:* UDP atn-80:1379 *:* UDP atn-80:1380 *:* UDP atn-80:1381 *:* UDP atn-80:1382 *:* UDP atn-80:1383 *:* UDP atn-80:1384 *:* UDP atn-80:1385 *:* UDP atn-80:1386 *:* UDP atn-80:1900 *:* UDP atn-80:ntp *:* UDP atn-80:netbios-ns *:* UDP atn-80:netbios-dgm *:* UDP atn-80:1900 *:* so according to status of netstat snmpd listen on 705 port but still subagent not able to connect to main agent, i tried for tcp protocol also by setting entry in snmpd.conf as well in my code but still same error is coming . what is the problem ? Thanks in advance Bhushan E. Sonawane -- bhushan. E . Sonawane ------=_Part_22120_20981239.1165398840059 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline hello friends,<br>I have installed netsnmp version 5.2.3 on windows<br>I ha= ve written code for suagent which will send trap to <br>main agent i.e. age= ntX. <br>so this is my code for subagent which send trap to main agent <br> <br>#include <net-snmp/net-snmp-config.h><br>#include <net-snmp/ne= t-snmp-includes.h><br>#include <net-snmp/agent/net-snmp-agent-include= s.h><br>#define SUB_AGENT 1<br>#include <time.h><br>#include < signal.h><br>#define MAX_PENDING_CONN 5<br>#define BUFF_LEN 1024<br><br>= static oid snmptrap_oid[] =3D { 1, 3, 6, 1, 6= , 3, 1, 1, 4, 1, 0 };<br>int<br>send_Event_trap( )<br>{<br> &nbs= p; netsnmp_variable_list *var_list =3D NULL; <br> &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; <br> int i;<b= r> int num_devices;<br> &nbs = p; &= nbsp; &nb sp; &nbs= p; &= nbsp; &nb sp; &nbs= p; &= nbsp; &nb sp; &nbs= p; &= nbsp; &nb sp; &nbs= p; &= nbsp;=20 <br> oid   ;&= nbsp; Event_oid[] =3D<br> &n= bsp; { 1, 3, 6, 1, 4, 1, 16901, 0, 1 };<br> &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; <br> char &nbs= p; &= nbsp; data_str[]=3D"testing windows trap";<br> = oid   ; = EventShortText_oid[] =3D <br> { 1, 3, 6, 1, 4, 1, 16901, 4= , 0 };<br> snmp_varlist_add_variable(&var_list,<br>&n= bsp; &nbs p;  = ; & nbsp; &n= bsp; snmptrap_oid, OID_LENGTH(snmptrap_oid),<br> &nb= sp;   ; = &n bsp; &nb= sp; ASN_OBJECT_ID,<br> &n bsp; = ; & nbsp; &n= bsp; &nbs p; ( u_char* ) Even= t_oid, <br> &nbs p;  = ; & nbsp; &n= bsp; sizeof(Event_oid) );<br> snmp_varlist_add_vari= able( &var_list,<br> &n bsp; &nb= sp;   ; = EventShortText_oid,<br> &nb sp; &nb= sp;   ; = OID_LENGTH(EventShortText_oid),<br> &nb = sp;   ; =   ; ASN_OCTET_STR, <br> &nbs p;  = ; & nbsp; data_st= r , strlen(data_str)); &n bsp;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; & nbsp; &n= bsp; &nbs p;  = ; <br> send_v2trap(var_list);<br> = snmp_free_varbind(var_list); <br> return SNMP_ERR_NOERROR;<br>}<br><br>///////////////= /////////////////<br><br><br>int send_trap()<br>{<br> sen= d_Event_trap ();<br> return 0;<br>}<br><br><br>int<br>mai= n (int argc, char **argv) <br>{<br> int agentx_subagent=3D1; /* chang= e this if you want to be a SNMP master agent */ <br> int background =3D 1; /* change this if you want to run in the b= ackground */<br> int num_fds;<br> fd_set fdset;<br> int c= ount;<br> int listen_fd; <br> int sock_fd;<br= > int keep_running =3D 0;<br> if (agentx_subagent) { <br> netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NE= TSNMP_DS_AGENT_ROLE, SUB_AGENT);<br> // My comment<br>&nb= sp; // Setting host,port for communication <br> &nbs= p; netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCK= ET, "udp:localhost:705"); <br> }<br> init_agent("sub-agent");<br> if (!ag= entx_subagent) {<br> init_vacm_vars();<br>&nb= sp; init_usmUser();<br> }<br> init_snmp= ("sub-agent");<br> if (!agentx_subagent)<br> &nb= sp; init_master_agent(); <br> keep_running =3D 1;<br> send_trap( );<br> return 0;<= br>}<br><br>so when i run this code it throws following warning <br>No log = handling enabled - turning on stderr logging<br>Warning: Failed to connect = to the agentx master agent (udp:localhost:705): Unknown host (udp:localhost= :705) <br><br>In my snmpd.conf i also set entry like this <br>master agentx<br>ag= entXSocket udp:localhost:705<br><br>this is netstat shows when my snmpd sta= rt <br>C:\Documents and Settings\Administrator.ATN-80>netstat -a<br> Active Connections<br> Proto Local Address &nb= sp; Foreign Address &n= bsp; State<br> TCP atn-80:1367 &nb= sp;   ; 192.168.1.13:epma= p TIME_WAIT<br> TCP atn-80:= 1368 &nbs p; <a h= ref=3D"http://192.168.1.13:1026"> 192.168.1.13:1026</a> TIME_WAIT<br> TCP= atn-80:1369 & nb= sp; <a href=3D"http://192.168.1.13:1026">192.168.1.13:102= 6</a> TIME_WAIT<br> UDP &nbs= p; atn-80:snmp & nbsp; &= nbsp; *:*<br> UDP atn-80:microsoft-ds &n= bsp; *:* <br> UDP atn-80:isakmp  = ; *:*<br> UDP atn-80:1025&n= bsp; &nbs p; *:*<br>&nb= sp; UDP atn-80:1026 &n= bsp; *:*<br> UDP atn-80:104= 5 & nbsp; *:*<br>= UDP atn-80:4500  = ; *:*<br> UDP atn-80:= ntp   ; = *:* <br> <span style=3D"color: rgb(255, 0, 0);"> UDP = atn-80:705 &n bsp;  = ; *:*</span><br> UDP atn-80:1027 &= nbsp; &nb sp; *:*<br> UDP&nbs= p; atn-80:1053 & nbsp;&= nbsp; *:*<br> UDP atn-80:1137 &nbs= p; *:*<br> UDP&= nbsp; atn-80:1379 & nbs= p; *:* <br> UDP atn-80:1380 &= nbsp; *:*<br> UDP atn= -80:1381 & nbsp; = *:*<br> UDP atn-80:1382 &nbs= p; *:*<br> UDP = atn-80:1383 & nbsp; &nbs= p; *:*<br> UDP atn-80:1384 &= nbsp; *:*<br> UDP &nbs= p; atn-80:1385 & nbsp; &= nbsp; *:* <br> UDP atn-80:1386 &= nbsp; *:*<br> UDP atn= -80:1900 & nbsp; = *:*<br> UDP atn-80:ntp  = ; *:*<br> UDP &n= bsp; atn-80:netbios-ns *:*<br> UDP = ; atn-80:netbios-dgm *:*<br> UDP&= nbsp; atn-80:1900 & nbs= p; *:* <br> so according to status of netstat snmpd listen on 705 port<br>&n= bsp; but still subagent not able to connect to main agent,<br> i trie= d for tcp protocol also by setting entry in snmpd.conf as well in <br> = ; my code but still same error is coming .=20 <br> what is the problem ?<br> Thanks in advance<br> Bhus= han E. Sonawane<br><br><br><br><br><br clear=3D"all"><br>-- <br>  = ; & nbsp; bhushan. E . S= onawane ------=_Part_22120_20981239.1165398840059-- --===============0572539865== 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 --===============0572539865== 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 --===============0572539865==-- |
![]() |
| Thread Tools | |
| Display Modes | |
|
|