class upsDeviceMap(SnmpPlugin):
    maptype = "upsDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.33.1.1.1.0': '_HWManufacturer',
        '.1.3.6.1.2.1.33.1.1.2.0': 'setHWProductKey',
        '.1.3.6.1.2.1.33.1.1.4.0': 'setOSProductKey',
         })

    def process(self, device, results, log):
        """collect snmp information from this device"""
#        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if not getdata:
            log.warn(' No SNMP response from %s for the %s plugin ' % ( device.id, self.name() ) )
            return

        om = self.objectMap(getdata)
        try:
            manufacturer = om._HWManufacturer
            om.setHWProductKey = MultiArgs(om.setHWProductKey, manufacturer)
            om.setOSProductKey = MultiArgs(om.setOSProductKey, manufacturer)
        except (KeyError, IndexError, AttributeError, TypeError), errorInfo:
            log.warn( ' Attribute error in upsDeviceMap modeler plugin %s', errorInfo)

        return om
Ejemplo n.º 2
0
class HPDeviceMap(SnmpPlugin):
    """Map mib elements from HP Insight Manager mib to get hw and os products.
    """

    maptype = "HPDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.232.2.2.2.1.0': 'setHWSerialNumber',
        '.1.3.6.1.4.1.232.2.2.4.2.0': 'setHWProductKey',
        '.1.3.6.1.4.1.232.11.2.2.1.0': 'setOSProductKey',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if getdata['setHWProductKey'] is None: return None
        om = self.objectMap(getdata)
        if om.setHWSerialNumber:
            om.setHWSerialNumber = om.setHWSerialNumber.strip()
        om.setHWProductKey = MultiArgs(om.setHWProductKey, "HP")

        if om.setOSProductKey and om.setOSProductKey.find("NetWare") > -1:
            delattr(om, 'setOSProductKey')
        else:
            if re.search(r'Microsoft', om.setOSProductKey, re.I):
                om.setOSProductKey = MultiArgs(om.setOSProductKey, "Microsoft")
            elif re.search(r'Red\s*Hat', om.setOSProductKey, re.I):
                om.setOSProductKey = MultiArgs(om.setOSProductKey, "RedHat")
        return om
Ejemplo n.º 3
0
class FSP3000R7ModuleMib(SnmpPlugin):

    modname = "ZenPacks.Merit.AdvaFSP3000R7.FSP3000R7Module"
    relname = "FSP3000R7Mod"

    # FspR7-MIB mib neSystemId is .1.3.6.1.4.1.2544.1.11.2.2.1.1.0.  Not used;
    # Have to get something with SNMP or modeler won't process
    snmpGetMap = GetMap({'.1.3.6.1.4.1.2544.1.11.2.2.1.1.0': 'setHWTag'})

    def process(self, device, results, log):
        """process snmp information for containers for this device"""
        log.info('processing %s for device %s', self.name(), device.id)

        # tabledata is not used (get tables from cache pickle file created
        # in FSP3000R7Device modeler)
        getdata = {}
        getdata['setHWTag'] = False
        getdata, tabledata = results
        if not getdata['setHWTag']:
            log.info("Couldn't get system name from Adva shelf.")

        inventoryTable = entityTable = opticalIfDiagTable = False
        containsModules = {}
        gotCache, inventoryTable, entityTable, opticalIfDiagTable, \
            containsModules = getCache(device.id, self.name(), log)
        if not gotCache:
            log.debug('Could not get cache for %s' % self.name())
            return

        # relationship mapping
        rm = self.relMap()

        # pick up MOD-* containers from entityTable
        for entityIndex in entityTable:
            # Power Supply, NCU and Fan models are already top level containers
            if not (entityIndex in inventoryTable):
                continue
            inventoryUnitName = inventoryTable[entityIndex][
                'inventoryUnitName']
            if inventoryUnitName in FanorNCUorPSModels:
                continue
            if entityTable[entityIndex]['entityIndexAid'].startswith('MOD-'):
                om = self.objectMap()
                om.EntityIndex = int(entityIndex)
                om.inventoryUnitName = inventoryUnitName
                om.entityIndexAid = entityTable[entityIndex]['entityIndexAid']
                om.entityAssignmentState = \
                    entityTable[entityIndex]['entityAssignmentState']
                om.interfaceConfigId = ''
                om.sortKey = '000000000'
                om.entityAssignmentState = 'Not set by modeler'
                om.containedIn = 'Chassis'
                om.id = self.prepId(om.entityIndexAid)
                om.title = om.entityIndexAid
                om.snmpindex = int(entityIndex)
                log.info('Found module at: %s inventoryUnitName: %s',
                         om.entityIndexAid, om.inventoryUnitName)
                rm.append(om)

        return rm
class DellUpsDeviceMap(SnmpPlugin):
    maptype = "DellUpsDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.674.10902.2.120.1.1.0': 'setHWProductKey',
        '.1.3.6.1.4.1.674.10902.2.100.5.0': 'setOSProductKey',
        '.1.3.6.1.4.1.674.10902.2.120.1.2.0': 'setHWSerialNumber',
         })

    def condition(self, device, log):
        """only for boxes with proper object id
        """
        return device.snmpOid.startswith(".1.3.6.1.4.1.674.10902.2")


    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        manufacturer = "Dell"
        om.setHWProductKey = MultiArgs(om.setHWProductKey, manufacturer)
#        log.debug("HWProductKey=%s Manufacturer = %s" % (om.setHWProductKey, manufacturer))
        om.setOSProductKey = MultiArgs(om.setOSProductKey, manufacturer)
#        log.debug("OSProductKey=%s Manufacturer = %s" % (om.setOSProductKey, manufacturer))

        return om
class TrangoInterfaceMap(SnmpPlugin):
    maptype = "TrangoInterfaceMap"
    compname = "os"
    relname = "interfaces"
    modname = "Products.ZenModel.IpInterface"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.5454.1.10.1.2.0': 'apsysDeviceId',
        '.1.3.6.1.4.1.5454.1.10.1.8.0': 'apsysIPAddr',
        '.1.3.6.1.4.1.5454.1.10.1.9.0': 'apsysSubnet',
        })

    def process(self, device, results, log):
        log.info("processing %s for device %s", self.name(), device.id)
        getdata, tabledata = results
        if getdata['apsysIPAddr'] is None: return None
        maskBits = self.maskToBits(getdata['apsysSubnet'])
        rm = self.relMap()
        om = self.objectMap()
        om.id = "ethernet"
        om.ifindex = "1"
        om.title = "ethernet"
        om.type = "trangoApEthernet"
        om.adminStatus = 1
        om.operStatus = 1
        om.speed = 100000000
        om.mtu = 1500
        ip = getdata['apsysIPAddr'] + "/" + str(maskBits)
        om.setIpAddresses = [ip,]
        om.macaddress = self.asmac(getdata['apsysDeviceId'])
        rm.append(om)
        
        return rm
Ejemplo n.º 6
0
class DellDeviceMap(SnmpPlugin):
    """Map mib elements from Dell Open Manage mib to get hw and os products.
    """

    maptype = "DellDeviceMap"

    snmpGetMap = GetMap({
        #'.1.3.6.1.4.1.674.10892.1.300.10.1.8' : 'manufacturer',
        '.1.3.6.1.4.1.674.10892.1.300.10.1.9.1':
        'setHWProductKey',
        '.1.3.6.1.4.1.674.10892.1.300.10.1.11.1':
        'setHWSerialNumber',
        '.1.3.6.1.4.1.674.10892.1.400.10.1.6.1':
        'setOSProductKey',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if getdata['setHWProductKey'] is None: return None
        om = self.objectMap(getdata)
        om.setHWProductKey = MultiArgs(om.setHWProductKey, "Dell")
        if re.search(r'Microsoft', om.setOSProductKey, re.I):
            om.setOSProductKey = MultiArgs(om.setOSProductKey, "Microsoft")
        elif re.search(r'Red\s*Hat', om.setOSProductKey, re.I):
            om.setOSProductKey = MultiArgs(om.setOSProductKey, "RedHat")
        return om
Ejemplo n.º 7
0
class BridgeDeviceMib(SnmpPlugin):

    #    relname = "BridgeInt"
    modname = "ZenPacks.skills1st.bridge.BridgeDevice"
    #    compname = "BridgeDevice"

    # snmpGetMap gets scalar SNMP MIBs (single values)
    #  Use .1.3.6.1.2.1.17.1.1 ( dot1dBaseBridgeAddress) to populate the Serial No
    #  and 1.3.6.1.2.1.17.1.2 ( dot1dBaseNumPorts ) to populate the Hardware tag
    #  setHWSerialNumber and setHWTag are standard methods on any Device

    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.17.1.1.0': 'setHWSerialNumber',
        '.1.3.6.1.2.1.17.1.2.0': 'setHWTag',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        #Collect Physical Port Forwarding Table
        getdata, tabledata = results

        # Uncomment next 2 lines for debugging when modeling
        log.warn("Get Data= %s", getdata)
        log.warn("Table Data= %s", tabledata)
        om = self.objectMap(getdata)
        om.setHWSerialNumber = self.asmac(om.setHWSerialNumber)
        om.setHWTag = "Number of ports = " + str(om.setHWTag)
        return om
Ejemplo n.º 8
0
class AIXDeviceMap(SnmpPlugin):
    """Map AIX MIB to get hw and os products.
    """

    maptype = "AIXDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.2.6.191.1.3.6': 'setHWProductKey',
        '.1.3.6.1.4.1.2.6.191.1.3.7': 'setHWSerialNumber',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""

        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results

        if getdata['setHWProductKey'] is None:
            return None

        om = self.objectMap(getdata)

        om.setHWProductKey = MultiArgs(om.setHWProductKey, "IBM")
        #
        # There's existing logic in the NewDeviceMap.py plugin to find
        # the OS version etc, so we won't set the setOsProductKey field.
        #
        return om
class OlsonPowerMap(SnmpPlugin):
    """Map mib elements from Olson device mib to get hw and os data.
    """

    maptype = "OlsonPowerMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.17933.1.1.1': 'setHWProductKey',
        '.1.3.6.1.4.1.17933.1.1.2': 'setOSProductKey',
        '.1.3.6.1.4.1.17933.1.1.3': 'setHWSerialNumber',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if not getdata:
            log.warn("Unable to retrieve getdata from %s", device.id)
            log.warn("Does snmpwalk -v1 -c community %s 1.3.6.1.2.1.1 work?",
                     device.id)
            return
        om = self.objectMap(getdata)
        om.setHWProductKey = MultiArgs(om.setHWProductKey, 'Olson')
        om.setOSProductKey = MultiArgs(om.setOSProductKey, 'Olson')

        return om
Ejemplo n.º 10
0
class HPLogicalDiskMap(SnmpPlugin):
    """Map HP/Compaq insight manager Logical Disk tables to model."""

    maptype = "HPLogicalDiskMap"
    modname = "ZenPacks.community.HPMon.HPLogicalDisk"
    relname = "logicaldisks"
    compname = "hw"

    oms = {}

    diskTypes = {1: 'other',
                }

    snmpGetMap = GetMap({'.1.3.6.1.2.1.1.2.0' : 'snmpOid'})

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        rm = self.relMap()
        if not device.id in self.oms:
            return rm
        for om in self.oms[device.id]:
            rm.append(om)
        del self.oms[device.id]
        return rm
Ejemplo n.º 11
0
class PacketFilter(SnmpPlugin):
    relname = 'packetFilter'
    modname = 'ZenPacks.crosse.OpenBSD.PacketFilter'

    snmpGetMap = (
            GetMap({
                '.1.3.6.1.4.1.30155.1.1.1.0': 'pfRunning',
                '.1.3.6.1.4.1.30155.1.1.2.0': 'pfRuntime',
                '.1.3.6.1.4.1.30155.1.1.3.0': 'pfDebug',
                '.1.3.6.1.4.1.30155.1.1.4.0': 'pfHostId',
                '.1.3.6.1.4.1.30155.1.2.1.0': 'pfCntMatch',
                '.1.3.6.1.4.1.30155.1.3.1.0': 'pfStateCount',
                '.1.3.6.1.4.1.30155.1.4.1.0': 'pfLogIfName',
                })
            )

    def process(self, device, results, log):
        log.info('Modeler %s processing data for device %s',
                self.name(), device.id)

        values = {}
        for key in results[0].keys():
            values[key] = results[0].get(key)

        values['id'] = self.prepId('pf')
        values['title'] = 'Packet Filter'
        values['pfRunning'] = True if (values['pfRunning'] == 1) else False

        rm = self.relMap()
        rm.append(self.objectMap(values))

        return rm
Ejemplo n.º 12
0
class TrangoRouteMap(SnmpPlugin):
    maptype = "TrangoInterfaceMap"
    compname = "os"
    relname = "routes"
    modname = "Products.ZenModel.IpRouteEntry"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.5454.1.20.1.9.0': 'apsysSubnet',
        '.1.3.6.1.4.1.5454.1.20.1.10.0': 'apsysDefaultGateway',
    })

    def process(self, device, results, log):
        log.info("processing %s for device %s", self.name(), device.id)
        getdata, tabledata = results
        if getdata['apsysDefaultGateway'] is None: return None
        dg = getdata['apsysDefaultGateway']
        maskBits = self.maskToBits(getdata['apsysSubnet'])
        rm = self.relMap()
        om = self.objectMap()
        om.id = dg + "_" + str(maskBits)
        om.setInterfaceIndex = "1"
        om.setNextHopIp = dg
        om.routemask = maskBits
        om.routetype = 'indirect'
        om.routeproto = 'local'
        om.routemask = self.maskToBits(getdata['apsysSubnet'])
        om.setTarget = dg + "/" + str(maskBits)
        rm.append(om)

        return rm
class BridgeDeviceMib(SnmpPlugin):

    modname = 'ZenPacks.community.bridge.BridgeDevice'

    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.17.1.1.0': 'setHWSerialNumber',
        '.1.3.6.1.2.1.17.1.2.0': 'setHWTag',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing {} for device {}'.format(self.name(), device.id))
        # Collect physical port forwarding table
        getdata, tabledata = results

        log.warn("Get Data= %s", getdata)
        log.warn("Table Data= %s", tabledata)

        try:
            om = self.objectMap(getdata)
            om.setHWSerialNumber = self.asmac(om.setHWSerialNumber)
            om.setHWTag = 'Number of ports = {}'.format(om.setHWTag)
            return om
        except:
            log.warn(
                ' Error in getting data for BridgeDeviceMib modeler plugin')
