I have a C++ program built around glibmm Main Event Loop and need to create an 
SNMP AgentX in it to be used along Net-SNMP own snmpd. I can't find any 
information how to integrate it other than the Tutorial "Instrumenting your own 
code with agentx subagent support" which I find a little shortcoming. 


How do I tie an Net-SNMP AgentX into my the glibmm Main Event Loop ? Perhaps it 
would be easier to use SNMP++/Agent++/AgentX++ instead of net-snmp. 


All communication to the device happens with sending/receiving XML messages. 
The program operates in stages, when receiving signals from various 
parts/managers. I first query the device for all information it has available. 
When it is received and processed I send a signal that is picked up by 
my_client so that it can begin to create the MIB file from this information, 
and then register the scalars. Another one of these signals indicate that the 
data for SNMP request have been received from device. When I get incoming SNMP 
requests I need to wait for this signal before I send the response to the SNMP 
manager/requester. 



Some of my Code: 

main.cpp 
int main(int argc, char **argv) { 



//Needs some code here for SNMP initialization. 
http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/example-demon.c 


my_client client(); 
client.run(); //The Main Event Loop executing within this call to client.run(). 

return (1); 
} 

my_client.cpp 

my_client::my_client( ) : 
_mainloop(Glib::MainLoop::create()) { 

//Define signals 
_manager1.signal_finished().connect(sigc::mem_fun(*this, 
&my_client::manager1_finished)); 

Glib::signal_idle().connect(sigc::bind_return(sigc::mem_fun(*this, 
&my_client::connection), false)); 
} 


void 
my_client::run() { 
_mainloop->run(); 
} 

bool 
my_client::connection() { 

//Getting information from device using manager1. 
... 
} 

void 
my_client::manager1_finished(bool finished) { 
//...Creating MIB file 

//...Register all scalars 
for (All Scalars) { 
netsnmp_register_scalar_group( 

netsnmp_create_handler_registration( text, 
handle_snmp, 
group_oid, 
OID_LENGTH(group_oid), 
HANDLER_CAN_RONLY 
), 1, scalars_total); 
} 
} 

int 
handle_snmp(netsnmp_mib_handler *handler, 
netsnmp_handler_registration *reginfo, 
netsnmp_agent_request_info *reqinfo, 
netsnmp_request_info *requests) { 

//Sending SNMP request to client.... 

//THIS MUST BE DONE WHEN I RECEIVE SIGNAL FROM ONE OF MY MANAGERS 
//THAT THE DATA IS READY/RETRIEVED FROM DEVICE. AND NOT BEFORE. 
snmp_set_var_typed_value(requests->requestvb, 
type, 
datapointer, 
length); 

} 





What I need is to bake this handle_snmp into my Main Event Loop so that 
snmp_set_var_typed_value is called when I receive a signal that I have gotten 
the value from the device. 



This is what I have for now: 


    1. C++ program running a Main Event Loop. Functions/Routines for querying 
the device and creating a MIB definition file. 
    2. Standalone C MIB module, And an snmp-deamon.c containing "main" and 
net-snmp initialization(instead of using net-snmp-config --compile-subagent). 
An example agent made from the Net-SNMP tutorials. 


I am not sure how to tie these two parts together. The class my_client is 
responsible for communicating with the device, handles all the signals, create 
the MIB definition, registers the scalars, and retrieves the information needed 
from the device. 

CONFIDENTIALITY
This e-mail and any attachment contain KONGSBERG information which may be 
proprietary, confidential or subject to export regulations, and is only meant 
for the intended recipient(s). Any disclosure, copying, distribution or use is 
prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in 
error, please delete it immediately from your system and notify the sender 
properly.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
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

Reply via email to