0
の配列:パスPySNMP getCmd私は監視システムのためのPySNMPを活用しようとしているが、私は以下のように、作られた接続ごとに照会し、それをオブジェクトの動的リストを渡したいObjectTypes
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData(self.device.getSNMPCommunity(), mpModel=0),
UdpTransportTarget((self.device.getHost(),
self.device.getSNMPPort()),self.device.getSNMPTimeout(),int(1)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0)),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysUpTime', 0)),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysLocation', 0)),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysContact', 0)),
)
)
代わりに、私は次のような何かをできるようにしたい:
for sensor in self.sensors:
if(sensor.sensor_type == 'snmp'):
if(sensor.snmp_oid):
Sensors.append(ObjectType(ObjectIdentity(sensor.snmp_oid)))
else:
Sensors.append(
ObjectType(
ObjectIdentity(
sensor.snmp_mib,
sensor.snmp_object,
sensor.snmp_field
).addAsn1MibSource('file:///usr/share/snmp/mibs')))
そして
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData(device_to_proc.snmp_community, mpModel=0),
UdpTransportTarget((device_to_proc.host, int(device_to_proc.snmp_port)),int(device_to_proc.snmp_timeout),int(1)),
ContextData(),
Sensors
)
)
を呼び出すdifferenがあります私が行方不明になっているpysnmpの機能、またはこれを実現する良い方法がありますか?
うわー、私は明らかに、Pythonのnoobです、そのトリックでした!素晴らしい、ありがとう。 –