Networking Forums

Networking Forums > Computer Networking > Linux Networking > Custom SNMP subagent

Reply
Thread Tools Display Modes

Custom SNMP subagent

 
 
dirk.debecker@gmail.com
Guest
Posts: n/a

 
      03-13-2008, 03:35 PM
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;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh vs. scp in custom PAM module Uwe Drekert Linux Networking 1 08-31-2009 10:29 AM
custom nameservers eminhanif@googlemail.com Linux Networking 3 03-30-2009 05:36 PM
IIS Custom FTP Port Rob Windows Networking 1 03-22-2007 12:14 PM
Custom Web Dev design.custom@gmail.com Wireless Internet 0 07-19-2006 06:38 PM
SNMP service is running OK, but get no SNMP relevant data from ser Marlon Brown Windows Networking 0 01-18-2006 06:14 PM



1 2 3 4 5 6 7 8 9 10 11