Ejemplo n.º 14
0
class DeviceMap(SnmpPlugin):

    maptype = "DeviceMap"

    columns = {
        '.1.3.6.1.2.1.1.1.0': 'snmpDescr',
        '.1.3.6.1.2.1.1.2.0': 'snmpOid',
        #'.1.3.6.1.2.1.1.3.0' : 'snmpUpTime',
        '.1.3.6.1.2.1.1.4.0': 'snmpContact',
        '.1.3.6.1.2.1.1.5.0': 'snmpSysName',
        '.1.3.6.1.2.1.1.6.0': 'snmpLocation',
    }
    snmpGetMap = GetMap(columns)

    ciscoVersion = re.compile(r'Version (?P<ver>.+), ')

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if not self.checkColumns(getdata, self.columns, log):
            return
        om = self.objectMap(getdata)

        # allow for custom parse of DeviceMap data
        scDeviceMapParse = getattr(device, 'scDeviceMapParse', None)
        if scDeviceMapParse:
            om = scDeviceMapParse(device, om)

        return om
Ejemplo n.º 15
0
class SynologyDeviceMap(SnmpPlugin):
    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.6574.1.5.1.0': 'modelName',
        '.1.3.6.1.4.1.6574.1.5.2.0': 'serialNumber',
        '.1.3.6.1.4.1.6574.1.5.3.0': 'version',
    })

    def process(self, device, results, log):
        log.info("Modeler %s processing data for device %s", self.name(),
                 device.id)

        manufacturer = 'Synology'
        getdata, tabledata = results
        model = getdata.get('modelName', 'Unknown')
        serial_number = getdata.get('serialNumber', 'Unknown')
        version = getdata.get('version', 'Unknown')

        hw_om = ObjectMap(compname='hw',
                          data={
                              'setProductKey': MultiArgs(model, manufacturer),
                              'serialNumber': serial_number,
                          })

        os_om = ObjectMap(compname='os',
                          data={
                              'setProductKey':
                              MultiArgs(version, manufacturer),
                          })

        return [hw_om, os_om]
Ejemplo n.º 16
0
class JuniperDeviceMap(SnmpPlugin):
    maptype = "JuniperDeviceMap"

# Get OSProductKey from Host Resources SoftwareInstalled table - .2 index
# jnxBoxRevision ( .1.3.6.1.4.1.2636.3.1.4.0 ) is usually null 
    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.2636.3.1.2.0': 'setHWProductKey',
        '.1.3.6.1.4.1.2636.3.1.4.0': '_modelNumber',
        '.1.3.6.1.4.1.2636.3.1.3.0': 'setHWSerialNumber',
        '.1.3.6.1.2.1.25.6.3.1.2.2': 'setOSProductKey',
        '.1.3.6.1.4.1.2636.3.1.16.0': 'memoryUsedPercent',
        '.1.3.6.1.4.1.2636.3.58.1.2.1.1.0': 'psuAvailable',

         })

    def condition(self, device, log):
        """only for boxes with proper object id
        """
        return device.snmpOid.startswith(".1.3.6.1.4.1.2636")


    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        manufacturer = "Juniper Networks, Inc."
        om.setHWProductKey = om.setHWProductKey + ' ' + om._modelNumber
        om.setHWProductKey = MultiArgs(om.setHWProductKey, manufacturer)
#        log.debug("HWProductKey=%s Manufacturer = %s" % (om.setHWProductKey, manufacturer))
        om.setOSProductKey = MultiArgs(om.setOSProductKey, manufacturer)
#        log.debug("OSProductKey=%s Manufacturer = %s" % (om.setOSProductKey, manufacturer))
#        log.debug("Memory used %s psu available = %s" % (om.memoryUsedPercent, om.psuAvailable))

        return om
Ejemplo n.º 17
0
class AristaDevice(SnmpPlugin):
    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.47.1.1.1.1.11.1': 'serialnumber',
        '.1.3.6.1.2.1.25.2.2.0': 'hrMemorySize',
        '.1.3.6.1.2.1.47.1.1.1.1.10.1': 'entPhysicalSoftwareRev',
        '.1.0.8802.1.1.2.1.3.2.0': 'lldpLocChassisId',
        '.1.3.6.1.2.1.47.1.1.1.1.13.1': 'entPhysicalModelName'
    })

    snmpGetTableMaps = (
        GetTableMap(
            'hostresourcestorage', '.1.3.6.1.2.1.25.2.3.1', {
                '.1': 'hrStorageIndex',
                '.2': 'hrStorageType',
                '.3': 'hrStorageDescr',
                '.4': 'hrStorageAllocationUnits',
                '.5': 'hrStorageSize',
                '.6': 'hrStorageUsed',
            }),
        GetTableMap(
            'hostresourceproc', '.1.3.6.1.2.1.25.3.2.1', {
                '.1': 'hrDeviceIndex',
                '.2': 'hrDeviceType',
                '.3': 'hrDeviceDescr',
                '.5': 'hrDeviceStatus',
                '.5': 'hrStorageSize',
                '.6': 'hrStorageUsed',
            }),
        GetTableMap('hostresourceprocload', '.1.3.6.1.2.1.25.3.3.1', {
            '.2': 'hrProcessorLoad',
        }),
    )

    def process(self, device, results, log):

        log.info('Modeler {} processing data for device {}'.format(
            self.name(), device.id))
        model = results[0].get('entPhysicalModelName', {})
        serial = results[0].get('serialnumber', {})
        memory = results[0].get('hrMemorySize', {})
        version = results[0].get('entPhysicalSoftwareRev', {})
        system_mac = results[0].get('lldpLocChassisId', {})

        try:
            formatted_system_mac = ':'.join(
                s.encode('hex')
                for s in binascii.hexlify(system_mac).decode('hex'))
        except TypeError:
            formatted_system_mac = None

        om = self.objectMap({
            'arista_switch_model': model,
            'arista_switch_serial': serial,
            'arista_switch_version': version,
            'arista_switch_memory': memory,
            'arista_switch_mac': formatted_system_mac
        })

        return om
