Bluehost.com Web Hosting $6.95

AgentX in windows (netsnmp 5.2.1.2 + example-demon)

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 ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-18-2005
Ali Ayoub
 
Posts: n/a
Default AgentX in windows (netsnmp 5.2.1.2 + example-demon)

------=_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&quot;host agentx disman/event-m=
ib=20
<br>examples/example&quot; --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&nbsp; r=
oot <br>rouser&nbsp; root <br>rwcommunity&nbsp; public <br>master agentx <b=
r># end of=20
snmpd.conf <br>############################################## ####### </p>
<p><br>snmpd output is: <br>&quot;&quot;&quot; <br>c:\usr\share\snmp\snmpd.=
conf&nbsp; -Dagentx <br>agentx/subagent: init_subagent sess 00325ea0 <br>ag=
entx_register_app_config_handler: registering .conf token for <br>&quot;age=
ntxsocket&quot;=20
<br>agentx_register_app_config_handler: registering .conf token for <br>&qu=
ot;agentxperms&quot; <br>agentx_register_app_config_handler: registering .c=
onf token for <br>&quot;agentxRetries&quot; <br>agentx_register_app_config_=
handler: registering .conf token for=20
<br>&quot;agentxTimeout&quot; <br>Turning on AgentX master support. <br>age=
ntx/master: initializing... <br>agentx/master: initializing...&nbsp;&nbsp; =
DONE <br>NET-SNMP version <a href=3D"http://5.2.1.2">5.2.1.2</a> <br>&quot;=
&quot;&quot;=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 &lt;net=
-snmp/net-snmp-config.h&gt; <br>#include &lt;net-snmp/net-snmp-includes.h
&gt; <br>#include &lt;net-snmp/agent/net-snmp-agent-includes.h&gt; <br>#inc=
lude &lt;signal.h&gt; </p>
<p><br>#include &lt;nstAgentSubagentObject.h&gt; </p>
<p><br>static int keep_running; </p>
<p><br>RETSIGTYPE <br>stop_server(int a) { <br>&nbsp;&nbsp;&nbsp; keep_runn=
ing =3D 0; </p>
<p>&nbsp;</p>
<p>} </p>
<p><br>int <br>main (int argc, char **argv) { <br>&nbsp; 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>&nbsp; int syslog =3D 0; /* change this if you want to use syslog */ </=
p>
<p>&nbsp; /* print log errors to syslog or stderr */ <br>&nbsp; if (syslog)=
<br>&nbsp;&nbsp;&nbsp; snmp_enable_calllog(); <br>&nbsp; else <br>&nbsp;&n=
bsp;&nbsp; snmp_enable_stderrlog(); </p>
<p><br>&nbsp; /* we're an agentx subagent? */ <br>&nbsp; if (agentx_subagen=
t) { <br>&nbsp;&nbsp;&nbsp; /* make us a agentx client. */ <br>&nbsp;&nbsp;=
&nbsp; netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, <br>NETSNMP_DS_AGE=
NT_ROLE, 1); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; netsnmp_ds_set_=
string(NETSNMP_DS_APPLICATION_ID,NETSNMP_DS_AGENT_ X_SOCKET,&quot;=ADlocalho=
st:705&quot;);=20
</p>
<p><br>&nbsp; } </p>
<p><br>&nbsp; /* run in background, if requested */ <br>&nbsp; if (backgrou=
nd &amp;&amp; netsnmp_daemonize(1, !syslog)) <br>&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; exit(1); <br>&nbsp; /* initialize tcpip, if necessary */ <br>&nbsp; SO=
CK_STARTUP; </p>
<p><br>&nbsp; /* initialize the agent library */ <br>&nbsp; init_agent(&quo=
t;example-demon&quot;); </p>
<p><br>&nbsp; /* initialize mib code here */ </p>
<p><br>&nbsp; /* mib code: init_nstAgentSubagentObject from <br>nstAgentSub=
agentObject.C */ <br>&nbsp; init_nstAgentSubagentObject(); </p>
<p><br>&nbsp; /* initialize vacm/usm access control&nbsp; */ <br>&nbsp; if =
(!agentx_subagent) { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; init_vacm_vars(); <=
br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; init_usmUser(); <br>&nbsp; } </p>
<p><br>&nbsp; /* example-demon will be used to read example-demon.conf file=
s. */ <br>&nbsp; init_snmp(&quot;example-demon&quot;); </p>
<p><br>&nbsp; /* If we're going to be a snmp master agent, initial the port=
s */ <br>&nbsp; if (!agentx_subagent) <br>&nbsp;&nbsp;&nbsp; init_master_ag=
ent();&nbsp; /* open the port to listen on (defaults to <br>udp:161) */ </p=
>

<p><br>&nbsp; /* In case we recevie a request to stop (kill -TERM or kill -=
INT) */ <br>&nbsp; keep_running =3D 1; <br>&nbsp; signal(SIGTERM, stop_serv=
er); <br>&nbsp; signal(SIGINT, stop_server); </p>
<p><br>&nbsp; snmp_log(LOG_INFO,&quot;example-demon is up and running.\n&qu=
ot;); </p>
<p><br>&nbsp; /* your main loop here... */ <br>&nbsp; while(keep_running) {=
<br>&nbsp;&nbsp;&nbsp; /* if you use select(), see snmp_select_info() in s=
nmp_api(3) */ <br>&nbsp;&nbsp;&nbsp; /*&nbsp;&nbsp;&nbsp;&nbsp; --- OR ---&=
nbsp; */ <br>&nbsp;&nbsp;&nbsp; agent_check_and_process(1); /* 0 =3D=3D don=
't block */=20
<br>&nbsp; } </p>
<p><br>&nbsp; /* at shutdown time */ <br>&nbsp; snmp_shutdown(&quot;example=
-demon&quot;); <br>&nbsp; SOCK_CLEANUP; </p>
<p><br>&nbsp; return 0; </p>
<p>&nbsp;</p>
<p>} </p>
<p><br># end of example-demon.c <br>###################### </p>
<p>Then I ran example-demon.exe, it says that &quot;example-demon is up and=
<br>running&quot;!!!!! </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&gt; 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 &quot;TCP pc_name:705 pc_name:0 LISTE=
NING&quot; <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
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 10:15 AM.


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