What I have done.
# net-snmp-config --create-snmpv3-user -a abcd1234 myuser
# run snmpd
# kill snmpd
copied the following line from /var/net-snmp/snmpd.conf to abc-demo.conf
usmUser 1 3 0x80001f88043078303130323033 "myuser" "myuser" NULL
.1.3.6.1.6.3.10.1.1.2 0x5def6f8f8b5f5db64efdb2796c3f7538 .1.3.6.1.6.3.10.1.2.2
0x5def6f8f8b5f5db64efdb2796c3f7538 ""
# cat abc-demo.conf
agentAddress 11161
rocommunity public
rwuser myuser
usmUser 1 3 0x80001f88043078303130323033 "myuser" "myuser" NULL
.1.3.6.1.6.3.10.1.1.2 0x5def6f8f8b5f5db64efdb2796c3f7538 .1.3.6.1.6.3.10.1.2.2
0x5def6f8f8b5f5db64efdb2796c3f7538 ""
* run abc-demo
# ./abc-demo
snmpwalk works perfectly here.
# snmpwalk -v3 -e 0x80001f88043078303130323033 -u myuser -l authNoPriv -a MD5
-A abcd1234 localhost:11161 1.3.6.1.4.1
But If i change the background value to 1, it calls netsnmp_daemonize().
- int background = 0;
+ int background = 1;
And snmpwalk does not respond. It gives error as "Timeout: No Response from
localhost:11161"
What is the wrong here?
If because of netsnmp_daemonize() , engineID changes, is it possible to keep
the engineID same after fork too ?
attaching abc-demo.c.
Thanks
Suj
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <signal.h>
#include "abc.h"
static int keep_running;
RETSIGTYPE stop_server(int a) {
keep_running = 0;
}
int main (int argc, char **argv) {
int background = 1;
int syslog = 0;
int agentx_subagent = 0; /* = 0 standalone or sub agent*/
if (syslog)
snmp_enable_calllog();
else
snmp_enable_stderrlog();
/* 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);
}
/* initialize tcpip, if necessary */
SOCK_STARTUP;
/* initialize vacm/usm access control */
if (!agentx_subagent) {
init_vacm_vars();
init_usmUser();
}
/* initialize the agent library */
init_agent("abc-demo");
/* mib code: init_cap001b() cap001b.c */
init_abc();
/* snmp-demo will be used to read snmp-demo.conf files. */
init_snmp("abc-demo");
if (!agentx_subagent && init_master_agent())
{
snmp_log(LOG_INFO, "SNMP: Some error opening one of the specified agent
transports.\n");
exit(1);
}
if (background && netsnmp_daemonize(1, !syslog))
exit(1);
snmp_log(LOG_INFO,"SNMP: SNMP-Subagent is up and running.\n");
/* In case we recevie a request to stop (kill -TERM or kill -INT) */
keep_running = 1;
signal(SIGTERM, stop_server);
signal(SIGINT, stop_server);
snmp_log(LOG_INFO,"SNMP-Subagent is up and running.\n");
while(keep_running) {
agent_check_and_process(1); /* 0 == don't block */
}
/* at shutdown time */
snmp_shutdown("abc-demo");
SOCK_CLEANUP;
return 0;
}
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders