def getTables(self, oids=[], results=[], ports=[], iftable=True): """Fetches wanted tables using async command generator and transport Dispatcher. Creates AsynCommandGenerator, adds request handles, and runs runDispatcher, which, for every result, calls cbFun (see above). """ # time of start of snmp grabbing: starttime = datetime.today() oids = oids or self.oids results = results or self.results ports = iftable and (ports or self.ports) or None for o, r in map(None, oids, results): requestHandle = self.asynCommandGenerator.asyncBulkCmd( self.CommunityData, self.UdpTransportTarget, 0, self.bulksize, (o.value,), (self.cbFun, (r, o.value, ports)) ) self.asynCommandGenerator.snmpEngine.transportDispatcher.runDispatcher() # time of end of snmp grabbing: endtime = datetime.today() self.snmptime += commonFuncs.timedelta2secs(endtime - starttime)
# # Collect variables and update perf. RRD: # # total errors number: toterrors = sum([ h.errors for h in cw.hosts ]) # total errors number: totsnmptime = (sum( [ h.snmptime for h in cw.hosts ] ) + 0.0)/cw.maxthreads t2 = datetime.today() # time spent for this one run: tottime = commonFuncs.timedelta2secs(t2 - t1) # try to update perf. rrd: updstr = 'N:%s:%s:%s:%s:%s' % ( tottime, totsnmptime, len(cw.hosts), totalports, toterrors ) rrdtool.update( '%s/%s' % (cw.rrdhostdir, cw.perfbase), updstr ) sys.stdout.write( '%.3f sec total, %.3f sec SNMP (%i devices, %i ports, %i errors).\n' % ( tottime, totsnmptime,