This is a discussion on AgentX in windows (netsnmp 5.2.1.2 + example-demon) within the SNMP Users forums, part of the Networking and Network Related category; ------=_Part_20317_28615989.1127057545410 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,=20 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
------=_Part_20317_28615989.1127057545410
Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,=20 I wrote a subAgent for Linux, it works just fine,=20 When I was asked to add support for Windows server 2003 too, I had a=20 lot of problems. I am asking you for help please:=20 After applying some patches, I installed net-snmp 5.2.1.2 <http://5.2.1.2>in my windows machine using cygwin, using those steps:=20 1. configure --with-mib-modules=3D"host agentx disman/event-mib=20 examples/example" --with-out-mib-modules=3Dhost/hr_net=20 work=20 2. make=20 3. make install=20 OK.. Now I am trying to compile example-demon (form agentx tutorial=20 from net-snmp official site).=20 I am running the snmpd:=20 c:\usr\bin\snmpd -f -L -c c:\usr\share\snmp\snmpd.conf -x localhost:705=20 -Dagentx=20 snmpd.conf looks like this:=20 ################################################## #########=20 # SECTION: Access Control Setup=20 rwuser root=20 rouser root=20 rwcommunity public=20 master agentx=20 # end of snmpd.conf=20 ################################################## ###=20 snmpd output is:=20 """=20 c:\usr\share\snmp\snmpd.conf -Dagentx=20 agentx/subagent: init_subagent sess 00325ea0=20 agentx_register_app_config_handler: registering .conf token for=20 "agentxsocket"=20 agentx_register_app_config_handler: registering .conf token for=20 "agentxperms"=20 agentx_register_app_config_handler: registering .conf token for=20 "agentxRetries"=20 agentx_register_app_config_handler: registering .conf token for=20 "agentxTimeout"=20 Turning on AgentX master support.=20 agentx/master: initializing...=20 agentx/master: initializing... DONE=20 NET-SNMP version 5.2.1.2 <http://5.2.1.2>=20 """=20 Then I opened a cygwin window and compiled example-demon.c, here is the=20 code:=20 ##############=20 # example-demon.c=20 #include <net-snmp/net-snmp-config.h>=20 #include <net-snmp/net-snmp-includes.h>=20 #include <net-snmp/agent/net-snmp-agent-includes.h>=20 #include <signal.h>=20 #include <nstAgentSubagentObject.h>=20 static int keep_running;=20 RETSIGTYPE=20 stop_server(int a) {=20 keep_running =3D 0;=20 }=20 int=20 main (int argc, char **argv) {=20 int agentx_subagent=3D1; /* change this if you want to be a SNMP master=20 agent */=20 int background =3D 0; /* change this if you want to run in the=20 background */=20 int syslog =3D 0; /* change this if you want to use syslog */=20 /* print log errors to syslog or stderr */=20 if (syslog)=20 snmp_enable_calllog();=20 else=20 snmp_enable_stderrlog();=20 /* we're an agentx subagent? */=20 if (agentx_subagent) {=20 /* make us a agentx client. */=20 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,= 20 NETSNMP_DS_AGENT_ROLE, 1);=20 netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,NE TSNMP_DS_AGENT_X_SOCKET,"= =ADlocalhost:705"); }=20 /* run in background, if requested */=20 if (background && netsnmp_daemonize(1, !syslog))=20 exit(1);=20 /* initialize tcpip, if necessary */=20 SOCK_STARTUP;=20 /* initialize the agent library */=20 init_agent("example-demon");=20 /* initialize mib code here */=20 /* mib code: init_nstAgentSubagentObject from=20 nstAgentSubagentObject.C */=20 init_nstAgentSubagentObject();=20 /* initialize vacm/usm access control */=20 if (!agentx_subagent) {=20 init_vacm_vars();=20 init_usmUser();=20 }=20 /* example-demon will be used to read example-demon.conf files. */=20 init_snmp("example-demon");=20 /* If we're going to be a snmp master agent, initial the ports */=20 if (!agentx_subagent)=20 init_master_agent(); /* open the port to listen on (defaults to=20 udp:161) */=20 /* In case we recevie a request to stop (kill -TERM or kill -INT) */=20 keep_running =3D 1;=20 signal(SIGTERM, stop_server);=20 signal(SIGINT, stop_server);=20 snmp_log(LOG_INFO,"example-demon is up and running.\n");=20 /* your main loop here... */=20 while(keep_running) {=20 /* if you use select(), see snmp_select_info() in snmp_api(3) */=20 /* --- OR --- */=20 agent_check_and_process(1); /* 0 =3D=3D don't block */=20 }=20 /* at shutdown time */=20 snmp_shutdown("example-demon");=20 SOCK_CLEANUP;=20 return 0;=20 }=20 # end of example-demon.c=20 ######################=20 Then I ran example-demon.exe, it says that "example-demon is up and=20 running"!!!!!=20 BUT, when I check the subagent's MIB it seems not working:=20 c:\snmpget -v 2c -c public localhost=20 NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0=20 =3D=3D> NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0 =3D No Such Object= =20 available on this agent at this OID=20 !!!!!!!=20 I spent some days trying to figure it out, I couldn't. Can you please=20 help me.=20 P.S=20 1. netstat -a shows me "TCP pc_name:705 pc_name:0 LISTENING"=20 2. When I try to run the example-demon without running the master, I=20 got the same behavior, it says that it's up and running!!, but in fact=20 it's not.=20 3. I am running snmpd and example-demon from MS window (not form cygwin=20 window), I don't know if that's matter.=20 Thanks in advance.=20 -Ali ------=_Part_20317_28615989.1127057545410 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline <p>Hi, <br>I wrote a subAgent for Linux, it works just fine, <br>When I was= asked to add support for Windows server 2003 too, I had a <br>lot of probl= ems. I am asking you for help please: </p> <p><br>After applying some patches, I installed net-snmp <a href=3D"http://= 5.2.1.2">5.2.1.2</a> in my windows <br>machine using cygwin, using those st= eps: <br>1. configure --with-mib-modules=3D"host agentx disman/event-m= ib=20 <br>examples/example" --with-out-mib-modules=3Dhost/hr_net <br>work <b= r>2. make <br>3. make install </p> <p><br>OK.. Now I am trying to compile example-demon (form agentx tutorial = <br>from net-snmp official site). <br>I am running the snmpd: <br>c:\usr\bi= n\snmpd -f -L -c c:\usr\share\snmp\snmpd.conf -x localhost:705 <br>-Dagentx= =20 <br>snmpd.conf looks like this: <br>#######################################= #################### <br># SECTION: Access Control Setup <br>rwuser r= oot <br>rouser root <br>rwcommunity public <br>master agentx <b= r># end of=20 snmpd.conf <br>############################################## ####### </p> <p><br>snmpd output is: <br>""" <br>c:\usr\share\snmp\snmpd.= conf -Dagentx <br>agentx/subagent: init_subagent sess 00325ea0 <br>ag= entx_register_app_config_handler: registering .conf token for <br>"age= ntxsocket"=20 <br>agentx_register_app_config_handler: registering .conf token for <br>&qu= ot;agentxperms" <br>agentx_register_app_config_handler: registering .c= onf token for <br>"agentxRetries" <br>agentx_register_app_config_= handler: registering .conf token for=20 <br>"agentxTimeout" <br>Turning on AgentX master support. <br>age= ntx/master: initializing... <br>agentx/master: initializing... = DONE <br>NET-SNMP version <a href=3D"http://5.2.1.2">5.2.1.2</a> <br>"= ""=20 </p> <p><br>Then I opened a cygwin window and compiled example-demon.c, here is = the <br>code: <br>############## <br># example-demon.c <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>#inc= lude <signal.h> </p> <p><br>#include <nstAgentSubagentObject.h> </p> <p><br>static int keep_running; </p> <p><br>RETSIGTYPE <br>stop_server(int a) { <br> keep_runn= ing =3D 0; </p> <p> </p> <p>} </p> <p><br>int <br>main (int argc, char **argv) { <br> int agentx_subagen= t=3D1; /* change this if you want to be a SNMP master <br>agent */ <br>&nbs= p; int background =3D 0; /* change this if you want to run in the <br>backg= round */=20 <br> int syslog =3D 0; /* change this if you want to use syslog */ </= p> <p> /* print log errors to syslog or stderr */ <br> if (syslog)= <br> snmp_enable_calllog(); <br> else <br> &n= bsp; snmp_enable_stderrlog(); </p> <p><br> /* we're an agentx subagent? */ <br> if (agentx_subagen= t) { <br> /* make us a agentx client. */ <br> = netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, <br>NETSNMP_DS_AGE= NT_ROLE, 1); <br> netsnmp_ds_set_= string(NETSNMP_DS_APPLICATION_ID,NETSNMP_DS_AGENT_ X_SOCKET,"=ADlocalho= st:705");=20 </p> <p><br> } </p> <p><br> /* run in background, if requested */ <br> if (backgrou= nd && netsnmp_daemonize(1, !syslog)) <br> &n= bsp; exit(1); <br> /* initialize tcpip, if necessary */ <br> SO= CK_STARTUP; </p> <p><br> /* initialize the agent library */ <br> init_agent(&quo= t;example-demon"); </p> <p><br> /* initialize mib code here */ </p> <p><br> /* mib code: init_nstAgentSubagentObject from <br>nstAgentSub= agentObject.C */ <br> init_nstAgentSubagentObject(); </p> <p><br> /* initialize vacm/usm access control */ <br> if = (!agentx_subagent) { <br> init_vacm_vars(); <= br> init_usmUser(); <br> } </p> <p><br> /* example-demon will be used to read example-demon.conf file= s. */ <br> init_snmp("example-demon"); </p> <p><br> /* If we're going to be a snmp master agent, initial the port= s */ <br> if (!agentx_subagent) <br> init_master_ag= ent(); /* open the port to listen on (defaults to <br>udp:161) */ </p= > <p><br> /* In case we recevie a request to stop (kill -TERM or kill -= INT) */ <br> keep_running =3D 1; <br> signal(SIGTERM, stop_serv= er); <br> signal(SIGINT, stop_server); </p> <p><br> snmp_log(LOG_INFO,"example-demon is up and running.\n&qu= ot;); </p> <p><br> /* your main loop here... */ <br> while(keep_running) {= <br> /* if you use select(), see snmp_select_info() in s= nmp_api(3) */ <br> /* --- OR ---&= nbsp; */ <br> agent_check_and_process(1); /* 0 =3D=3D don= 't block */=20 <br> } </p> <p><br> /* at shutdown time */ <br> snmp_shutdown("example= -demon"); <br> SOCK_CLEANUP; </p> <p><br> return 0; </p> <p> </p> <p>} </p> <p><br># end of example-demon.c <br>###################### </p> <p>Then I ran example-demon.exe, it says that "example-demon is up and= <br>running"!!!!! </p> <p><br>BUT, when I check the subagent's MIB it seems not working: <br>c:\sn= mpget -v 2c -c public localhost <br>NET-SNMP-TUTORIAL-MIB::nstAgentSubagent= Object.0 <br>=3D=3D> NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0 =3D= No Such Object=20 <br>available on this agent at this OID </p> <p><br>!!!!!!! </p> <p><br>I spent some days trying to figure it out, I couldn't. Can you pleas= e <br>help me. </p> <p><br>P.S <br>1. netstat -a shows me "TCP pc_name:705 pc_name:0 LISTE= NING" <br>2. When I try to run the example-demon without running the m= aster, I <br>got the same behavior, it says that it's up and running!!, but= in fact=20 <br>it's not. <br>3. I am running snmpd and example-demon from MS window (n= ot form cygwin <br>window), I don't know if that's matter. </p> <p><br>Thanks in advance. <br>-Ali<br></p> ------=_Part_20317_28615989.1127057545410-- ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.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 |