def processInt(self, device, iface, available_interfaces ): """Create an object map for the iface, but only if: * the iface has an 'id' key * after cleanup, the id makes sense * the interface id is in the available_interfaces dictionary * the interface id is not in the zInterfaceMapIgnoreNames zProperty * the interface type is not in the zInterfaceMapIgnoreTypes zProperty """ om = self.objectMap(iface) if not hasattr(om, 'id'): return None om.id = cleanstring(om.id) #take off \x00 at end of string # Left in interfaceName, but added title for # the sake of consistency if not om.id: om.id = 'Index_%s' % iface.get('ifindex', "") semicolon_index= om.id.find( ';' ) if semicolon_index != -1: om.id= om.id[:semicolon_index] om.interfaceName = om.id om.title = om.id om.id = self.prepId(om.interfaceName) if not om.id: return None dontCollectIntNames = getattr(device, 'zInterfaceMapIgnoreNames', None) if (dontCollectIntNames and re.search(dontCollectIntNames, om.interfaceName)): return None if available_interfaces.has_key( om.id ): om.type= available_interfaces[ om.id ][ 'type' ] else: return None dontCollectIntTypes = getattr(device, 'zInterfaceMapIgnoreTypes', None) if dontCollectIntTypes and re.search(dontCollectIntTypes, om.type): return None if hasattr(om, 'macaddress'): om.macaddress = self.asmac(om.macaddress) return om
def processInt(self, device, iface, available_interfaces): """Create an object map for the iface, but only if: * the iface has an 'id' key * after cleanup, the id makes sense * the interface id is in the available_interfaces dictionary * the interface id is not in the zInterfaceMapIgnoreNames zProperty * the interface type is not in the zInterfaceMapIgnoreTypes zProperty """ om = self.objectMap(iface) if not hasattr(om, 'id'): return None om.id = cleanstring(om.id) #take off \x00 at end of string # Left in interfaceName, but added title for # the sake of consistency if not om.id: om.id = 'Index_%s' % iface.get('ifindex', "") semicolon_index = om.id.find(';') if semicolon_index != -1: om.id = om.id[:semicolon_index] om.interfaceName = om.id om.title = om.id om.id = self.prepId(om.interfaceName) if not om.id: return None dontCollectIntNames = getattr(device, 'zInterfaceMapIgnoreNames', None) if (dontCollectIntNames and re.search(dontCollectIntNames, om.interfaceName)): return None if available_interfaces.has_key(om.id): om.type = available_interfaces[om.id]['type'] else: return None dontCollectIntTypes = getattr(device, 'zInterfaceMapIgnoreTypes', None) if dontCollectIntTypes and re.search(dontCollectIntTypes, om.type): return None if hasattr(om, 'macaddress'): om.macaddress = self.asmac(om.macaddress) return om
def processInt(self, device, iface): om = self.objectMap(iface) if not hasattr(om, 'id'): return None om.id = cleanstring(om.id) #take off \x00 at end of string # Left in interfaceName, but added title for # the sake of consistency if not om.id: om.id = 'Index_%s' % iface.get('ifindex', "") om.interfaceName = om.id om.title = om.id om.id = self.prepId(om.interfaceName) if not om.id: return None dontCollectIntNames = getattr(device, 'zInterfaceMapIgnoreNames', None) if (dontCollectIntNames and re.search(dontCollectIntNames, om.interfaceName)): return None om.type = self.ifTypes.get(str(om.type), "Unknown") dontCollectIntTypes = getattr(device, 'zInterfaceMapIgnoreTypes', None) if dontCollectIntTypes and re.search(dontCollectIntTypes, om.type): return None if hasattr(om, 'macaddress'): om.macaddress = self.asmac(om.macaddress) return om
def processInt(self, log, device, iface): """ Convert each interface into an object map, if possible Return None if the zProperties match the name or type of this iface. """ om = self.objectMap(iface) if not hasattr(om, 'id'): log.debug( "Can't find 'id' after self.objectMap(iface)" " -- ignoring this interface" ) return None om.id = cleanstring(om.id) #take off \x00 at end of string # Left in interfaceName, but added title for # the sake of consistency if not om.id: om.id = 'Index_%s' % iface.get('ifindex', "") om.interfaceName = om.id om.title = om.id om.id = self.prepId(om.interfaceName) if not om.id: log.debug( "prepId(%s) doesn't return an id -- skipping" % ( om.interfaceName)) return None dontCollectIntNames = getattr(device, 'zInterfaceMapIgnoreNames', None) if dontCollectIntNames and re.search(dontCollectIntNames, om.interfaceName): log.debug( "Interface %s matched the zInterfaceMapIgnoreNames zprop '%s'" % ( om.interfaceName, getattr(device, 'zInterfaceMapIgnoreNames'))) return None om.type = self.ifTypes.get(str(getattr(om, 'type', 1)), "Unknown") dontCollectIntTypes = getattr(device, 'zInterfaceMapIgnoreTypes', None) if dontCollectIntTypes and re.search(dontCollectIntTypes, om.type): log.debug( "Interface %s type %s matched the zInterfaceMapIgnoreTypes zprop '%s'" % ( om.interfaceName, om.type, getattr(device, 'zInterfaceMapIgnoreTypes'))) return None dontCollectIntDescriptions = getattr(device, 'zInterfaceMapIgnoreDescriptions', None) if dontCollectIntDescriptions and re.search(dontCollectIntDescriptions, om.description): log.debug( "Interface %s description %s matched the zInterfaceMapIgnoreDescriptions zprop '%s'" % ( om.interfaceName, om.description, getattr(device, 'zInterfaceMapIgnoreDescriptions'))) return None # Append _64 to interface type if high-capacity counters are supported if hasattr(om, 'hcCounters'): om.type += "_64" del(om.hcCounters) if hasattr(om, 'macaddress'): if isinstance(om.macaddress, basestring): om.macaddress = self.asmac(om.macaddress) else: log.debug("The MAC address for interface %s is invalid (%s)" \ " -- ignoring", om.id, om.macaddress) # Handle misreported operStatus from Linux tun devices if om.id.startswith('tun') and om.adminStatus == 1: om.operStatus = 1 # Net-SNMP on Linux will always report the speed of bond interfaces as # 10Mbps. This is probably due to the complexity of figuring out the # real speed which would take into account all bonded interfaces and # the bonding method (aggregate/failover). The problem is that 10Mbps # is a really bad default. The following check changes this default to # 1Gbps instead. See the following article that explains how you can # manually set this per-interface in the device's snmpd.conf for better # accuracy. # # http://whocares.de/2007/12/28/speed-up-your-bonds/ if om.id.startswith('bond') and om.speed == 1e7: newspeed = 1000000000 log.debug( "Resetting bond interface %s speed from %s to %s" % ( om.interfaceName, om.speed, newspeed)) om.speed = newspeed # Clear out all IP addresses for interfaces that no longer have any. if not hasattr(om, 'setIpAddresses'): om.setIpAddresses = [] return om
def processInt(self, log, device, iface): """ Convert each interface into an object map, if possible Return None if the zProperties match the name or type of this iface. """ om = self.objectMap(iface) if not hasattr(om, 'id'): log.debug("Can't find 'id' after self.objectMap(iface)" " -- ignoring this interface") return None om.id = cleanstring(om.id) #take off \x00 at end of string # Left in interfaceName, but added title for # the sake of consistency if not om.id: om.id = 'Index_%s' % iface.get('ifindex', "") om.interfaceName = om.id om.title = om.id om.id = self.prepId(om.interfaceName) if not om.id: log.debug("prepId(%s) doesn't return an id -- skipping" % (om.interfaceName)) return None dontCollectIntNames = getattr(device, 'zInterfaceMapIgnoreNames', None) if dontCollectIntNames and re.search(dontCollectIntNames, om.interfaceName): log.debug( "Interface %s matched the zInterfaceMapIgnoreNames zprop '%s'" % (om.interfaceName, getattr(device, 'zInterfaceMapIgnoreNames'))) return None om.type = self.ifTypes.get(str(getattr(om, 'type', 1)), "Unknown") dontCollectIntTypes = getattr(device, 'zInterfaceMapIgnoreTypes', None) if dontCollectIntTypes and re.search(dontCollectIntTypes, om.type): log.debug( "Interface %s type %s matched the zInterfaceMapIgnoreTypes zprop '%s'" % (om.interfaceName, om.type, getattr(device, 'zInterfaceMapIgnoreTypes'))) return None dontCollectIntDescriptions = getattr( device, 'zInterfaceMapIgnoreDescriptions', None) if dontCollectIntDescriptions and re.search(dontCollectIntDescriptions, om.description): log.debug( "Interface %s description %s matched the zInterfaceMapIgnoreDescriptions zprop '%s'" % (om.interfaceName, om.description, getattr(device, 'zInterfaceMapIgnoreDescriptions'))) return None # Append _64 to interface type if high-capacity counters are supported if hasattr(om, 'hcCounters'): om.type += "_64" del (om.hcCounters) if hasattr(om, 'macaddress'): if isinstance(om.macaddress, basestring): om.macaddress = self.asmac(om.macaddress) else: log.debug("The MAC address for interface %s is invalid (%s)" \ " -- ignoring", om.id, om.macaddress) # Handle misreported operStatus from Linux tun devices if om.id.startswith('tun') and om.adminStatus == 1: om.operStatus = 1 # Net-SNMP on Linux will always report the speed of bond interfaces as # 10Mbps. This is probably due to the complexity of figuring out the # real speed which would take into account all bonded interfaces and # the bonding method (aggregate/failover). The problem is that 10Mbps # is a really bad default. The following check changes this default to # 1Gbps instead. See the following article that explains how you can # manually set this per-interface in the device's snmpd.conf for better # accuracy. # # http://whocares.de/2007/12/28/speed-up-your-bonds/ if om.id.startswith('bond') and om.speed == 1e7: newspeed = 1000000000 log.debug("Resetting bond interface %s speed from %s to %s" % (om.interfaceName, om.speed, newspeed)) om.speed = newspeed # Clear out all IP addresses for interfaces that no longer have any. if not hasattr(om, 'setIpAddresses'): om.setIpAddresses = [] return om