Ejemplo n.º 18
0
class BMCPowerConsumptionMap(SnmpPlugin):
    '''
    BMCPowerConsumptionMap
    '''

    relname = 'bmcpowerConsumptions'
    modname = 'ZenPacks.community.HuaweiServer.BMCPowerConsumption'
    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.2011.2.235.1.1.1.13.0':
        'presentSystemPower',
        '.1.3.6.1.4.1.2011.2.235.1.1.20.1.0':
        'peakPower',
        '.1.3.6.1.4.1.2011.2.235.1.1.20.3.0':
        'averagePower',
        '.1.3.6.1.4.1.2011.2.235.1.1.20.4.0':
        'powerConsumption',
        '.1.3.6.1.4.1.2011.2.235.1.1.23.1.0':
        'powerCappingEnable',
        '.1.3.6.1.4.1.2011.2.235.1.1.23.2.0':
        'powerCappingValue',
        '.1.3.6.1.4.1.2011.2.235.1.1.23.3.0':
        'powerCappingFailureAction',
    })

    def process(self, device, results, log):
        '''
        process oid
        '''

        log = log
        device = device
        getdata = results[0]

        psp = str(getdata.get('presentSystemPower'))
        relmap = self.relMap()
        relmap.append(
            self.objectMap({
                'id':
                self.prepId('PC_1'),
                'title':
                '1',
                'presentSystemPower':
                psp + '(Watts)',
                'peakPower':
                str(getdata.get('peakPower')) + '(Watts)',
                'averagePower':
                str(getdata.get('averagePower')) + '(Watts)',
                'powerConsumption':
                str(getdata.get('powerConsumption')) + '(kWh)',
                'powerCappingEnable':
                BMCPCESTATUS.get(getdata.get('powerCappingEnable'), 'unknown'),
                'powerCappingValue':
                getdata.get('powerCappingValue'),
                'powerCappingFailureAction':
                BMCPCFA.get(getdata.get('powerCappingFailureAction'),
                            'unknown'),
            }))
        return relmap
Ejemplo n.º 19
0
class FalconInputs(SnmpPlugin):

    INPUT_PREFIX = '.1.3.6.1.4.1.3184.1.1.1.3'

    relname = "inputs"
    modname = "ZenPacks.zenoss.FalconMonitor.Input"

    snmpGetTableMaps = (WalkTree("inputs", INPUT_PREFIX),)
    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.1.2.0':      'sysObjectID',

        # On some falcons, input 34 doesn't return
        # proper values during a walk, but does during
        # a get, so we'll get them here
        INPUT_PREFIX + '.34.1.0':  '34.1',
        INPUT_PREFIX + '.34.3.0':  '34.3',
        })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results

        if not getdata.get('sysObjectID', '').startswith('.1.3.6.1.4.1.3184.1.1'):
            return None

        # Create a data structure
        data = {}
        for key in sorted(tabledata["inputs"][FalconInputs.INPUT_PREFIX]):
            pattern  = '^' + FalconInputs.INPUT_PREFIX.replace('.', '\.')
            pattern += '.([0-9]+)\.([0-9]+)\.0' 
            input, attribute = map(int, re.findall(pattern, key)[0])
            data[input] = data.get(input, {})
            data[input][attribute] = tabledata["inputs"][FalconInputs.INPUT_PREFIX][key]
        for key in sorted(getdata):
            match = re.findall("^([0-9]+)\.([0-9]+)$", key)
            if not match:
                continue
            input, attribute = map(int, match[0])
            data[input] = data.get(input, {})
            data[input][attribute] = getdata[key]

        # Build the model
        id = 0
        rm = self.relMap()
        for i in sorted(data.keys()):
            id            += 1
            om             = self.objectMap()
            om.id          = self.prepId("%d" % id)
            om.type        = data[i].get(1, 0)
            om.snmpindex   = "%d.2.0" % i
            om.description = data[i].has_key(13) and data[i].get(5, "") or data[i].get(3, "")

            # (ABOVE) If we have a 13 column input, the description is in column 5
            # Otherwise we will assume this is a 5 column input (description in column 3)

            rm.append(om)
        return rm
