C
challman
I'm executing the following:
def run(self):
# get ntp_column
pop = os.popen("snmpget -v 1 -c SLI398uwiE " + self.host + "
1.3.6.1.4.1.9.9.168.1.1.9.0\n")
popS = string.join(pop.readlines())
if "Unknown host" in popS:
output.write(self.host + " - unknow host.\n")
return
elif "Error in packet" in popS:
output.write(self.host + " - error in SNMP query.\n")
return
popS = popS.split('INTEGER: ')
clmn = str(popS[1].replace('\n', ''))
time.sleep(1)
# get ntpRootDelay
pop = os.popen("snmpget -v 1 -c readonly " + self.host + "
1.3.6.1.4.1.9.9.168.1.2.1.1.13." + clmn + "\n")
popS = string.join(pop.readlines())
if "Unknown host" in popS:
output.write(self.host + " - unknow host.\n")
return
elif "Error in packet" in popS:
output.write(self.host + " - error in SNMP query.\n")
return
popS = popS.split('Hex-STRING: ')
delay = popS[1].replace('\n', '')
delay = delay.replace(' ', '')
The output from the second popen is:
SNMPv2-SMI::enterprises.9.9.168.1.2.1.1.13.51858 = Hex-STRING: 00 00 00
26
I need to get the Hex-STRING into the following format: 0.0038.. I know
how to covert 26 to 38 but I haven't figured out how to pad it or place
the decimal point between the while number and the decimal.
def run(self):
# get ntp_column
pop = os.popen("snmpget -v 1 -c SLI398uwiE " + self.host + "
1.3.6.1.4.1.9.9.168.1.1.9.0\n")
popS = string.join(pop.readlines())
if "Unknown host" in popS:
output.write(self.host + " - unknow host.\n")
return
elif "Error in packet" in popS:
output.write(self.host + " - error in SNMP query.\n")
return
popS = popS.split('INTEGER: ')
clmn = str(popS[1].replace('\n', ''))
time.sleep(1)
# get ntpRootDelay
pop = os.popen("snmpget -v 1 -c readonly " + self.host + "
1.3.6.1.4.1.9.9.168.1.2.1.1.13." + clmn + "\n")
popS = string.join(pop.readlines())
if "Unknown host" in popS:
output.write(self.host + " - unknow host.\n")
return
elif "Error in packet" in popS:
output.write(self.host + " - error in SNMP query.\n")
return
popS = popS.split('Hex-STRING: ')
delay = popS[1].replace('\n', '')
delay = delay.replace(' ', '')
The output from the second popen is:
SNMPv2-SMI::enterprises.9.9.168.1.2.1.1.13.51858 = Hex-STRING: 00 00 00
26
I need to get the Hex-STRING into the following format: 0.0038.. I know
how to covert 26 to 38 but I haven't figured out how to pad it or place
the decimal point between the while number and the decimal.