Моя функция просмотра печатает весь список в терминале, но она показывает только 1 строку в шаблоне (веб, html-страница), как исправить мой код для вывода с одинакового терминала.
def snmpWALK(request):
if request.method=='GET':
host= 'localhost'
oid = '1.3.6.1.2.1.1.9.1.2'
for (errorIndication,
errorStatus,
errorIndex,
varBinds) in nextCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget((host, 161)),
ContextData(),
ObjectType(ObjectIdentity(oid)),
lookupMib=False,
lexicographicMode=False):
if errorIndication:
print(errorIndication, file=sys.stderr)
break
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'), file=sys.stderr)
break
else:
MyList = []
for varBind in varBinds:
thing='%s = %s' % varBind
MyList.append(thing)
print (MyList)
return render(request, 'snmpWALK.html', {'MyList':MyList})
/ snmpWALK.html
{% block content %}
{{MyList}}
{% endblock %}
печать терминала
['1.3.6.1.2.1.1.9.1.2.1 = 1.3.6.1.6.3.11.3.1.1']
[' 1.3.6.1.2.1.1.9.1.2.2 = 1.3.6.1.6.3.15.2.1.1 ']
[' 1.3.6.1.2.1.1.9.1.2.3 = 1.3.6.1.6.3.10.3.1.1 ']
[' 1.3.6.1.2.1.1.9.1.2.4 = 1.3.6.1.6.3.1 ']
['1.3.6.1.2.1.1.9.1.2.5 = 1.3.6.1.6.3.16.2.2.1']
['1.3.6.1.2.1.1.9.1.2.6 = 1.3.6.1.2.1.49 ']
[' 1.3.6.1.2.1.1.9.1.2.7 = 1.3.6.1.2.1.4 ']
[' 1.3.6.1.2.1.1.9.1.2.8 = 1.3.6.1.2.1.50 ']
[' 1.3.6.1.2.1.1.9.1.2.9 = 1.3.6.1.6.3.13.3.1.3 ']
['1.3.6.1.2.1.1.9.1.2.10 = 1.3.6.1.2.1.92 ']
веб-печать
[' 1.3.6.1.2.1.1.9.1.2.10 = 1,3.6.1.2.1.92' ]