Ejemplo n.º 20
0
class BigipDeviceMap(SnmpPlugin):
    """
    Collects the basic hardware information about the Bigip
    """

    modname = "ZenPacks.community.f5.BigipLtm"

    snmpGetMap = GetMap({
        #'.1.3.6.1.4.1.674.10892.1.300.10.1.8' : 'manufacturer',
        '.1.3.6.1.4.1.3375.2.1.3.3.1.0': 'sysGeneralHwName',
        '.1.3.6.1.4.1.3375.2.1.3.3.2.0': 'setHWProductKey',
        '.1.3.6.1.4.1.3375.2.1.3.3.3.0': 'setHWSerialNumber',
        #'.1.3.6.1.4.1.674.10892.1.400.10.1.6.1': 'setOSProductKey',
        # Collect some info to build the setOSProductKey string later
        '.1.3.6.1.4.1.3375.2.1.4.1.0': 'sysProductName',
        '.1.3.6.1.4.1.3375.2.1.4.2.0': 'sysProductVersion',
        '.1.3.6.1.4.1.3375.2.1.4.3.0': 'sysProductBuild',
        '.1.3.6.1.4.1.3375.2.1.4.4.0': 'sysProductEdition',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        manufacturer_name = "F5 Labs, Inc."
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        #if getdata['setHWProductKey'] is None: return None
        om = self.objectMap(getdata)
        # Build a product build and version string to populate the OSModel field
        # Also set the manufacturer_name
        os_model = " ".join([
            om.sysProductName, om.sysProductVersion, om.sysProductBuild,
            om.sysProductEdition
        ])
        om.setOSProductKey = MultiArgs(os_model, manufacturer_name)

        #To make things more fun, there is an issue on Viprions.
        #http://support.f5.com/kb/en-us/solutions/public/10000/600/sol10635.html
        #http://support.f5.com/kb/en-us/solutions/public/11000/400/sol11441.html
        # This results in om.sysProductName coming back as unknown....
        # Lets try to work around that
        if om.setHWProductKey == "unknown":
            viprion_marketing_names = ['A100', 'A107']
            if om.sysGeneralHwName in viprion_marketing_names:
                hw_model = "VIPRION"
            pass
        else:
            # By default the HWProductKey is very generic, ie '3400'. Lets prepend an identifier
            # so it aligns with the table in sol10635
            hw_model = " ".join([om.sysProductName, om.setHWProductKey])

        # Now set it. I'm not entirely up to speed on this method,
        # But in testing the multiargs stuff will populate two fields in the GUI
        om.setHWProductKey = MultiArgs(hw_model, manufacturer_name)
        return om
Ejemplo n.º 21
0
class HPDeviceMap(SnmpPlugin):
    """Map mib elements from HP/Compaq Insight Manager mib to get hw and os
    products.
    """

    maptype = "HPDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.232.2.2.2.1.0': 'setHWSerialNumber',
        '.1.3.6.1.4.1.232.2.2.2.6.0': 'setHWTag',
        '.1.3.6.1.4.1.232.2.2.4.2.0': 'setHWProductKey',
        '.1.3.6.1.4.1.232.11.2.2.1.0': 'setOSProductKey',
        '.1.3.6.1.4.1.232.11.2.2.2.0': '_OSVer',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if getdata['setHWProductKey'] is None: return None
        om = self.objectMap(getdata)
        if not getattr(om, 'setOSProductKey', None):
            om.setOSProductKey = "Unknown"
        if om.setOSProductKey and om.setOSProductKey.find("NetWare") > -1:
            om.setOSProductKey = "Novell %s %s" % (om.setOSProductKey,
                                                   om._OSVer)
            manuf = "Novell"
        elif re.search(r'Microsoft', om.setOSProductKey, re.I):
            manuf = "Microsoft"
        elif re.search(r'Red\s*Hat', om.setOSProductKey, re.I):
            manuf = "Red Hat"
        elif re.search(r'VMware', om.setOSProductKey, re.I):
            if '-' in om.setOSProductKey:
                om.setOSProductKey = om.setOSProductKey.split('-',
                                                              1)[1].strip()
            om.setOSProductKey = "%s %s" % (om.setOSProductKey, om._OSVer)
            manuf = "VMware"
        elif re.search(r'SuSE', om.setOSProductKey, re.I):
            if '-' in om.setOSProductKey:
                om.setOSProductKey = om.setOSProductKey.split('-',
                                                              1)[1].strip()
            om.setOSProductKey = "Novell %s %s" % (om.setOSProductKey,
                                                   om._OSVer)
            manuf = "Novell"
        else:
            manuf = "Unknown"
        try:
            from Products.DataCollector.plugins.DataMaps import MultiArgs
            om.setHWProductKey = MultiArgs(om.setHWProductKey, "HP")
            om.setOSProductKey = MultiArgs(om.setOSProductKey, manuf)
        except:
            pass
        return om
Ejemplo n.º 22
0
class SLCDeviceMap(SnmpPlugin):
    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.244.1.1.6.1.0': 'setHWProductKey',
        '.1.3.6.1.4.1.244.1.1.6.2.0': 'setHWSerialNumber',
        '.1.3.6.1.4.1.244.1.1.6.3.0': 'setOSProductKey',
    })

    def process(self, device, results, log):
        getdata, tabledata = results
        om = self.objectMap(getdata)
        om.setHWProductKey = MultiArgs(om.setHWProductKey, "Lantronix")
        om.setOSProductKey = MultiArgs(om.setOSProductKey, "Lantronix")
        return om
