Closed fbettag closed 4 years ago
At the moment, we're using OTP's :snmpm.sync_set/5
to handle SNMPSET. According to that documentation,
When
var_and_val()
is{oid(), value()}
, the manager makes an educated guess based on the loaded mibs.
which holds, here, as this is precisely the format we pass now. Still, none of the code cited by the trace seems to check MIBs for type information.
I think that, particularly in cases where obtaining the requisite MIB is unreasonable or impossible, we need to accept type hints from the varbind input. I'll add this and let you know once it's available.
thanks! i am not using any mibs really, i just have the oids as macros up top and use @bla_oid <> [port_id] or whatever to concat them. :)
@fbettag Try again while using one of the value_type()
atoms accepted by :snmpm
. In the case that you're setting an octet string, try the :s
shorthand type, or feel free to use :"OCTET STRING"
if it provides better readability.
Let me know how it goes!
Hi there, sorry i was on vacation for a week :)
I tested the new code, and while :s
works like a charm, using :"OCTET STRING"
yields:
[error] Unexpected result: {:error, {:invalid_value_type, :"OCTET STRING"}}
and thank you very much! this helps me a lot!
Yes, it seems I misinterpreted the OTP code. In particular, this function is responsible for interpreting the type
field in varbinds:
var_and_value_to_varbind({Oid, Type, Value}, MiniMIB) ->
Oid2 = flatten_oid(Oid, MiniMIB),
#varbind{oid = Oid2,
variabletype = char_to_type(Type),
value = Value};
var_and_value_to_varbind({Oid, Value}, MiniMIB) ->
Oid2 = flatten_oid(Oid, MiniMIB),
#varbind{oid = Oid2,
variabletype = oid2type(Oid2, MiniMIB),
value = Value}.
char_to_type(i) ->
'INTEGER';
char_to_type(u) ->
'Unsigned32';
char_to_type(g) -> % Gauge, Gauge32
'Unsigned32';
char_to_type(b) ->
'BITS';
char_to_type(ip) ->
'IpAddress';
char_to_type(ia) ->
'IpAddress';
char_to_type(op) ->
'Opaque';
char_to_type(c32) ->
'Counter32';
char_to_type(c64) ->
'Counter64';
char_to_type(tt) ->
'TimeTicks';
char_to_type(o) ->
'OBJECT IDENTIFIER';
char_to_type(s) ->
'OCTET STRING';
char_to_type(C) ->
throw({error, {invalid_value_type, C}}).
Incidentally, this only handles the short form atom value types rather than the long form SNMP types. Sorry for misleading you!
Absolutely not a problem :) thank you
Hi there,
i am trying to set a label for an APC power bar port (its easier for documentation). So i am trying to set the value "newlabel" for PDU Port 1 on 10.4.20.11.
the code in question is below. getting the octet-string label works like a charm. (as opposed to their Unsigned32 and Integer32 (as written in the other ticket).
Thank you very much in advance