On 8 Apr 2008 06:24:13 -0000, <[EMAIL PROTECTED]> wrote:
> i gave command
>
> snmpget -v 2c -c public localhost leaf.leafNetwork.leafNetworkHostsIp.0
There's no point in doing this until you've actually finished coding the
'leaf.c' file. SNMP isn't magic, and doesn't know what values to return.
*You* have got to tell the agent how to report the information that you're
interested in.
> and my leaf.c leaf mib look like
>
> LEAF-MIB DEFINITIONS ::= BEGIN
> IMPORTS
> mgmt, experimental, NetworkAddress, IpAddress, Counter, Gauge,
> TimeTicks
> FROM RFC1155-SMI
> OBJECT-TYPE
> FROM RFC-1212;
You should really be writing MIBs in SMIv2.
This old-style of MIB has been effectively obsolete for almost a decade now.
> leaf OBJECT IDENTIFIER ::= { iso org(3) dod(6) internet(1)
> experimental(3) 100 }
This area is really intended for use by IETF working groups, not private
individuals. If you want a temporary location for your MIB, I'd suggest
you use NET-SNMP-MIB::netSnmpPlaypen (1.3.6.1.4.1.8072.9999.9999)
Taking the object above as an example:
> leafNetworkHostsIP OBJECT-TYPE
> SYNTAX IpAddress
> ACCESS read-write
> STATUS mandatory
> DESCRIPTION
> "/etc/hosts"
> ::= { leafNetwork 3 }
[snip]
>
> (WE DONT KNOW WHAT EXACTLY WE SHOULD WRITE IN THIS .C FILE
> PLEASE HELP US.)
What information do you want to return for the leafNetworkHosts.IP object?
Your DESCRIPTION just reads "/etc/hosts", which isn't very informative.
Try
> int
> handle_leafNetworkHostsIP(netsnmp_mib_handler *handler,
> netsnmp_handler_registration *reginfo,
> netsnmp_agent_request_info *reqinfo,
> netsnmp_request_info *requests)
> {
> int ret;
u_long addr = 0x7f000001;
>
> switch (reqinfo->mode) {
> case MODE_GET:
> snmp_set_var_typed_value(requests->requestvb, ASN_IPADDRESS,
(u_char *) &addr,
sizeof(addr));
> break;
/* To start with - implement as Read-Only */
> case MODE_SET_RESERVE1:
> netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_NOTWRITABLE);
> break;
>
> case MODE_SET_FREE:
> break;
> default:
> snmp_log(LOG_ERR,
> "unknown mode (%d) in handle_leafNetworkHostsIP\n",
> reqinfo->mode);
> return SNMP_ERR_GENERR;
> }
>
> return SNMP_ERR_NOERROR;
> }
(and similarly for the other functions).
That should at least allow you to get a working (read-only) agent.
Then start replacing the dummy values with real ones, retrieving
the necessary information from the appropriate place(s).
I wouldn't worry about SET support until you are comfortable with
the way that GET requests are handled.
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
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