Ejemplo n.º 23
0
class BaytechPduPSMap(SnmpPlugin):
    """Map Baytech PDU power supply data to model. These are scalars not table."""
    maptype = "BaytechPduPSMap"
    modname = "ZenPacks.ZenSystems.BaytechPdu.BaytechPduPS"
    relname = "BaytechPduP"
    compname = ""

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.4779.1.3.5.3.1.3.1.1': 'supply1Status',
        '.1.3.6.1.4.1.4779.1.3.5.3.1.3.1.2': 'supply2Status',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if not getdata:
            log.warn(' No SNMP response from %s for the %s plugin ' %
                     (device.id, self.name()))
            return
        rm = self.relMap()
        om = self.objectMap(getdata)
        if not om.supply1Status and not om.supply2Status:
            log.warn(
                ' No SNMP values for BaytechPdu power supplies - component will not be created '
            )
            return

        try:
            if int(om.supply1Status == 1):
                om.supply1Status = 'OK'
            elif int(om.supply1Status == 2):
                om.supply1Status = 'Failed'
            else:
                om.supply1Status = 'Unknown'

            if int(om.supply2Status == 1):
                om.supply2Status = 'OK'
            elif int(om.supply2Status == 2):
                om.supply2Status = 'Failed'
            else:
                om.supply2Status = 'Unknown'
            om.id = "Power_Supplies"
            om.id = self.prepId(om.id)
            # Fix om.snmpindex to 0 as this is a scalar
            om.snmpindex = '0'
        except (KeyError, IndexError, AttributeError, TypeError), errorInfo:
            log.warn(' Error in BaytechPduPSMap modeler plugin %s', errorInfo)

        rm.append(om)
        return rm
Ejemplo n.º 24
0
class ApcAtsDeviceMap(SnmpPlugin):
    maptype = "ApcAtsDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.318.1.1.8.1.5.0':
        '_modelNumber',
        '.1.3.6.1.4.1.318.1.1.8.1.1.0':
        '_hardwareRev',
        '.1.3.6.1.4.1.318.1.1.8.1.2.0':
        'setOSProductKey',
        '.1.3.6.1.4.1.318.1.1.8.1.6.0':
        'setHWSerialNumber',
        '.1.3.6.1.4.1.318.1.1.8.5.1.2.0':
        'statusSelectedSource',
        '.1.3.6.1.4.1.318.1.1.8.5.1.3.0':
        'statusRedundancyState',
        '.1.3.6.1.4.1.318.1.1.8.5.1.12.0':
        'statusSourceAStatus',
        '.1.3.6.1.4.1.318.1.1.8.5.1.13.0':
        'statusSourceBStatus',
        '.1.3.6.1.4.1.318.1.1.8.5.1.14.0':
        'statusPhaseSyncStatus',
    })

    #    def condition(self, device, log):
    #        """only for boxes with proper object id
    #        """
    #        return device.snmpOid.startswith(".1.3.6.1.4.1.318.1.3.11")

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if not getdata:
            log.warn(' No SNMP response from %s for the %s plugin ' %
                     (device.id, self.name()))
            return
        om = self.objectMap(getdata)
        try:
            manufacturer = "American Power Conversion Corp."
            om.setHWProductKey = om._modelNumber + ' ' + om._hardwareRev
            om.setHWProductKey = MultiArgs(om.setHWProductKey, manufacturer)
            log.debug("HWProductKey=%s Manufacturer = %s" %
                      (om.setHWProductKey, manufacturer))
            om.setOSProductKey = MultiArgs(om.setOSProductKey, manufacturer)
            log.debug("OSProductKey=%s Manufacturer = %s" %
                      (om.setOSProductKey, manufacturer))
        except (KeyError, IndexError, AttributeError, TypeError), errorInfo:
            log.warn(' Error in ApcAtsDeviceMap modeler plugin %s', errorInfo)

        return om
