This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SNMP protocol in Logic Machine
#16
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:

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)
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.
Reply


Messages In This Thread
RE: SNMP protocol in Logic Machine - by AEK - 04.09.2018, 09:17
RE: SNMP protocol in Logic Machine - by AEK - 06.09.2018, 06:59
RE: SNMP protocol in Logic Machine - by admin - 06.09.2018, 07:57
RE: SNMP protocol in Logic Machine - by admin - 07.09.2018, 07:00
RE: SNMP protocol in Logic Machine - by admin - 11.09.2018, 06:41
RE: SNMP protocol in Logic Machine - by AEK - 11.09.2018, 09:26
RE: SNMP protocol in Logic Machine - by admin - 12.09.2018, 05:58
RE: SNMP protocol in Logic Machine - by Carlos Padilla - 15.10.2018, 18:02
RE: SNMP protocol in Logic Machine - by admin - 15.10.2018, 18:10
RE: SNMP protocol in Logic Machine - by admin - 16.10.2018, 10:30
RE: SNMP protocol in Logic Machine - by admin - 16.10.2018, 17:50
RE: SNMP protocol in Logic Machine - by admin - 11.04.2019, 09:52
RE: SNMP protocol in Logic Machine - by admin - 17.06.2019, 07:34
RE: SNMP protocol in Logic Machine - by admin - 17.06.2019, 08:34
RE: SNMP protocol in Logic Machine - by admin - 18.06.2019, 08:05
RE: SNMP protocol in Logic Machine - by admin - 11.07.2019, 08:48
RE: SNMP protocol in Logic Machine - by admin - 12.07.2019, 06:15
RE: SNMP protocol in Logic Machine - by admin - 04.11.2019, 12:12
RE: SNMP protocol in Logic Machine - by admin - 21.02.2020, 08:22
RE: SNMP protocol in Logic Machine - by admin - 06.03.2020, 12:26
RE: SNMP protocol in Logic Machine - by admin - 06.03.2020, 18:47
RE: SNMP protocol in Logic Machine - by admin - 07.03.2020, 13:20
RE: SNMP protocol in Logic Machine - by admin - 09.03.2020, 09:21
RE: SNMP protocol in Logic Machine - by admin - 28.03.2020, 15:06
RE: SNMP protocol in Logic Machine - by admin - 12.04.2020, 12:12
RE: SNMP protocol in Logic Machine - by admin - 15.04.2020, 06:08
RE: SNMP protocol in Logic Machine - by admin - 09.12.2020, 07:07
RE: SNMP protocol in Logic Machine - by admin - 11.03.2021, 13:15
RE: SNMP protocol in Logic Machine - by admin - 11.03.2021, 13:34
RE: SNMP protocol in Logic Machine - by admin - 11.03.2021, 14:22
RE: SNMP protocol in Logic Machine - by admin - 19.09.2022, 13:00

Forum Jump: