On 07/10/2013 02:04 PM, zhuyj wrote:
On 07/10/2013 01:41 PM, Niels Baggesen wrote:
On Wed, Jul 10, 2013 at 10:34:05AM +0800, zhuyj wrote:
root@localhost:/root> snmpset -v 2c -c public 192.168.2.15
.1.3.6.1.6.3.12.1.2.1.9.0.25 i 5
SNMP-TARGET-MIB::snmpTargetAddrRowStatus.'..' = INTEGER: createAndWait(5)
root@localhost:/root> snmpget -v 2c -c NETMAN 192.168.2.15
.1.3.6.1.6.3.12.1.2.1.9.0.25 i 5
snmp_build: unknown failuresnmpget: Error building ASN.1 representation
(Can't build OID for variable)

Notice that there is no error when setting, only when trying to get.
That is natural. You are setting one object to the value 5, but you
are trying to get 3 objects, 1.3.6.1.6.3.12.1.2.1.9.0.25, i, and 5.

snmpget complains that it cannot build the ASN.1 representation for the
object 5, which is quite correct as the first element of an object
identifier must be 0 or 1.

What you want is just
snmpget -v 2c -c NETMAN 192.168.2.15 .1.3.6.1.6.3.12.1.2.1.9.0.25

I admit that the error message could have been clearer.

/Niels

Sorry. Maybe I am wrong with the command.

These command can work well.
user@ubuntu1004:~/net-snmp-5.7.2$ <mailto:revo@ubuntu1004:%7E/net-snmp-5.7.2$> snmpset -v 2c -c NETMAN 127.0.0.1 .1.3.6.1.6.3.12.1.2.1.9.8.25 i 5
SNMP-TARGET-MIB::snmpTargetAddrRowStatus.'..' = INTEGER: createAndWait(5)
user@ubuntu1004:~/net-snmp-5.7.2$ <mailto:revo@ubuntu1004:%7E/net-snmp-5.7.2$> snmpget -v 2c -c NETMAN 127.0.0.1 .1.3.6.1.6.3.12.1.2.1.9.8.25 -Ofn
.1.3.6.1.6.3.12.1.2.1.9.8.25 = INTEGER: notReady(3)

But these command can not work.
user@ubuntu1004:~/net-snmp-5.7.2$ <mailto:revo@ubuntu1004:%7E/net-snmp-5.7.2$> snmpset -v 2c -c NETMAN 127.0.0.1 .1.3.6.1.6.3.12.1.2.1.9.0.25 i 5
SNMP-TARGET-MIB::snmpTargetAddrRowStatus.'..' = INTEGER: createAndWait(5)
user@ubuntu1004:~/net-snmp-5.7.2$ <mailto:revo@ubuntu1004:%7E/net-snmp-5.7.2$> snmpget -v 2c -c NETMAN 127.0.0.1 .1.3.6.1.6.3.12.1.2.1.9.0.25 -Ofn .1.3.6.1.6.3.12.1.2.1.9.0.25 = No Such Instance currently exists at this OID

The difference is in OID. One is .1.3.6.1.6.3.12.1.2.1.9.8.25, the other is .1.3.6.1.6.3.12.1.2.1.9.0.25.
.1.3.6.1.6.3.12.1.2.1.9.8.25 can work
.1.3.6.1.6.3.12.1.2.1.9.0.25 can not work.

Zhuyj
Hi, all

In OID .1.3.6.1.6.3.12.1.2.1.9.0.25, 0.25 is snmpTargetAddrName. The following is its definition.

snmpTargetAddrName OBJECT-TYPE
    SYNTAX      SnmpAdminString (SIZE(1..32))
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "The locally arbitrary, but unique identifier associated
         with this snmpTargetAddrEntry."
    ::= { snmpTargetAddrEntry 1 }

The type of snmpTargetAddrName is SnmpAdminString.
The definition of SnmpAdminString is:
SnmpAdminString ::= TEXTUAL-CONVENTION
    DISPLAY-HINT "255t"
    STATUS       current
    DESCRIPTION "An octet string containing administrative
                 information, preferably in human-readable form.

                 To facilitate internationalization, this
                 information is represented using the ISO/IEC
                 IS 10646-1 character set, encoded as an octet
                 string using the UTF-8 transformation format
                 described in [RFC2279].

                 Since additional code points are added by
                 amendments to the 10646 standard from time
                 to time, implementations must be prepared to
                 encounter any code point from 0x00000000 to
                 0x7fffffff.  Byte sequences that do not
                 correspond to the valid UTF-8 encoding of a
                 code point or are outside this range are
                 prohibited.

The use of control codes should be avoided.

                 When it is necessary to represent a newline,
                 the control code sequence CR LF should be used.

                 The use of leading or trailing white space should
                 be avoided.

                 For code points not directly supported by user
                 interface hardware or software, an alternative
                 means of entry and display, such as hexadecimal,
                 may be provided.

                 For information encoded in 7-bit US-ASCII,
                 the UTF-8 encoding is identical to the
                 US-ASCII encoding.

                 UTF-8 may require multiple bytes to represent a
                 single character / code point; thus the length
                 of this object in octets may be different from
                 the number of characters encoded.  Similarly,
                 size constraints refer to the number of encoded
                 octets, not the number of characters represented
                 by an encoding.

                 Note that when this TC is used for an object that
                 is used or envisioned to be used as an index, then
                 a SIZE restriction MUST be specified so that the
                 number of sub-identifiers for any object instance
                 does not exceed the limit of 128, as defined by
                 [RFC3416].

                 Note that the size of an SnmpAdminString object is
                 measured in octets, not characters.
                "
    SYNTAX       OCTET STRING (SIZE (0..255))

In its definition, it mentions "The use of control codes should be avoided.". In rfc20, 0 (NUL) is
control code.
So it can not used in snmpAdminString as normal codes.
Can we explain it like this?

Best Regards!
Zhuyj

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to