Ejemplo n.º 25
0
class SnmpV3EngineIdMap(SnmpPlugin):

    snmpGetMap = GetMap({'.1.3.6.1.6.3.10.2.1.1.0': 'setSnmpV3EngineId'})

    def condition(self, device, log):
        """ Only for snmp v3 and if we do not have a value for zSnmpEngineId """
        return ('3' in device.zSnmpVer and len(device.zSnmpEngineId) == 0)

    def process(self, device, results, log):
        """ collect snmp information from this device """
        log.info('Processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        om.setSnmpV3EngineId = binascii.hexlify(om.setSnmpV3EngineId)
        return om
Ejemplo n.º 26
0
class ApcUpsDeviceMap(SnmpPlugin):
    maptype = "ApcUpsDeviceMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.318.1.1.1.1.1.1.0': 'setHWProductKey',
        '.1.3.6.1.4.1.318.1.1.1.1.2.1.0': 'setOSProductKey',
        '.1.3.6.1.4.1.318.1.1.1.1.2.3.0': 'setHWSerialNumber',
        '.1.3.6.1.4.1.318.1.1.1.2.2.5.0': 'numBatteryPacks',
        '.1.3.6.1.4.1.318.1.1.1.2.2.6.0': 'numBadBatteryPacks',
        '.1.3.6.1.4.1.318.1.1.1.4.1.1.0': 'basicOutputStatus',
    })

    def condition(self, device, log):
        """only for boxes with proper object id
        """
        return device.snmpOid.startswith(".1.3.6.1.4.1.318.1.3.2")

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        manufacturer = "American Power Conversion Corp."
        om.setHWProductKey = MultiArgs(om.setHWProductKey, manufacturer)
        #        log.debug("HWProductKey=%s Manufacturer = %s" % (om.setHWProductKey, manufacturer))
        om.setOSProductKey = MultiArgs(om.setOSProductKey, manufacturer)
        #        log.debug("OSProductKey=%s Manufacturer = %s" % (om.setOSProductKey, manufacturer))
        if (om.basicOutputStatus < 1 or om.basicOutputStatus > 12):
            om.basicOutputStatus = 1
        index = om.basicOutputStatus
        om.basicOutputStatusText = self.basicOutputStatusMap[index]

        return om

    basicOutputStatusMap = {
        1: 'Unknown',
        2: 'onLine',
        3: 'onBattery',
        4: 'onSmartBoost',
        5: 'timedSleeping',
        6: 'softwareBypass',
        7: 'off',
        8: 'rebooting',
        9: 'switchedBypass',
        10: 'hardwareFailureBypass',
        11: 'sleepingUntilPowerReturn',
        12: 'onSmartTrim',
    }
Ejemplo n.º 27
0
class BMCDeviceMap(SnmpPlugin):
    '''
    BMCDeviceMap
    '''

    snmpGetTableMap = (GetTableMap('fruBoardTable',
                                   '1.3.6.1.4.1.2011.2.235.1.1.19.50.1', {
                                       '.1': 'fruId',
                                       '.4': 'fruBoardSerialNumber'
                                   }))
    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.2011.2.235.1.1.19.50.1.4.1':
        'fruBoardSerialNumber',
        '.1.3.6.1.4.1.2011.2.235.1.1.1.6.0':
        'deviceName',
        '.1.3.6.1.4.1.2011.2.235.1.1.1.9.0':
        'hostName',
        '.1.3.6.1.4.1.2011.2.235.1.1.1.2.0':
        'systemBootsequence',
        '.1.3.6.1.4.1.2011.2.235.1.1.1.12.0':
        'fruPowerControl',
        '.1.3.6.1.4.1.2011.2.235.1.1.10.50.1.4.9.77.97.105.110.98.111.97.114.100':
        'boardId',
    })

    def process(self, device, results, log):
        '''
        process oid
        '''

        log = log
        device = device
        getdata = results[0]

        return self.objectMap({
            'bmcDeviceName':
            getdata.get('deviceName'),
            'bmcHostName':
            getdata.get('hostName'),
            'bmcBoardId':
            getdata.get('boardId'),
            'bmcBootSequence':
            BMCBOOTSTR.get(getdata.get('systemBootsequence'), 'Timeout'),
            'bmcFRUControl':
            BMCFPCSTR.get(getdata.get('fruPowerControl')),
            'setHWSerialNumber':
            getdata.get('fruBoardSerialNumber'),
        })
Ejemplo n.º 28
0
class LocationMap(SnmpPlugin):

    maptype = "LocationMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.2.1.1.6.0': 'setLocationviaSNMP',
    })

    def process(self, device, results, log):
        """Collect SNMP location information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        om.setLocationviaSNMP = '/%s' % (self.prepId(om.setLocationviaSNMP))

        log.info('Location: %s', om.setLocationviaSNMP)
        return om
Ejemplo n.º 29
0
class SubagentShellOsMap(SnmpPlugin):
    """Map mib elements from SubagentShell mib to get os  release. """
    deviceProperties = SnmpPlugin.deviceProperties + ('getOSProductKey', )

    maptype = "SubagentShellOsMap"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.777.100.6.1': 'setOSProductKey',
    })

    def process(self, device, results, log):
        """collect snmp information from this device"""
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        if getdata['setOSProductKey'] is None: return None
        om = self.objectMap(getdata)
        return om
Ejemplo n.º 30
0
class NetWareSwapInfo(SnmpPlugin):

    maptype = "NetwareSwapInfo"
    compname = "os"
    relname = "filesystems"
    modname = "Products.ZenModel.FileSystem"

    snmpGetMap = GetMap({
        '.1.3.6.1.4.1.23.2.79.7.1.5.0': 'totalSwap',
    })

    def process(self, device, results, log):
        log.info('processing %s for device %s', self.name(), device.id)
        getdata, tabledata = results
        om = self.objectMap(getdata)
        om.totalSwap = om.totalSwap * 4
        return om