Custom SNMP subagent

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 ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2008
dirk.debecker@gmail.com
 
Posts: n/a
Default 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?
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 -
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:27 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0