Discussion:
HOW to use snmpset to set value of a COUNTER64 type OID parameter
lucky goyal
2008-11-04 11:05:10 UTC
Permalink
Hi ALL,

I want to set a OID parameter which is of type "COUNTER64" using 'snmpset'. The parameter has MAX-ACCESS read-write and is member of a Table. I am trying following command

snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234

But agent sends back a response with error status as WRONG_TYPE(7).

Could anyone please tell how to set value of this COUNTER64 variable.

Thanks and Regards,
Lucky
Arazo Camprecios, Marc
2008-11-04 12:12:28 UTC
Permalink
Hello,



I had the same problem. It seems that when using an Unisgned value in a
table the default function which checks the variable type doesn't work
properly.



Try using this one:



ret = netsnmp_check_vb_type(requests->requestvb, ASN_UNSIGNED);



-----------------

Marc Arazo



________________________________

De: lucky goyal [mailto:***@yahoo.com]
Enviado el: martes, 04 de noviembre de 2008 12:05
Para: net-snmp-***@lists.sourceforge.net
Asunto: HOW to use snmpset to set value of a COUNTER64 type OID
parameter



Hi ALL,

I want to set a OID parameter which is of type "COUNTER64" using
'snmpset'. The parameter has MAX-ACCESS read-write and is member of a
Table. I am trying following command

snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234

But agent sends back a response with error status as WRONG_TYPE(7).

Could anyone please tell how to set value of this COUNTER64 variable.

Thanks and Regards,
Lucky
lucky goyal
2008-11-05 04:04:12 UTC
Permalink
Hi Marc,

Thanks for your reply. You are right. I had implemented MY-MIB as subagent using 'mib2c' code generation tool. The problem was in the function 'netsnmp_check_vb_type_and_size()' which is called in subagent code . When the 'U' is used to represent the set variable type (snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234 ) the variable type sent in the SNMP SET request is ASN_OPAQUE, whereas the variable type for COUNTER64 is ASN_COUNTER64. This results in mismatch of type as mentioned by you and the SET operation fails. A work around for this is to compare the incoming variable type with ASN_OPAQUE rather than ASN_COUNTER64, which is what you suggested. I am able to SET the COUNTER64 type OID parameter using this work around(thanks to your reply). But I am wondering if there is a way where the variable type in the incoming request itself is ASN_COUNTER64 and not ASN_OPAQUE? Please let me know if you know one.

Thanks and Regards,
Lucky Goyal




________________________________
From: "Arazo Camprecios, Marc" <***@eservicios.indra.es>
To: lucky goyal <***@yahoo.com>; net-snmp-***@lists.sourceforge.net
Sent: Tuesday, November 4, 2008 5:42:28 PM
Subject: RE: HOW to use snmpset to set value of a COUNTER64 type OID parameter


Hello,
 
I had the same problem. It seems that when using an Unisgned value in a table the default function which checks the variable type doesn¢t work properly.
 
Try using this one:
 
ret = netsnmp_check_vb_type(requests->requestvb, ASN_UNSIGNED);
 
-----------------
Marc Arazo
 

________________________________

De:lucky goyal [mailto:***@yahoo.com]
Enviado el: martes, 04 de noviembre de 2008 12:05
Para: net-snmp-***@lists.sourceforge.net
Asunto: HOW to use snmpset to set value of a COUNTER64 type OID parameter
 
Hi ALL,

I want to set a OID parameter which is of type "COUNTER64" using 'snmpset'. The parameter has MAX-ACCESS read-write and is member of a Table. I am trying following command

 snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234

But agent sends back a response with error status as  WRONG_TYPE(7).

Could anyone please tell how to set value of this COUNTER64 variable.

Thanks and Regards,
Lucky
Dave Shield
2008-11-05 08:54:35 UTC
Permalink
Whenthe 'U' is used to represent the set variable type (snmpset -v2c -cpublic
localhost MY-MIB::Variable.1 U 1234 ) the variable type sent in the SNMP SET
request is ASN_OPAQUE
That is correct.
The type 'U' indicates the (non-standard) type "Unsigned64",
which is implemented as an Opaque-wrapped type.
whereas the variable type for COUNTER64 is ASN_COUNTER64.
The type character for Counter64 is 'C', not 'U'

But please note that it is not valid to define a Counter or Counter64
object with write-access, and hence these types cannot be used with
a SET request. See RFC 2578, sections 7.1.6 & 7.1.10


Dave
Arazo Camprecios, Marc
2008-11-05 07:53:05 UTC
Permalink
Hi Lucky,



Since the “real” value check in my application is done in the “core” process rather than in the subagent I’m just using the function I told you to make a first and quick check.



