This is a discussion on Custom SNMP subagent within the SNMP Users forums, part of the Networking and Network Related category; Hi all, I have a question concerning SNMP on linux. I am making a custom SNMP sub-agent to be ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all,
I have a question concerning SNMP on linux. I am making a custom SNMP sub-agent to be able to get and set some specific information about my systems. That is working almost fine, but ... If I change one of the settings via an external program on the system, I have to perform 2 snmpget's in order to be able to get the correct value. It seams like the first time a perform the snmpget, first the currently stored value is returned, and after that the processBrightnessRequest is called. (see code below) Is there a way to make sure that the callback function is called (and finished) prior to returning a value, or am I using the wrong functions altogether? Thanks a lot in advance, Dirk A code snippet: void init_dZidcmBrightness(void) { netsnmp_handler_registration *reg; netsnmp_watcher_info *winfo; static oid dZidcmBrightness_oid[] = { 1,3,6,1,4,1,1327,1,2,2,1,1,2 }; reg = netsnmp_create_handler_registration("dZidcmBrightn ess", processBrightnessRequest, dZidcmBrightness_oid, OID_LENGTH(dZidcmBrightness_oid), HANDLER_CAN_RWRITE); winfo = netsnmp_create_watcher_info(&dZidcmBrightness, sizeof(long), ASN_INTEGER, WATCHER_FIXED_SIZE); if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) { snmp_log( LOG_ERR, "Failed to register watched dZidcmBrightness" ); } } int processBrightnessRequest(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { DZ_RETURN_VALUE result = -1; switch (reqinfo->mode) { case MODE_GET: // Read the value MonitorGetBrightness(&dZidcmBrightness); break; case MODE_SET_RESERVE1: break; case MODE_SET_RESERVE2: break; case MODE_SET_FREE: break; case MODE_SET_ACTION: // Set the value result = MonitorSetBrightness(*(requests->requestvb- >val.integer)); break; case MODE_SET_COMMIT: break; case MODE_SET_UNDO: break; default: snmp_log(LOG_INFO, "Unknown mode\n\n"); } return 0; - Hide quoted text - |