![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Custom SNMP subagent
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? If this is not the correct newsgroup for this question, please refer me to the correct place. 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; } |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|