slight snmp performance improvement
This commit is contained in:
@@ -958,6 +958,8 @@ class EpsonPrinter:
|
|||||||
hostname: str
|
hostname: str
|
||||||
parm: dict
|
parm: dict
|
||||||
mib_dict: dict = {}
|
mib_dict: dict = {}
|
||||||
|
used_net_val: tuple = ()
|
||||||
|
snmp_conf: object = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -1206,23 +1208,28 @@ class EpsonPrinter:
|
|||||||
)
|
)
|
||||||
return None, False
|
return None, False
|
||||||
return self.mib_dict[mib]
|
return self.mib_dict[mib]
|
||||||
if not self.hostname:
|
if (
|
||||||
return None, False
|
self.hostname, self.port, self.timeout, self.retries
|
||||||
|
) != self.used_net_val:
|
||||||
try:
|
try:
|
||||||
utt = UdpTransportTarget(
|
self.snmp_conf = (
|
||||||
(self.hostname, self.port),
|
SnmpDispatcher(),
|
||||||
|
CommunityData('public', mpModel=0),
|
||||||
|
UdpTransportTarget(
|
||||||
|
(self.hostname, self.port, self.timeout, self.retries)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.critical("snmp_mib invalid address: %s", e)
|
logging.critical("snmp_mib invalid address: %s", e)
|
||||||
|
self.used_net_val = ()
|
||||||
|
return None, False
|
||||||
|
self.used_net_val = (
|
||||||
|
self.hostname, self.port, self.timeout, self.retries
|
||||||
|
)
|
||||||
|
if not self.hostname or not self.snmp_conf:
|
||||||
return None, False
|
return None, False
|
||||||
if self.timeout is not None:
|
|
||||||
utt.timeout = self.timeout
|
|
||||||
if self.retries is not None:
|
|
||||||
utt.retries = self.retries
|
|
||||||
iterator = getCmd(
|
iterator = getCmd(
|
||||||
SnmpDispatcher(),
|
*self.snmp_conf,
|
||||||
CommunityData('public', mpModel=0),
|
|
||||||
utt,
|
|
||||||
(mib, None)
|
(mib, None)
|
||||||
)
|
)
|
||||||
for response in iterator:
|
for response in iterator:
|
||||||
|
|||||||
Reference in New Issue
Block a user