18.07.2019, 14:07
Attached an example for a data type OCTET STRING. It is important to clarify that if you want to send a value, it must be passed from ascii to hexadecimal and separated by two points (. For example, the asci 30 when passed to hexadecimal is 33:30. On the other hand, when writing the type of data to write, you can use the type of data or the number that represents it, according to the documentation of LUA SNMP (http://luasnmp.luaforge.net/ objects.html), whichever of the two is possible.
Code:
val=event.getvalue()
require('snmp')
conn, err = snmp.open({
version = snmp.SNMPv1,
community = 'public',
peer = '192.168.0.222',
})
assert(conn, err)
if val==true then
vbIn = {
{oid = "1.3.6.1.4.1.1248.4.1.1.2.1.0", type=snmp.TYPE_INTEGER, value = "1"},
{oid = "1.3.6.1.4.1.1248.4.1.1.2.2.0", type=2, value = "33:30"}
}
vbOut, err, index = conn:set(vbIn)
log(vbOut)
else
vbIn = {
{oid = "1.3.6.1.4.1.1248.4.1.1.2.1.0", type=snmp.TYPE_INTEGER, value = "0"}
}
vbOut, err, index = conn:set(vbIn)
end
conn:close()