Actually, I’m a beginner with SNMP and I don’t know nothing further about this question. Maybe Dave or Mike could give us some more help.



Regards,



Marc Arazo



________________________________

De: lucky goyal [mailto:***@yahoo.com]
Enviado el: miércoles, 05 de noviembre de 2008 5:04
Para: Arazo Camprecios, Marc; net-snmp-***@lists.sourceforge.net
Asunto: Re: HOW to use snmpset to set value of a COUNTER64 type OID parameter



Hi Marc,



Thanks for your reply. You are right. I had implemented MY-MIB as subagent using 'mib2c' code generation tool. The problem was in the function 'netsnmp_check_vb_type_and_size()' which is called in subagent code . When the 'U' is used to represent the set variable type (snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234 ) the variable type sent in the SNMP SET request is ASN_OPAQUE, whereas the variable type for COUNTER64 is ASN_COUNTER64. This results in mismatch of type as mentioned by you and the SET operation fails. A work around for this is to compare the incoming variable type with ASN_OPAQUE rather than ASN_COUNTER64, which is what you suggested. I am able to SET the COUNTER64 type OID parameter using this work around(thanks to your reply). But I am wondering if there is a way where the variable type in the incoming request itself is ASN_COUNTER64 and not ASN_OPAQUE? Please let me know if you know one.



Thanks and Regards,

Lucky Goyal



________________________________

From: "Arazo Camprecios, Marc" <***@eservicios.indra.es>
To: lucky goyal <***@yahoo.com>; net-snmp-***@lists.sourceforge.net
Sent: Tuesday, November 4, 2008 5:42:28 PM
Subject: RE: HOW to use snmpset to set value of a COUNTER64 type OID parameter

Hello,



I had the same problem. It seems that when using an Unisgned value in a table the default function which checks the variable type doesnÊŒt work properly.



Try using this one:



ret = netsnmp_check_vb_type(requests->requestvb, ASN_UNSIGNED);



-----------------

Marc Arazo



________________________________

De: lucky goyal [mailto:***@yahoo.com]
Enviado el: martes, 04 de noviembre de 2008 12:05
Para: net-snmp-***@lists.sourceforge.net
Asunto: HOW to use snmpset to set value of a COUNTER64 type OID parameter



Hi ALL,

I want to set a OID parameter which is of type "COUNTER64" using 'snmpset'. The parameter has MAX-ACCESS read-write and is member of a Table. I am trying following command

snmpset -v2c -cpublic localhost MY-MIB::Variable.1 U 1234

But agent sends back a response with error status as WRONG_TYPE(7).

Could anyone please tell how to set value of this COUNTER64 variable.

Thanks and Regards,
Lucky
lucky goyal
2008-11-06 10:52:33 UTC
Permalink
Hi ALL,


Thanks for your reply Dave.
Post by Dave Shield
Whenthe 'U' is used to represent the set variable type (snmpset -v2c -cpublic
localhost MY-MIB::Variable.1 U 1234 ) the variable type sent in the SNMP SET
request is ASN_OPAQUE
That is correct.
The type 'U' indicates the (non-standard) type "Unsigned64",
which is implemented as an Opaque-wrapped type.
whereas the variable type for COUNTER64 is ASN_COUNTER64.
The type character for Counter64 is 'C', not 'U'
OK
Post by Dave Shield
But please note that it is not valid to define a Counter or Counter64
object with write-access, and hence these types cannot be used with
a SET request. See RFC 2578, sections 7.1.6 & 7.1.10
But I need to define an object of "Unsigned64" type with read-write access. I did not find any SYNTAX notation other than "Counter64" which serves this purpose. Kindly let me know if there is any other standard SYNTAX notation which I can use to represent an object of unsigned 64-bit type with read-write access.

Thanks and Regards,
Lucky
Mike Ayers
2008-11-07 18:26:23 UTC
Permalink
Sent: Thursday, November 06, 2008 2:53 AM
But I need to define an object of "Unsigned64" type with
read-write access. I did not find any SYNTAX notation other
than "Counter64" which serves this purpose. Kindly let me
know if there is any other standard SYNTAX notation which I
can use to represent an object of unsigned 64-bit type with
read-write access.
Don't jam a square peg into a round hole. Counter64 objects have a defined syntax, which is why they are never to be settable. These are the only 64 bit objects available, but you can always construct an unsigned 64 bit value out of 2 32 bit unsigned values, specifying one to be the lower bits and the other to be the upper bits. You must guarantee that reads and writes are simultaneous for the two within an SNMP operation, or bad things will happen. Another alternative is to use OCTET STRING (SIZE (0..7)). Neither allows basic tools such as snmpget to display the value, BTW.


HTH,

Mike

Loading...