Fixed HEX-STRING parsing and invalid supply status from printer-details.py script.
This commit is contained in:
parent
e84a99fc98
commit
8691f697da
1 changed files with 19 additions and 7 deletions
|
@ -132,11 +132,15 @@ def getdata(name, addr, templates):
|
||||||
baseoid + '.6.1'), snmpdata.keys()))
|
baseoid + '.6.1'), snmpdata.keys()))
|
||||||
data += '<table>\n'
|
data += '<table>\n'
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
try:
|
||||||
|
value = ' %s\n' % getstatus(snmpdata['%s.9.1.%s' % (baseoid, k)],
|
||||||
|
snmpdata['%s.8.1.%s' % (baseoid, k)])
|
||||||
|
except KeyError:
|
||||||
|
continue
|
||||||
data += '<tr>\n'
|
data += '<tr>\n'
|
||||||
data += ' <td>%s:</td>\n' % (
|
data += ' <td>%s:</td>\n' % (
|
||||||
snmpdata[baseoid + '.6.1.' + k])
|
snmpdata[baseoid + '.6.1.' + k])
|
||||||
data += ' %s\n' % getstatus(snmpdata['%s.9.1.%s' % (baseoid, k)],
|
data += value
|
||||||
snmpdata['%s.8.1.%s' % (baseoid, k)])
|
|
||||||
data += '</tr>\n'
|
data += '</tr>\n'
|
||||||
data += '</table>\n'
|
data += '</table>\n'
|
||||||
data += '\n'
|
data += '\n'
|
||||||
|
@ -244,7 +248,7 @@ def readtemplate(name, *args, **kwargs):
|
||||||
|
|
||||||
## snmp functions
|
## snmp functions
|
||||||
def snmpget(community, hostname, *args):
|
def snmpget(community, hostname, *args):
|
||||||
cmdline = [ 'snmpget', '-On', '-v', '1', '-c', community, hostname ]
|
cmdline = [ 'snmpget', '-Ona', '-v', '1', '-c', community, hostname ]
|
||||||
for o in args:
|
for o in args:
|
||||||
cmdline.append(o)
|
cmdline.append(o)
|
||||||
ret = {}
|
ret = {}
|
||||||
|
@ -257,13 +261,21 @@ def snmpget(community, hostname, *args):
|
||||||
|
|
||||||
|
|
||||||
def snmpwalk(community, hostname, oid):
|
def snmpwalk(community, hostname, oid):
|
||||||
cmdline = [ 'snmpwalk', '-On', '-v', '1', '-c', community, hostname, oid ]
|
cmdline = [ 'snmpwalk', '-Ona', '-v', '1', '-c', community, hostname, oid ]
|
||||||
ret = {}
|
ret = {}
|
||||||
cmd = Popen(cmdline, stdout=PIPE, stderr=PIPE, close_fds=True)
|
cmd = Popen(cmdline, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||||
|
buff = ''
|
||||||
for line in cmd.stdout.readlines():
|
for line in cmd.stdout.readlines():
|
||||||
line = snmpparse(line)
|
if re.search('[\.0-9]* = .*', line):
|
||||||
if line is not None:
|
buff = snmpparse(buff)
|
||||||
ret[line[0]] = line[1]
|
if buff is not None:
|
||||||
|
ret[buff[0]] = buff[1]
|
||||||
|
buff = line.strip()
|
||||||
|
else:
|
||||||
|
buff += line.strip()
|
||||||
|
buff = snmpparse(buff)
|
||||||
|
if buff is not None:
|
||||||
|
ret[buff[0]] = buff[1]
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue