On 3/20/06, Guillaume Desticourt <[EMAIL PROTECTED]> wrote:
ok so what i have done to - try to - solve this problem is:
i ve written a module wich processes the oid .1.3.6.1.3.72.1.3.0
when it receive a get request on this oid, it makes two requests to the netsnmp agent he s plugged into:
.1.3.6.1.3.72.1.5.1.0
.1.3.6.1.3.72.1.5.2.0
i have configured the snmpd as so:
proxy -t 3 -v 2c -r 0 -c private localhost:1042 .1.3.6.1.3.72.1.5.1.0 .1.3.6.1.3.72.1.4.1.0
proxy -t 3 -v 2c -r 0 -c private localhost:1043 .1.3.6.1.3.72.1.5.2.0 .1.3.6.1.3.72.1.4.2.0
(the snmpd forward the requests to two standalone agents i ve written)
but there s still a problem.
if a do:
ultimatetrader% snmpget -t 5 -r 0 -v 2c -c private localhost:1042 .1.3.6.1.3.72.1.4.1.0
Unlinked OID in NET2S-QUOD-MIB: net2squodmib ::= { experimental 72 }
Undefined identifier: experimental near line 16 of /usr/share/snmp/mibs/NET2S-QUOD-MIB.txt
NET2S-QUOD-MIB::agentTest1-INT.0 = INTEGER: 1042
ultimatetrader% snmpget -t 5 -r 0 -v 2c -c private localhost:1043 .1.3.6.1.3.72.1.4.2.0
Unlinked OID in NET2S-QUOD-MIB: net2squodmib ::= { experimental 72 }
Undefined identifier: experimental near line 16 of /usr/share/snmp/mibs/NET2S-QUOD-MIB.txt
NET2S-QUOD-MIB::agentTest1.2.0 = INTEGER: 1043
so the two proxied agents are(/seems to be) ok
hello,
i need a hint regarding the use of the net-snmp agent.
i wrote my MIB, which contains 3 Integer32 variables.
the first two variables are queryed to proxyed agents, using the proxy directive in the snmpd.conf file.
but the third one is to be computed using the first ones, in a dynamic module i wrote (using mib2c).
my question is: how to access the first two variables from the module?
should i make a snmp request - using netsnmp C api - from the module to the net-snmp daemon?
can i access the variables monitored by net-snmp easily and directly?
if you have links, samples and/or ideas i d really appreciate.
ok so what i have done to - try to - solve this problem is:
i ve written a module wich processes the oid .1.3.6.1.3.72.1.3.0
when it receive a get request on this oid, it makes two requests to the netsnmp agent he s plugged into:
.1.3.6.1.3.72.1.5.1.0
.1.3.6.1.3.72.1.5.2.0
i have configured the snmpd as so:
proxy -t 3 -v 2c -r 0 -c private localhost:1042 .1.3.6.1.3.72.1.5.1.0 .1.3.6.1.3.72.1.4.1.0
proxy -t 3 -v 2c -r 0 -c private localhost:1043 .1.3.6.1.3.72.1.5.2.0 .1.3.6.1.3.72.1.4.2.0
(the snmpd forward the requests to two standalone agents i ve written)
but there s still a problem.
ultimatetrader% snmpget -t 5 -r 0 -v 2c -c private localhost:1042 .1.3.6.1.3.72.1.4.1.0
Unlinked OID in NET2S-QUOD-MIB: net2squodmib ::= { experimental 72 }
Undefined identifier: experimental near line 16 of /usr/share/snmp/mibs/NET2S-QUOD-MIB.txt
NET2S-QUOD-MIB::agentTest1-INT.0 = INTEGER: 1042
ultimatetrader% snmpget -t 5 -r 0 -v 2c -c private localhost:1043 .1.3.6.1.3.72.1.4.2.0
Unlinked OID in NET2S-QUOD-MIB: net2squodmib ::= { experimental 72 }
Undefined identifier: experimental near line 16 of /usr/share/snmp/mibs/NET2S-QUOD-MIB.txt
NET2S-QUOD-MIB::agentTest1.2.0 = INTEGER: 1043
so the two proxied agents are(/seems to be) ok
but if i do:
ultimatetrader% snmpget -t 10 -r 0 -v 2c -c private localhost:161 .1.3.6.1.3.72.1.3.0
Unlinked OID in NET2S-QUOD-MIB: net2squodmib ::= { experimental 72 }
Undefined identifier: experimental near line 16 of /usr/share/snmp/mibs/NET2S-QUOD-MIB.txt
NET2S-QUOD-MIB::starterAgentPID.0 = INTEGER: 666
when i have a look at the syslog, i can see that the two requests to from the module to the snmpd have been timeouted.
the problem is that the snmpd answers the module request just after the module has ansered the initial request (according to ethereal).
here is the code of the module i wrote:
void
init_experimental(void)
{
static oid starterAgentProcess_oid[] = { 1,3,6,1,3,72,1,1 };
static oid starterAgentStart_oid[] = { 1,3,6,1,3,72,1,2 };
static oid starterAgentPID_oid[] = { 1,3,6,1,3,72,1,3 };
DEBUGMSGTL(("experimental", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("starterAgentProcess", handle_starterAgentProcess,
starterAgentProcess_oid, OID_LENGTH(starterAgentProcess_oid),
HANDLER_CAN_RWRITE
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("starterAgentStart", handle_starterAgentStart,
starterAgentStart_oid, OID_LENGTH(starterAgentStart_oid),
HANDLER_CAN_RWRITE
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("starterAgentPID", handle_starterAgentPID,
starterAgentPID_oid, OID_LENGTH(starterAgentPID_oid),
HANDLER_CAN_RWRITE
));
snmp_sess_init(&_session);
_session.version = SNMP_VERSION_2c;
_session.peername = strdup("127.0.0.1:161");
_session.community = (u_char *) strdup("private");
_session.community_len = strlen((const char *)_session.community);
_session.retries = 0;
_session.timeout = 3000000; // 3 secondes
_session_handler = snmp_open(&_session);
if (!_session_handler)
{
DEBUGMSGTL(("experimental", "session initialization failed\n"));
}
else
{
DEBUGMSGTL(("experimental", "session initialized\n"));
}
}
int
handle_starterAgentPID(netsnmp_mib_handler* handler,
netsnmp_handler_registration* reginfo,
netsnmp_agent_request_info* reqinfo,
netsnmp_request_info* requests)
{
DEBUGMSGTL(("experimental", "gloire a Shoton\n"));
oid _oid1[MAX_OID_LEN];
::std::size_t _oid1_len;
read_objid(".1.3.6.1.3.72.1.5.1.0",
_oid1,
&_oid1_len);
oid _oid2[MAX_OID_LEN];
::std::size_t _oid2_len;
read_objid(".1.3.6.1.3.72.1.5.2.0",
_oid2,
&_oid2_len);
struct snmp_pdu* _pdu1 = snmp_pdu_create(SNMP_MSG_GET);
snmp_add_null_var(_pdu1,
_oid1,
_oid1_len);
struct snmp_pdu* _pdu2 = snmp_pdu_create(SNMP_MSG_GET);
snmp_add_null_var(_pdu2,
_oid2,
_oid2_len);
struct snmp_pdu* response1 = 0;
int status1 = -1;
struct snmp_pdu* response2 = 0;
int status2 = -1;
switch(reqinfo->mode)
{
case MODE_GET:
status1 = snmp_synch_response(_session_handler,
_pdu1,
&response1);
status2 = snmp_synch_response(_session_handler,
_pdu2,
&response2);
if (status1 == STAT_SUCCESS &&
response1->errstat == SNMP_ERR_NOERROR)
{
DEBUGMSGTL(("experimental", "response1 ok\n"));
}
else
{
DEBUGMSGTL(("experimental", "response1 ko\n"));
snmp_sess_perror("LOSE: snmpget1 error:",
_session_handler);
}
if (status2 == STAT_SUCCESS &&
response2->errstat == SNMP_ERR_NOERROR)
{
DEBUGMSGTL(("experimental", "response2 ok\n"));
}
else
{
DEBUGMSGTL(("experimental", "response2 ko\n"));
snmp_sess_perror("LOSE: snmpget2 error:",
_session_handler);
}
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
(u_char *) &sapid/* XXX: a pointer to the scalar's data */,
sizeof(u_long)/* XXX: the length of the data in bytes */);
break;
default:
return SNMP_ERR_GENERR;
}
and the syslog:
Mar 22 14:36:06 ultimatetrader snmpd[24125]: Connection from 127.0.0.1
Mar 22 14:36:06 ultimatetrader snmpd[24125]: experimental:
Mar 22 14:36:06 ultimatetrader snmpd[24125]: gloire a Shoton
Mar 22 14:36:06 ultimatetrader snmpd[24125]: Connection from 127.0.0.1
Mar 22 14:36:09 ultimatetrader snmpd[24125]: Connection from 127.0.0.1
Mar 22 14:36:12 ultimatetrader snmpd[24125]: experimental:
Mar 22 14:36:12 ultimatetrader snmpd[24125]: response1 ko
Mar 22 14:36:12 ultimatetrader snmpd[24125]: LOSE: snmpget1 error:: Timeout
Mar 22 14:36:12 ultimatetrader snmpd[24125]: experimental:
Mar 22 14:36:12 ultimatetrader snmpd[24125]: response2 ko
Mar 22 14:36:12 ultimatetrader snmpd[24125]: LOSE: snmpget2 error:: Timeout
return SNMP_ERR_NOERROR;
}
i have really no idea why the netsnmp agent answers so late (though it had already been answered by the proxyed agents).
any help would be greatly appreciated, because i am really stuck on that one.
thanks,
--
Guillaume Desticourt
