RE: popen() is executed many times in MODE_SET_ACTION:

<[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi ,

     Please check your agentxRetries value in snmpd.conf file.

Thanks

Krishna

 

 

________________________________

From: [email protected] [mailto:[email protected]] On Behalf Of goon863
Sent: Tuesday, October 16, 2007 4:09 PM Krishna
To: [email protected]
Subject: Re:popen() is executed many times in MODE_SET_ACTION:

 

Sorry for my mistake.my env is uclinux and the net-snmp is 5.0.9 v.I use enseirb.c form net-snmp homepage.And add popen().
 
 
netsnmp_register_instance(netsnmp_create_handler_registration
                              ("led2",
                               do_led2, led2_oid, OID_LENGTH(led2_oid), HANDLER_CAN_RWRITE));
 
 
int
do_led2(netsnmp_mib_handler *handler,
        netsnmp_handler_registration *reginfo,
        netsnmp_agent_request_info *reqinfo,
        netsnmp_request_info *requests)
{
 char tmp;
    /*
     * We are never called for a GETNEXT if it's registered as a
     * "instance", as it's "magically" handled for us.  
     */
    /*
     * a instance handler also only hands us one request at a time, so
     * we don't need to loop over a list of requests; we'll only get one. 
     */
    switch (reqinfo->mode) {
    case MODE_GET:

// system("ping -c 3 192.168.0.1");
  MYDEBUG( printf("popen haha (%s  %d\n) ... ", __FILE__,__LINE__));
        snmp_set_var_typed_value(requests->requestvb,
     ASN_INTEGER,
                                 (u_char *) &led2,
     sizeof(led2));
        DEBUGMSGTL(("enseirb", "led2 current value :  %d\n", led2));
        break;
        /*
         * SET REQUEST
         *
         * multiple states in the transaction.  See:
         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
         */
    case MODE_SET_RESERVE1:
        break;
    case MODE_SET_RESERVE2:
        break;
    case MODE_SET_FREE:
        /*
         * XXX: free resources allocated in RESERVE1 and/or
         * RESERVE2.  Something failed somewhere, and the states
         * below won't be called. 
         */
        break;
    case MODE_SET_ACTION:
        /*
         * XXX: perform the value change here 
         */
// lpdata = inb(lp_base);
 led2 = *(requests->requestvb->val.integer);
 MYDEBUG( printf("run here (%s  %d\n) ... ", __FILE__,__LINE__));
  if(led2==20) popen("ping -c 6 www.google.com","r <http://www.google.com> ");

        break;
    case MODE_SET_COMMIT:
        /*
         * XXX: delete temporary storage 
         */
        break;
    case MODE_SET_UNDO:
        /*
         * XXX: UNDO and return to previous value for the object 
         */
        break;
    default:
        /*
         * we should never get here, so this is a really bad error 
         */
        return SNMP_ERR_GENERR;
    }
    return SNMP_ERR_NOERROR;
}

 





________________________________

 LOGO<http://mimg.163.com/hd/163/163footer/163footer_50.jpg> 

把爱心注入牛奶,共同凝聚这份力量 <http://popme.163.com/link/003515_0929_938.html> 
快来参加蒙牛免费赠奶爱心行动 <http://popme.163.com/link/003515_0929_938.html>

-------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.