I found the problem is "ping" command.My env is uclinux and the net-snmp is
5.0.9v.My code is as follow.While i run "snmpget -c public -v2c 192.168.0.148
1.3.6.1.4.1.9362.1.7.0",the snmpd will run several times handle_led7(),and the
code fp=popen("ping -c 8www.google.com","r") is run serveral times too.It just
run one time if natural.If i change fp=popen("ping -c 8www.google.com","r");
to fp=popen("ps -ef","r");or other command,the handle_led7() just run one time
as usual .my code : static oid led7_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1,
7 };
netsnmp_register_scalar(netsnmp_create_handler_registration
("led7", handle_led7, led7_oid,
OID_LENGTH(led7_oid), HANDLER_CAN_RWRITE));
int
handle_led7(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
FILE *fp;
MYDEBUG( printf("popen haha (%s %d\n) ... ", __FILE__,__LINE__));
switch (reqinfo->mode) {
case MODE_GET:
fp=popen("ping -c 8www.google.com","r");
pclose(fp);
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)led7
/* XXX: a pointer to the scalar's data */
,strlen(led7)
/*
* XXX: the length of the data in bytes
*/ );
break;
case MODE_SET_RESERVE1:
…………………… Could you tell me how to solve the problem please?thanks.-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users