Re: about net-snmp not restore data and get data from traffic porcess every time when recv a snmp message form MANAGER?
daily study <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
hi, all:
first, thank you very much, Dave!
I stuy carefully your answer, and i have some further questions,~
> My traffic model as below:
> traffic process1<--(private protocol)-->agent process<-(snmp
protocol)->manager
> |
> traffic process2<--(private protocol)--
> Figure processes draft
> Traffic processes and agent process are in one computer, and manager
in another computer.
> Agent process does not save any real data and only convert the snmp
oid to private_id used in traffic process.
> Agent get/getnext/set real data from traffic processes every time when
agent receive get/getnext/set snmp message from manager.
> I think agent will send (message type, private_id1, private id2,....)
to traffic process when agent receive snmp message from manager.
> (private id will be converted from OID, message type including
GET/GETNEXT/SET )
> and agetn will send real snmp message to manager when agent receive
(message type, private_id1, private id2,....)
> from traffic process (private id will be converted to OID ,message
type including RESPONSE/ TRAP).
> 1. I want to use net-snmp as such agent, Could i use net-snmp in
the
> model above ? How to use net-snmp? Could give me some examples in
such
> model?
--Yes - you could use Net-SNMP for this.
--What you are describing sounds similar to the existing standard
--extension protocols
--(SMUX or AgentX) or the Net-SNMP-specific extension mechanisms
(sh/exec/extend
--or pass/pass_persist).
--
--The cleanest example is probably the AgentX master code.
--See the routine agentx_master_handler() in the file
--mibgroup/agentx/master.c
--
--The details of how you pass the private protocol request on to your
traffic
--processes will be different, but the basic model is likely to be
broadly
--similar.
(1)
I study the master.c file. I find that the routine
agentx_master_handler() process
the SNMP message from MANAGER, then after change to private protocol
and dipatch
the private get/getnext/set message to subagent which
should be my traffic process
and the routine agentx_got_response() process the messges from subagent
the routine agentx_master_handler() process.
Is it right? In traffic process, when receive a getnext private command
message from agent,
I should get the the next oid and its value and send this to agent,
i.e. my real data in traffic process should be built in a list of
lexicographic order.
Is this right?
> 2. I find i may use send_v2trap api to send snmpv2 trap to manager.
--If you want to send a notification from the agent to the manager,
--then 'send_v2trap' would be a perfectly sensible way to do this.
--
--Remember that the version (and destination) of the trap are determined
--by the trap2sink (or equivalent) lines in your snmpd.conf file.
--The agent will convert between versions as appropriate, so calling
--send_v2trap may result in an SNMPv1 (or v3) notification being sent.
-- See the FAQ for more details.
This is OK~
> 3. How and where i can get OID from snmp message from manager?
--The agent will call the handler routine that you register.
--This will include a list of varbinds to be processed, including the
OIDs.
--
--See the code routine mentioned above for an example of what to do
--with this information.
In master.c file, can i use two lines below to get oid and oid len?
size_t nlen = request->requestvb->name_length;
oid *nptr = request->requestvb->name;
I could not find the oid type typedef and guess the type of oid is
INTEGER. Is it right?
> 4. How can i make a snmp message to manager when i receive private
> procotol message from traffic process ? which API in net-snmp i can
use to
> send this RESPONSE message to manager?
--The simplest approach would be if you're happy for the SNMP agent to
--block while wating for a response from the traffic process. You'd
then
--insert the values into the request list (just as for any other MIB
code)
--and return from the handler.
--
--If you don't want the agent to block, then you should mark the
requested
--varbind (i.e. "request") as 'delegated' and awaiting a response.
--That's the approach used in the AgentX code - see
'agentx_got_response'
--for what to do with the return message. I believe there's more on
--delegated requests on the project website, but it's not something I've
--really looked into myself.
--A blocking approach would be much simpler - at least to start with,
I can not find the send function in agentx_got_response.
part code of agentx_got_response below:
--else if (cache->reqinfo->mode == MODE_GET ||
-- cache->reqinfo->mode == MODE_GETNEXT ||
-- cache->reqinfo->mode == MODE_GETBULK) {
-- /*
-- * Replace varbinds for data request types, but not SETs.
-- */
-- DEBUGMSGTL(("agentx/master",
-- "agentx_got_response() beginning...\n"));
-- for (var = pdu->variables, request = requests; request && var;
-- request = request->next, var = var->next_variable) {
-- /*
-- * Otherwise, process successful requests
-- */
-- DEBUGMSGTL(("agentx/master",
-- " handle_agentx_response: processing: "));
-- DEBUGMSGOID(("agentx/master", var->name,
var->name_length));
-- DEBUGMSG(("agentx/master", "\n"));
-- if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_VERBOSE)) {
-- DEBUGMSGTL(("snmp_agent", " >> "));
-- DEBUGMSGVAR(("snmp_agent", var));
-- DEBUGMSG(("snmp_agent", "\n"));
-- }
--
-- /*
-- * update the oid in the original request
-- */
-- if (var->type != SNMP_ENDOFMIBVIEW) {
-- snmp_set_var_typed_value(request->requestvb,
var->type,
-- var->val.string,
var->val_len);
-- snmp_set_var_objid(request->requestvb, var->name,
-- var->name_length);
-- }
-- request->delegated = REQUEST_IS_NOT_DELEGATED;
-- }
--
-- if (request || var) {
-- /*
-- * ack, this is bad. The # of varbinds don't match and
-- * there is no way to fix the problem
-- */
-- snmp_log(LOG_ERR,
-- "response to agentx request illegal. bailing
out.\n");
-- netsnmp_set_request_error(cache->reqinfo, requests,
-- SNMP_ERR_GENERR);
-- }
--
-- if (cache->reqinfo->mode == MODE_GETBULK)
-- netsnmp_bulk_to_next_fix_requests(requests);
--} else {
-- /*
-- * mark set requests as handled
-- */
-- for (request = requests; request; request = request->next) {
-- request->delegated = REQUEST_IS_NOT_DELEGATED;
-- }
--}
--DEBUGMSGTL(("agentx/master",
-- "handle_agentx_response() finishing...\n"));
--netsnmp_free_delegated_cache(cache);
--return 1;
Function netsnmp_set_request_error should be use to send error
response to MANAGER.
Which one is to send valid response message of get command?
netsnmp_bulk_to_next_fix_requests or netsnmp_free_delegated_cache ?
Is it that using request->delegated = REQUEST_IS_NOT_DELEGATED to
inform agent
this request state is REQUEST_IS_NOT_DELEGATED and agent send the
RESPONSE
when netsnmp_free_delegated_cache(cache)??
> -- 5. In snmp normal model, is it ture that agent MUST have the real
data of
> --all OID in defined MIB and agent MUST get real data from traffic
process
> --periodical ?
--No.
--That's certainly one model of working.
--But it's perfectly feasible to implement the MIB within the master
agent,
--and query some extenal subsystem for the actual values to use,
whenever
--a request comes in.
--
--There's nothing inherently different between making a local system
call
--to retrieve the information of interest (say the current clock time),
and
--making some more complicated query from a remote system.
--
--The main reason for using a local cache is to avoid excessive delays
--in getting the necessary information. It's a trade off between speed
--of response, and timeliness of data.
This is very important for me to understand the SNMP concept. Thank
you~~
Now what i think that the action of getting next oid and its value from
GETNEXT response
MUST be in the process which have the whole real value. Is it right?
In agentx style, i have used mib2c to create C file for scalar MIB OID
and can get real data from private MIB by defining a Variable in sub agent.
What i Doubt is how to process table's GETNEXT. In created C handle
routine code for table, it say i does not process GETNEXT, only should
process GET.
But how does sub agent kown row number of creative table whick can be
create dynamically ? and how sub agent kown that witch element in table is
the next?
please help me!!!
thanks a lot.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
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