I'm trying to write a program in python that reads the values in a remote terminal unit (RTU) by snmp, using pysnmp.
The thing is: in the RTU every interface has 2 sensors: Temperature and Humidity.
I'm able to to the print but in different times. What I need to do is print both values in the same line.
This is what I have so far.
list = []
list1 = []
OID = "iso.3.6.1.4.1.3699.1.1.2.1.5.1.1.3."
UAD = "iso.3.6.1.4.1.3699.1.1.2.1.5.1.1.7."
for omega in range(1,33):
UAD1 = UAD + str(omega)
list.append(UAD1)
for altarf in range(1,33):
OID1 = OID + str(altarf)
list1.append(OID1)
# this value gives me the interface description
for auriga in lista1:
sistema = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(( hostname, 161)),auriga
)
interfaz = sistema[3][0][1]
print("Estado interfaz ") + str(interfaz)
# this value return the (temp / humidity) of sensors in every interface
for Sculptor in lista:
Sextans = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(( hostname, 161)),Sculptor
)
entrega = Sextans[3][0][1]
entrega = float(entrega) * 0.1
print "sensor " + str(entrega)