15.10.2018, 18:02
Good guys, I told them that I have a problem with the request of the OID information of the UPS and that the code works for me, but after several hours, the code stops working and I have to disable and enable the resident function again so that the data can be updated, but after several hours again I can not obtain the values. I look at the error log and the following appears:
Resident script: 16: netsnmp: Unknown host (192.168.0.114) stack traceback: [C]: in function 'assert'
Resident script: 16: netsnmp: Unknown host (192.168.0.111) stack traceback:
[C]: in function 'assert'
The code is the following:
I must clarify that I have the UPS are connected to the network, the connection has not fallen and I have installed the two necessary SNMP packages and I do not have any MIB file (either Mikrotik or UPS) loaded, since the UPS that I am using does not they have a single MIB file, since one information is given to me by a MIB that I found and another one is given to me by another MIB and I did not use the code that the admin indicated after, because the current one seemed more comfortable to edit, besides that I had it done. Currently I ask the variables to 4 UPS, the first question is by resident code at 20 seconds, the second at 30 seconds, 40 and 50 seconds respectively. Thank you and I will be attentive to your comments.
Resident script: 16: netsnmp: Unknown host (192.168.0.114) stack traceback: [C]: in function 'assert'
Resident script: 16: netsnmp: Unknown host (192.168.0.111) stack traceback:
[C]: in function 'assert'
The code is the following:
Code:
--Abrir una sesión con snmp
require "snmp"
local mib, err = snmp.mib.load('/home/ftp/snmp/Mikrotik.mib')
if not mib then
log('Failed to load mib: ' .. err)
end
ups1, err = snmp.open{
version = snmp.SNMPv1,
community = "tekneoCO",
port = 161,
peer = "192.168.0.111",
}
assert(ups1, err)
--Lee los OID del Mib
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.2.1.1.0")
grp.write('8/0/0', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.2.2.5.0")
grp.write('8/0/1', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.4.1.1.0")
grp.write('8/0/2', vbind.value)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.2.5.0")
grp.write('8/0/50', vbind.value)
os.sleep(2)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.2.4.0")
grp.write('8/0/7', vbind.value)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.2.3.0")
grp.write('8/0/8', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.2.2.3.0")
grp.write('8/0/51', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.3.2.4.0")
grp.write('8/0/52', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.3.2.1.0")
grp.write('8/0/53', vbind.value)
os.sleep(2)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.4.2.2.0")
grp.write('8/0/54', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.4.2.1.0")
grp.write('8/0/55', vbind.value)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.4.4.1.5.1")
grp.write('8/0/19', vbind.value)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.5.1.0")
grp.write('8/0/56', vbind.value)
vbind, err = ups1:get("1.3.6.1.2.1.33.1.5.3.1.2.1")
grp.write('8/0/23', vbind.value)
os.sleep(2)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.5.1.0")
grp.write('8/0/26', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.5.7.0")
grp.write('8/0/27', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.6.2.0")
grp.write('8/0/28', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.6.3.0")
grp.write('8/0/29', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.6.4.0")
grp.write('8/0/30', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.5.0")
grp.write('8/0/31', vbind.value)
os.sleep(2)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.1.0")
grp.write('8/0/32', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.4.0")
grp.write('8/0/33', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.5.0")
grp.write('8/0/34', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.6.0")
grp.write('8/0/35', vbind.value)
vbind, err = ups1:get("1.3.6.1.4.1.935.1.1.1.8.7.7.0")
grp.write('8/0/36', vbind.value)