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 log.debug("%s getdata = %s", device.id, getdata) maps = [] om = self.objectMap(getdata) if om.snmpDescr: descr = re.sub("\s", " ", om.snmpDescr) for regex in self.osregex: m = regex.search(descr) if m: groups = m.groups() if groups[0] == 'Olson': om.setOSProductKey = MultiArgs(" ".join(groups[0:3]), 'Olson') else: om.setOSProductKey = " ".join(groups) log.debug("OSProductKey=%s", om.setOSProductKey) break maps.append(om) # Create an interface for the device if ipAddr and macAddr were supplied by Olson MIB if device.manageIp: if om._ipAddr and om._macAddr: maps.append(self.olsonInterface(om._ipAddr, om._macAddr)) return maps
def process(self, device, results, log): '''''' log.info("The plugin %s returned %s results." % (self.name(), len(results))) # trying to be sneaky here self.device = device klass = self.modname.split('.')[-1] if len(results) == 0: return None rm = self.relMap() for result in results: result = self.preprocess(result, log) enabled = result['enabled'] result.pop('enabled') om = self.objectMap(result) om.setJavaapp = '' om.setIpservice = '' #prodKey = '%s %s' % (result.get('vendorproduct'), klass) prodKey = result.get('vendorproduct') om.setProductKey = MultiArgs(prodKey, result.get('vendorname')) om.monitor = enabled om = self.postprocess(result, om, log) rm.append(om) log.debug(om) return rm
def process(self, device, results, log): log.info("Modeler %s processing data for device %s", self.name(), device.id) sysEnclosure = results.get('Win32_SystemEnclosure', (None, ))[0] computerSystem = results.get('Win32_ComputerSystem', (None, ))[0] operatingSystem = results.get('Win32_OperatingSystem', (None, ))[0] clusterInformation = results.get('MSCluster', ()) exchange_version = results.get('exchange_version') if exchange_version: exchange_version = exchange_version.stdout[ 0][:2] if exchange_version.stdout else None if exchange_version: exchange_version = { '6': '2003', '8': '2010', '08': '2010', '14': '2010', '15': '2013' }.get(exchange_version) maps = [] # Device Map device_om = ObjectMap() try: device_om.snmpSysName = computerSystem.Name device_om.snmpContact = computerSystem.PrimaryOwnerName device_om.snmpDescr = computerSystem.Caption except AttributeError: log.warn( 'No results returned for Win32_ComputerSystem. Check WMI namespace and DCOM permissions.' ) device_om.ip_and_hostname = self.get_ip_and_hostname(device.manageIp) # http://office.microsoft.com/en-001/outlook-help/determine-the-version-of-microsoft-exchange-server-my-account-connects-to-HA010117038.aspx if exchange_version: if exchange_version in ['2010', '2013']: device_om.msexchangeversion = 'MSExchange%sIS' % exchange_version else: # We use this attr to find the correct monitoring template device_om.msexchangeversion = 'MSExchangeInformationStore' else: device_om.msexchangeversion = '' # Cluster Information try: clusterlist = [] for cluster in clusterInformation: clusterlist.append(cluster.Name + '.' + computerSystem.Domain) device_om.setClusterMachines = clusterlist except (AttributeError): pass # if domainrole is 4 or 5 then this is a DC # Standalone Workstation (0) # Member Workstation (1) # Standalone Server (2) # Member Server (3) # Backup Domain Controller (4) # Primary Domain Controller (5) if computerSystem.DomainRole in (BACKUPDC, PRIMARYDC): device_om.domain_controller = True else: device_om.domain_controller = False maps.append(device_om) # Hardware Map hw_om = ObjectMap(compname='hw') try: hw_om.serialNumber = operatingSystem.SerialNumber if operatingSystem else '' except AttributeError: log.warn( 'No results returned for Win32_OperatingSystem. Check WMI namespace and DCOM permissions.' ) try: hw_om.tag = sysEnclosure.Tag hw_om.setProductKey = MultiArgs(computerSystem.Model, computerSystem.Manufacturer) except AttributeError: log.warn( 'No results returned for Win32_SystemEnclosure. Check WMI namespace and DCOM permissions.' ) try: assert operatingSystem is not None hw_om.totalMemory = 1024 * int( operatingSystem.TotalVisibleMemorySize) except AttributeError: log.warn("Win32_OperatingSystem query did not respond with " "TotalVisibleMemorySize: {0}".format( pformat(sorted(vars(operatingSystem).keys())))) except AssertionError: log.warn( 'No results returned for Win32_OperatingSystem. Check WMI namespace and DCOM permissions.' ) maps.append(hw_om) # Operating System Map os_om = ObjectMap(compname='os') try: os_om.totalSwap = int( operatingSystem.TotalVirtualMemorySize) * 1024 operatingSystem.Caption = re.sub(r'\s*\S*Microsoft\S*\s*', '', operatingSystem.Caption) osCaption = '{} - {}'.format(operatingSystem.Caption, operatingSystem.CSDVersion) os_om.setProductKey = MultiArgs(osCaption, operatingSystem.Manufacturer) except AttributeError: pass maps.append(os_om) return maps
def process(self, device, results, log): log.info("Modeler {} processing data for device {}".format( self.name(), device.id)) rm = self.relMap() try: diskdrives = results.get('diskdrives').get('Win32_DiskDrive') except Exception: return rm if not diskdrives: return rm partitions = results.get('diskdrives').get( 'Win32_DiskDriveToDiskPartition') volumes = results.get('diskdrives').get('Win32_LogicalDiskToPartition') for drive in diskdrives: utilization = 0 fs_ids = [] instance_name = '{}'.format(drive.Index) try: for partition in partitions[drive.DeviceID]: try: partsize = int(partition.Size) except (TypeError, ValueError): partsize = 0 utilization += partsize for volume in volumes[partition.DeviceID]: fs_ids.append(self.prepId(volume.DeviceID)) instance_name += ' {}'.format(volume.DeviceID) except Exception: log.debug("No partitions for drive {} on {}.".format( instance_name, device.id)) try: size = int(drive.Size) except (TypeError, ValueError): size = 0 freespace = size - utilization if freespace < 0: freespace = 0 try: num_partitions = int(drive.Partitions) except TypeError: num_partitions = 0 # drive.SerialNumber could be None. let's make it '' serialNumber = '' if hasattr(drive, 'SerialNumber'): if drive.SerialNumber is None: drive.SerialNumber = '' serialNumber = drive.SerialNumber.strip() product_key = MultiArgs(drive.Model, drive.Manufacturer) capabilities = '' if hasattr( drive, 'CapabilityDescriptions') and drive.CapabilityDescriptions: capabilities = drive.CapabilityDescriptions rm.append( self.objectMap({ 'id': self.prepId(drive.PNPDeviceID), 'title': drive.Caption, 'size': size, 'partitions': num_partitions, 'capabilities': capabilities, 'serialNumber': serialNumber, 'freespace': freespace, 'disk_ids': make_disk_ids(drive), 'fs_ids': fs_ids, 'instance_name': instance_name, 'setProductKey': product_key })) return rm
def process(self, device, results, log): log.info('processing %s for device %s', self.name(), device.id) dbrm = self.relMap() irm = self.relMap() irm.relname = "softwaredbsrvinstances" databases = [] instances = set([k[3:] for k in results.keys()]) for instname in instances: dbs = results.get('db_%s'%instname, None) if not dbs: continue try: inst = results['si_%s'%instname][0] om = self.objectMap(inst) except: databases.extend(dbs) continue om.modname = "ZenPacks.community.MsSQLMon.MsSqlSrvInst" if not om.dbsiname: om.dbsiname = instname or 'MSSQLSERVER' om.dbsiname = om.dbsiname.strip() om.id = self.prepId(om.dbsiname) om.processID = int(om.processID or 0) om.dbsiproperties = om.dbsiproperties.split() pn, arch = om.setProductKey.split(' - ', 1) arch = arch.__contains__('(X64)') and '(64-Bit) ' or '' pn = '%s %s(%s)' % (pn, arch, om.dbsiname) om.setProductKey = MultiArgs(pn, 'Microsoft') irm.append(om) for db in dbs: db['setDBSrvInst'] = om.dbsiname databases.append(db) for database in databases: try: om = self.objectMap(database) om.dbproperties = [] for dbprop in (database.pop('status', '') or '').split(', '): try: var, val = dbprop.split('=') setattr(om, var.lower(), val) except: om.dbproperties.append(dbprop) om.status = STATES.get(getattr(om, 'status', ''), 6) if not hasattr(om, 'setDBSrvInst'): om.id = self.prepId(om.dbname) else: om.id = self.prepId('%s_%s'%(om.setDBSrvInst, om.dbname)) om.dbid = int(om.dbid or 0) om.activeTime = str(om.activeTime) except Exception: continue om.blockSize = 8192 try: om.type = TYPES.get(float(str(getattr(om,'type',1)))) or TYPES[1] except ValueError: om.type = TYPES[1] try: om.totalBlocks = long(round(float(str(getattr(om, 'totalBlocks', 0) or 0).split()[0]) * 128)) except ValueError: om.totalBlocks = 0 dbrm.append(om) return [irm, dbrm]
severity=0, device=device.id, eventClass='/BBCApplication/Zenoss', eventKey='maxApps limit', component='BBCApplicationMap zenmodeler plugin', message='maxApps limit %d was not exceeded' % self.maxApps, summary='maxApps limit ok')) # build relationships for appName, appRow in app_hash.items(): om = self.objectMap(appRow) om.id = appName if kpi_hash.has_key(appName): om.getAppKPISetup = MultiArgs(kpi_hash[appName]) rm.append(om) # build 50 testName oids per application for app in appOids: for x in range(1, 51): appOid = "%s.75025.%s" % (app, x ) # 75025 if fibonacci seq f(25) newAppOid = "%s.75025.500.%s" % (app, x) # new oid space if appOid not in brokenAppOids: oidsToSave.append(appOid) if newAppOid not in brokenAppOids: if device.zBBCAdditionalAppOidSpace: oidsToSave.append(newAppOid)
def process(self, device, results, log): log.info("Modeler %s processing data for device %s", self.name(), device.id) getdata, tabledata = results sensor_count = sum([getdata[x] for x in getdata if "Count" in x]) maps = [] # device-specific data manufacturer = "Geist Manufacturing, Inc." os_name = "%s %s" % (getdata["productTitle"], getdata["productVersion"]) maps.append( ObjectMap( data={ "sensor_count": sensor_count, "title": getdata["productFriendlyName"], "productUrl": getdata["productUrl"], "setHWProductKey": MultiArgs(getdata["productHardware"], manufacturer), "setOSProductKey": MultiArgs(os_name, manufacturer), })) # Components: climate sensors rm = RelationshipMap( relname="geistClimateSensors", modname="ZenPacks.crosse.Geist.Monitor.GeistClimateSensor", ) for snmpindex, row in tabledata.get("climateTable", {}).items(): serial = row.get("climateSerial") if not serial: log.warn("Skipping climate sensor with no serial") continue log.debug("Modeling climate sensor %s", serial) values = {k: row[k] for k in row} values["id"] = self.prepId(serial) values["title"] = values["climateName"] values["snmpindex"] = snmpindex.strip(".") rm.append( ObjectMap( modname="ZenPacks.crosse.Geist.Monitor.GeistClimateSensor", data=values, )) maps.append(rm) # Components: temperature sensors rm = RelationshipMap( relname="geistTemperatureSensors", modname="ZenPacks.crosse.Geist.Monitor.GeistTemperatureSensor", ) for snmpindex, row in tabledata.get("tempSensorTable", {}).items(): serial = row.get("tempSensorSerial") if not serial: log.warn("Skipping temperature sensor with no serial") continue log.debug("Modeling temperature sensor %s", serial) values = {k: row[k] for k in row} values["id"] = self.prepId(serial) values["title"] = values["tempSensorName"] values["snmpindex"] = snmpindex.strip(".") rm.append( ObjectMap( modname= "ZenPacks.crosse.Geist.Monitor.GeistTemperatureSensor", data=values, )) maps.append(rm) # Components: airflow sensors rm = RelationshipMap( relname="geistAirflowSensors", modname="ZenPacks.crosse.Geist.Monitor.GeistAirflowSensor", ) for snmpindex, row in tabledata.get("airFlowSensorTable", {}).items(): serial = row.get("airFlowSensorSerial") if not serial: log.warn("Skipping airflow sensor with no serial") continue log.debug("Modeling airflow sensor %s", serial) values = {k: row[k] for k in row} values["id"] = self.prepId(serial) values["title"] = values["airFlowSensorName"] values["snmpindex"] = snmpindex.strip(".") rm.append( ObjectMap( modname="ZenPacks.crosse.Geist.Monitor.GeistAirflowSensor", data=values, )) maps.append(rm) return maps
def process(self, device, results, log): log.info("Modeler %s processing data for device %s", self.name(), device.id) sysEnclosure = results.get('Win32_SystemEnclosure', (None, ))[0] computerSystem = results.get('Win32_ComputerSystem', (None, ))[0] operatingSystem = results.get('Win32_OperatingSystem', (None, ))[0] clusterInformation = results.get('MSCluster', ()) exchange_version = results.get('exchange_version') if exchange_version: exchange_version = exchange_version.stdout[ 0][:2] if exchange_version.stdout else None if exchange_version: exchange_version = { '6': '2003', '8': '2010', '08': '2010', '14': '2010', '15': '2013' }.get(exchange_version) maps = [] if not computerSystem: # if no results for computerSystem, then there is a WMI permission error log.warn('No results returned for OperatingSystem plugin.' ' Check WMI namespace and DCOM permissions.') return maps # Device Map device_om = ObjectMap() device_om.snmpSysName = getattr( computerSystem, 'Name', getattr(operatingSystem, 'CSName', 'Unknown')).strip() device_om.snmpContact = getattr( computerSystem, 'PrimaryOwnerName', getattr(operatingSystem, 'RegisteredUser', 'Unknown')).strip() device_om.snmpDescr = getattr( computerSystem, 'Caption', getattr(operatingSystem, 'Caption', 'Unknown')).strip() device_om.ip_and_hostname = self.get_ip_and_hostname(device.manageIp) # http://office.microsoft.com/en-001/outlook-help/determine-the-version-of-microsoft-exchange-server-my-account-connects-to-HA010117038.aspx if exchange_version: if exchange_version in ['2010', '2013']: device_om.msexchangeversion = 'MSExchange%sIS' % exchange_version else: # We use this attr to find the correct monitoring template device_om.msexchangeversion = 'MSExchangeInformationStore' else: device_om.msexchangeversion = '' # Cluster Information clusterlist = [] for cluster in clusterInformation: clusterlist.append( getattr(cluster, 'Name', '') + '.' + getattr(computerSystem, 'Domain', '')) device_om.setClusterMachines = clusterlist # if domainrole is 4 or 5 then this is a DC # Standalone Workstation (0) # Member Workstation (1) # Standalone Server (2) # Member Server (3) # Backup Domain Controller (4) # Primary Domain Controller (5) device_om.domain_controller = False if getattr(computerSystem, 'DomainRole', '0') in (BACKUPDC, PRIMARYDC) or\ getattr(operatingSystem, 'ProductType', '0') == OS_DOMAIN_CONTROLLER: device_om.domain_controller = True maps.append(device_om) # Hardware Map hw_om = ObjectMap(compname='hw') hw_om.serialNumber = getattr(operatingSystem, 'SerialNumber', '') if operatingSystem else '' hw_om.tag = getattr(sysEnclosure, 'Tag', 'Unknown') model = getattr(computerSystem, 'Model', 'Unknown') manufacturer = getattr( computerSystem, 'Manufacturer', getattr(operatingSystem, 'Manufacturer', 'Microsoft Corporation')) hw_om.setProductKey = MultiArgs(model, manufacturer) try: hw_om.totalMemory = 1024 * int( operatingSystem.TotalVisibleMemorySize) except AttributeError: log.warn("Win32_OperatingSystem query did not respond with " "TotalVisibleMemorySize: {0}".format( pformat(sorted(vars(operatingSystem).keys())))) maps.append(hw_om) # Operating System Map os_om = ObjectMap(compname='os') os_om.totalSwap = int( getattr(operatingSystem, 'TotalVirtualMemorySize', '0')) * 1024 operatingSystem.Caption = re.sub( r'\s*\S*Microsoft\S*\s*', '', getattr(operatingSystem, 'Caption', 'Unknown')) osCaption = getattr(operatingSystem, 'Caption', 'Unknown') CSDVersion = getattr(operatingSystem, 'CSDVersion', 'Unknown') if CSDVersion: osCaption += ' - {}'.format(CSDVersion) os_om.setProductKey = MultiArgs( osCaption, getattr(operatingSystem, 'Manufacturer', 'Microsoft Corporation')) maps.append(os_om) return maps
def process(self, device, results, log): log.info("Modeler %s processing data for device %s", self.name(), device.id) sysEnclosure = results.get('Win32_SystemEnclosure', (None, ))[0] computerSystem = results.get('Win32_ComputerSystem', (None, ))[0] operatingSystem = results.get('Win32_OperatingSystem', (None, ))[0] clusterInformation = results.get('MSCluster', ()) exchange_version = results.get('exchange_version') if exchange_version: exchange_version = exchange_version.stdout[ 0][:2] if exchange_version.stdout else None if exchange_version: exchange_version = { '6': '2003', '8': '2010', '08': '2010', '14': '2010', '15': '2013' }.get(exchange_version) maps = [] # Device Map device_om = ObjectMap() device_om.snmpSysName = computerSystem.Name device_om.snmpContact = computerSystem.PrimaryOwnerName device_om.snmpDescr = computerSystem.Caption # http://office.microsoft.com/en-001/outlook-help/determine-the-version-of-microsoft-exchange-server-my-account-connects-to-HA010117038.aspx if exchange_version: device_om.msexchangeversion = 'MSExchange%sIS' % ( exchange_version if exchange_version in ['2010', '2013'] else "") else: device_om.msexchangeversion = 'MSExchangeIS' # Cluster Information try: clusterlist = [] for cluster in clusterInformation: clusterlist.append(cluster.Name + '.' + computerSystem.Domain) device_om.setClusterMachines = clusterlist except (AttributeError): pass maps.append(device_om) # Hardware Map hw_om = ObjectMap(compname='hw') hw_om.serialNumber = sysEnclosure.SerialNumber hw_om.tag = sysEnclosure.Tag hw_om.setProductKey = MultiArgs(computerSystem.Model, computerSystem.Manufacturer) if hasattr(operatingSystem, 'TotalVisibleMemorySize'): hw_om.totalMemory = 1024 * int( operatingSystem.TotalVisibleMemorySize) else: log.warn("Win32_OperatingSystem query did not respond with " "TotalVisibleMemorySize: {0}".format( pformat(sorted(vars(operatingSystem).keys())))) maps.append(hw_om) # Operating System Map os_om = ObjectMap(compname='os') os_om.totalSwap = int(operatingSystem.TotalVirtualMemorySize) * 1024 operatingSystem.Caption = re.sub(r'\s*\S*Microsoft\S*\s*', '', operatingSystem.Caption) osCaption = '{} - {}'.format(operatingSystem.Caption, operatingSystem.CSDVersion) os_om.setProductKey = MultiArgs(osCaption, operatingSystem.Manufacturer) maps.append(os_om) return maps
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 cpuTable = tabledata.get('cpmCPUTotalTable') if cpuTable is None: log.error('Unable to get cpmCPUTotalTable for %s' % device.id) return None else: log.debug('cpmCPUTotalTable has % entries', len(cpuTable)) entTable = tabledata.get('entPhysicalTable') if entTable is None: log.error('Unable to get entPhysicalTable for %s' % device.id) return None else: log.debug('entPhysicalTable has %s entries', len(entTable)) # Processors rm = self.relMap() for snmpindex, row in cpuTable.items(): if not rm and not self.checkColumns(row, self.columns, log): return rm om = self.objectMap() om.snmpindex = snmpindex.strip('.') # Many fixed-config switches and small routers return 0 for # cpmCPUTotalPhysicalIndex and have no entPhysicalName.0 object, # but have entPhysicalName.1. The Catalyst 3560 is a notable # exception, starting with entPhysicalName.1001. entIndex = str(row.get('cpmCPUTotalPhysicalIndex', None)) if entIndex not in entTable: log.debug('Index %s not found in entPhysicalTable, using %s', entIndex, snmpindex) entIndex = str(snmpindex) if entIndex not in entTable: entIndex = str(1000 + int(entIndex)) log.debug( 'Index %s not found in entPhysicalTable, using %s', snmpindex, entIndex) entity = entTable.get(entIndex, dict()) model = entity.get('entPhysicalModelName', None) if model is None or len(model) == 0: log.debug('entPhysicalModelName not available') model = entity.get('entPhysicalDescr', None) if model is None or len(model) == 0: log.debug('entPhysicalDescr not available') model = entity.get('entPhysicalName', None) if model is None or len(model) == 0: log.debug('entPhysicalName not available') model = 'CPU {0}'.format(om.snmpindex) if 'cpu' not in model.lower() and 'proc' not in model.lower(): model = 'CPU of {0}'.format(model) mfg = entTable[entIndex].get('entPhysicalMfgName') if mfg is None or len(mfg) == 0: log.debug('entPhysicalMfgName not available') mfg = 'Cisco' socket = entTable[entIndex].get('entPhysicalContainedIn') if socket is None or len(str(socket)) == 0: log.debug('entPhysicalContainedIn not available, using 0') socket = '0' # TODO: Set socket value in ObjectMap log.debug('Index: %s, Model: %s, Manufacturer: %s', entIndex, model, mfg) om.setProductKey = MultiArgs(model, mfg) om.id = self.prepId(model) rm.append(om) log.debug('%s RelMap:\n%s', self.name(), str(rm)) return rm
def process(self, device, results, log): """Gather data from the standard AIX snmpd + friends""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results pv_table = tabledata.get("aixPvTable") vg_table = tabledata.get("aixVgTable") lv_table = tabledata.get("aixLvTable") fs_table = tabledata.get("aixFsTable") paging_table = tabledata.get("aixPagingTable") if not pv_table or not vg_table or not lv_table or not fs_table: log.warn('No SNMP response from %s for the %s plugin', device.id, self.name()) log.warn("Data= %s", getdata) return relationship = self.relMap() maps = [] # Loop through the Volume Groups skipvgnames = getattr(device, 'zVolumeGroupIgnoreNames', None) for vg in vg_table.values(): if not self.checkColumns(vg, self.aixVgTable_columns, log): log.debug("Volume Group data missing ... skipping...") continue if skipvgnames and re.search(skipvgnames, vgom.title): log.info( "Skipping volume group %s as it matches zVolumeGroupIgnoreNames.", vgom.title) continue vgom = self.objectMap(vg) vgom.id = self.prepId(vgom.title) # Find the Physical Volumes for this Volume Group pv_hash = {} for pv in pv_table.values(): if not self.checkColumns(pv, self.aixPvTable_columns, log): log.debug("Physical volume data missing ... skipping...") continue if pv['aixPvNameVg'] == vgom.title: pv_hash[pv['title']] = pv # Find the Logical Volumes for this Volume Group lv_hash = {} skiplvnames = getattr(device, 'zLogicalVolumeIgnoreNames', None) for lv in lv_table.values(): if not self.checkColumns(lv, self.aixLvTable_columns, log): log.debug("logical volume data missing ... skipping...") continue if skiplvnames and re.search(skiplvnames, lv['title']): log.info( "Skipping logical volume %s as it matches zLogicalVolumeIgnoreNames.", lv['title']) continue skipfsnames = getattr(device, 'zFileSystemMapIgnoreNames', None) skipfstypes = getattr(device, 'zFileSystemMapIgnoreTypes', None) if lv['aixLvNameVg'] == vgom.title: lv_hash[lv['title']] = lv # Find any Filesystems that map to the logical volume for fs in fs_table.values(): if not self.checkColumns(fs, self.aixFsTable_columns, log): log.debug( "filesystem data missing ... skipping...") continue if fs['storageDevice'] == "/dev/" + lv['title']: if skipfsnames and re.search( skipfsnames, fs['mount']): log.info( "Skipping %s as it matches zFileSystemMapIgnoreNames.", fs['mount']) continue if skipfstypes and fs['type'] in skipfstypes: log.info( "Skipping %s (%s) as it matches zFileSystemMapIgnoreTypes.", fs['mount'], fs['type']) continue if fs['totalBlocks'] <= 0: log.info("Skipping %s as its totalBlocks <= 0", fs['mount']) continue if fs['storageDevice'] == "/dev/" + lv['title']: lv_hash[lv['title']]['getFsSetup'] = fs # Find any Paging Spaces that map to the logical volume for paging in paging_table.values(): if not self.checkColumns( paging, self.aixPagingTable_columns, log): log.debug("paging data missing ... skipping...") continue if paging['aixPageName'] == lv['title']: lv_hash[lv['title']]['getPagingSetup'] = paging vgom.getPvSetup = MultiArgs(pv_hash) vgom.getLvSetup = MultiArgs(lv_hash) relationship.append(vgom) maps.append(relationship) log.debug(maps) # # As a final sanity check, see if we found anything. If we # didn't find anything, that's probably an error so just return. # if len(maps) == 0: log.warn("No volume groups found by %s for %s", self.name(), device.id) return # Return valid maps found return maps
def process(self, device, results, log): log.info("Modeler %s processing data for device %s", self.name(), device.id) sysEnclosure = results.get('Win32_SystemEnclosure', (None, ))[0] computerSystem = results.get('Win32_ComputerSystem', (None, ))[0] operatingSystem = results.get('Win32_OperatingSystem', (None, ))[0] clusterInformation = results.get('MSCluster', ()) maps = [] # Device Map device_om = ObjectMap() device_om.snmpSysName = computerSystem.Name device_om.snmpContact = computerSystem.PrimaryOwnerName device_om.snmpDescr = computerSystem.Caption # Cluster Information try: clusterlist = [] for cluster in clusterInformation: clusterlist.append(cluster.Name) device_om.setClusterMachines = clusterlist except (AttributeError): pass maps.append(device_om) # Hardware Map hw_om = ObjectMap(compname='hw') hw_om.serialNumber = sysEnclosure.SerialNumber hw_om.tag = sysEnclosure.Tag hw_om.setProductKey = MultiArgs(computerSystem.Model, computerSystem.Manufacturer) if hasattr(operatingSystem, 'TotalVisibleMemorySize'): hw_om.totalMemory = 1024 * int( operatingSystem.TotalVisibleMemorySize) else: log.warn("Win32_OperatingSystem query did not respond with " "TotalVisibleMemorySize: {0}".format( pformat(sorted(vars(operatingSystem).keys())))) maps.append(hw_om) # Operating System Map os_om = ObjectMap(compname='os') os_om.totalSwap = int(operatingSystem.TotalVirtualMemorySize) * 1024 operatingSystem.Caption = re.sub(r'\s*\S*Microsoft\S*\s*', '', operatingSystem.Caption) osCaption = '{} - {}'.format(operatingSystem.Caption, operatingSystem.CSDVersion) os_om.setProductKey = MultiArgs(osCaption, operatingSystem.Manufacturer) maps.append(os_om) return maps
def process(self, device, results, log): log.info('processing %s for device %s', self.name(), device.id) types = { 1: 'SQL Server', 60: 'SQL Server 6.0', 65: 'SQL Server 6.5', 70: 'SQL Server 7.0', 80: 'SQL Server 2000', 90: 'SQL Server 2005', 100: 'SQL Server 2008', } statuses = { 'ONLINE': 0, 'OFFLINE': 1, 'RESTORING': 2, 'RECOVERING': 3, 'RECOVERY_PENDING': 4, 'SUSPECT': 5, 'EMERGENCY': 6, } maps = [self.relMap()] databases = [] for instname in getattr(device, 'zMsSqlSrvInstances', '').split() or ['']: inst = results.get('si_%s' % instname, [None])[0] dbs = results.get('db_%s' % instname, None) if not dbs: continue if not inst: databases.extend(dbs) continue om = self.objectMap(inst) if not om.dbsiname: om.dbsiname = instname or 'MSSQLSERVER' om.id = self.prepId(om.dbsiname) om.dbsiproperties = om.dbsiproperties.split() pn, arch = om.setProductKey.split(' - ', 1) if not arch.__contains__('(X64)'): pn = '%s (%s)' % (pn, om.dbsiname) else: pn = '%s (64-Bit) (%s)' % (pn, om.dbsiname) om.setProductKey = MultiArgs(pn, 'Microsoft') maps[-1].append(om) for db in dbs: db['setDBSrvInst'] = om.dbsiname databases.append(db) self.relname = "softwaredatabases" self.modname = "ZenPacks.community.MsSQLMon_ODBC.MsSqlDatabase" maps.append(self.relMap()) if not databases: return maps for database in databases: try: om = self.objectMap(database) if not om.status: om.status = 1 else: om.dbproperties = [] for dbprop in om.status.split(', '): try: var, val = dbprop.split('=') if var == 'Status': val = statuses.get(val, 0) setattr(om, var.lower(), val) except: om.dbproperties.append(dbprop) if not hasattr(om, 'setDBSrvInst'): om.id = self.prepId(om.dbname) else: om.id = self.prepId('%s_%s' % (om.setDBSrvInst, om.dbname)) om.activeTime = str(om.activeTime) om.type = types.get(getattr(om, 'type', 1), types[1]) om.blockSize = 8192 om.totalBlocks = round(float(om.totalBlocks.split()[0]) * 128) except AttributeError: continue maps[-1].append(om) return maps
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
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 maps = [] OSModelDict = { '1.3.6.1.4.1.22610.1.3': 'a10AX', '1.3.6.1.4.1.22610.1.3.1': 'a10AX2100', '1.3.6.1.4.1.22610.1.3.2': 'a10AX3100', '1.3.6.1.4.1.22610.1.3.3': 'a10AX3200', '1.3.6.1.4.1.22610.1.3.4': 'a10AX2200', '1.3.6.1.4.1.22610.1.3.5': 'a10AX2000', '1.3.6.1.4.1.22610.1.3.6': 'a10AX1000', '1.3.6.1.4.1.22610.1.3.7': 'a10AX5200', '1.3.6.1.4.1.22610.1.3.8': 'a10AX2500', '1.3.6.1.4.1.22610.1.3.9': 'a10AX2600', '1.3.6.1.4.1.22610.1.3.10': 'a10AX3000', '1.3.6.1.4.1.22610.1.3.11': 'a10HitachiBladeServer', '1.3.6.1.4.1.22610.1.3.12': 'a10AX5100', '1.3.6.1.4.1.22610.1.3.13': 'a10SoftAX', '1.3.6.1.4.1.22610.1.3.14': 'a10AX3030', '1.3.6.1.4.1.22610.1.3.15': 'a10AX1030', '1.3.6.1.4.1.22610.1.3.16': 'a10AX3200-12', '1.3.6.1.4.1.22610.1.3.17': 'a10AX3400', '1.3.6.1.4.1.22610.1.3.18': 'a10AX3530', '1.3.6.1.4.1.22610.1.3.19': 'a10AX5630', '1.3.6.1.4.1.22610.1.3.20': 'a10TH6430', '1.3.6.1.4.1.22610.1.3.21': 'a10TH5430', '1.3.6.1.4.1.22610.1.3.22': 'a10TH3030S', '1.3.6.1.4.1.22610.1.3.23': 'a10TH1030S', '1.3.6.1.4.1.22610.1.3.24': 'a10TH930S', '1.3.6.1.4.1.22610.1.3.25': 'a10TH4430', '1.3.6.1.4.1.22610.1.3.26': 'a10TH5330', '1.3.6.1.4.1.22610.1.3.27': 'a10TH4330', '1.3.6.1.4.1.22610.1.3.28': 'a10TH5630', '1.3.6.1.4.1.22610.1.3.29': 'a10TH6630', } #om = self.objectMap(getdata) try: serialNumber = getdata.get('_serialNumber', None) # SNMP memory values are in KB - convert to bytes memoryUsed = getdata.get('memoryUsed', None) * 1024 # Default map is A10DeviceMap (in maptype statement at top) maps.append(ObjectMap({'setHWSerialNumber': serialNumber})) maps.append(ObjectMap({'memoryUsed': memoryUsed})) # Get Hw Model manufacturer = 'Raksha Networks Inc.' HwModel = getdata.get('_snmpOid', None) log.info(' HwModel is %s \n' % (HwModel)) if HwModel: try: model = OSModelDict[HwModel.strip('.')] except: model = None pass log.info(' Model is %s \n' % (model)) if model: model = manufacturer + ' ' + model maps.append( ObjectMap({ 'setHWProductKey': MultiArgs(model, manufacturer) })) SwModel = getdata.get('_snmpDescr', None) if SwModel: maps.append( ObjectMap( {'setOSProductKey': MultiArgs(SwModel, manufacturer)})) # totalMemory is part of the standard os component so compname is added to next maps.append maps.append( ObjectMap({'totalMemory': getdata['_totalMemory'] * 1024}, compname='hw')) except (KeyError, IndexError, AttributeError, TypeError), errorInfo: log.warn(' Error in %s modeler plugin %s' % (self.name(), errorInfo))
def process(self, device, results, log): # data format expected in results # DisplayName=Software1;InstallDate=19700101;Vendor=Microsoft Corporation| # DisplayName=Software2;InstallDate=19700102;Vendor=Microsoft Corporation| log.info("Modeler %s processing data for device %s", self.name(), device.id) rm = self.relMap() software_results = results.get('software') if not software_results: return rm software_results = ''.join(software_results.stdout).split('|') # Registry Software formatting for sw in software_results: softwareDict = {} for keyvalues in sw.split(';'): try: key, value = keyvalues.split('=') except ValueError: continue value = str(value.strip()) try: if key == "Vendor": checkValidId(None, value, allow_dup=False) except BadRequest: value = str() softwareDict[key] = value keys = ['DisplayName', 'Vendor', 'InstallDate'] # malformed data line if set(keys).difference(set(softwareDict.keys())): continue # skip over empty entries if softwareDict['DisplayName'] == '': continue om = self.objectMap() om.id = self.eliminate_underscores( self.prepId(softwareDict['DisplayName'])).strip() vendor = softwareDict['Vendor'].strip( ) if softwareDict['Vendor'].strip() != '' else 'Unknown' om.setProductKey = MultiArgs(om.id, vendor) if any(om.setProductKey.args == x.setProductKey.args for x in rm.maps): # https://jira.zenoss.com/browse/ZPS-1245 # Do not report duplicate software, even if Windows reports it continue try: installDate = DateTime(softwareDict['InstallDate']) om.setInstallDate = '{0} 00:00:00'.format(installDate.Date()) except (SyntaxError, TimeError): # Date is unreadable or empty, ok to leave blank pass rm.append(om) return rm
def process(self, device, results, log): log.info('processing %s for device %s', self.name(), device.id) maps = [] regionmap = [] regionnames = [] getdata, tabledata = results acc_points = tabledata.get('hwApObjectsTable', {}) lldp = tabledata.get('hwApLldpTable', {}) regions = tabledata.get('hwApRegionTable', {}) # AP Region Component for snmpindex, row in regions.items(): name = row.get('hwApRegionName') if not name: log.warn('Skipping region with no name') continue regionnames.append(name) regionmap.append( ObjectMap({ 'id': self.prepId(name), 'title': name, 'snmpindex': snmpindex.strip('.'), 'regiondeploymode': DEPLOYMODES.get(row.get('hwApRegionDeployMode'), 'Unknown'), 'regionapnumber': row.get('hwApRegionApNumber'), })) # Access Point Component for region in regionnames: apmap = [] for snmpindex, row in acc_points.items(): neighbour = "" neighport = "" name = row.get('hwApSysName') regionrow = regions.get('.' + str(row.get('hwApUsedRegionIndex'))), apregion = regionrow[0].get('hwApRegionName'), if not name: log.warn('Skipping access point with no name') continue if region == apregion[0]: apneighbour = lldp.get(snmpindex + '.200.1') if apneighbour is not None: neighbour = apneighbour.get('hwApLldpRemSysName') neighport = apneighbour.get('hwApLldpRemPortId') apmap.append( ObjectMap({ 'id': self.prepId(name), 'title': name, 'snmpindex': snmpindex.strip('.'), 'apip': row.get('hwApIpAddress'), 'apmac': self.asmac(row.get('hwApMac')), 'apserial': row.get('hwApSn'), 'apmodel': row.get('hwApUsedType'), 'apstatus': STATUSNAME.get(row.get('hwApRunState'), 'Unknown'), 'apregion': apregion, 'apsoftwareversion': row.get('hwApSoftwareVersion'), 'apneighbourname': neighbour, 'apneighbourport': neighport, })) maps.append( RelationshipMap( compname='huaweiAPRegions/%s' % region, relname='huaweiAccessPoints', modname= 'ZenPacks.community.HuaweiWireless.HuaweiAccessPoint', objmaps=apmap)) # Map main device details maps.append( ObjectMap( modname= 'ZenPacks.community.HuaweiWireless.HuaweiControllerDevice', data={ 'setHWSerialNumber': getdata.get('entPhysicalSerialNum'), 'setOSProductKey': MultiArgs(getdata.get('entPhysicalSoftwareRev'), 'HUAWEI Technology Co.,Ltd'), 'controller_maxap': getdata.get('hwWlanAcAccessMaxApNumber'), })) # Map AP Region components maps.append( RelationshipMap( relname='huaweiAPRegions', modname='ZenPacks.community.HuaweiWireless.HuaweiAPRegion', objmaps=regionmap)) return maps
def process(self, device, results, log): """Gather data from the standard AIX snmpd + friends""" log.info('processing %s for device %s', self.name(), device.id) getdata, tabledata = results cache_table = tabledata.get("aixMemTable") if not cache_table: log.warn('No SNMP response from %s for the %s plugin', device.id, self.name()) return # # There is only one L2 cache size # l2cache = 0 for memory_entry in cache_table.values(): if not self.checkColumns(memory_entry, self.cachecols, log): continue om = self.objectMap(memory_entry) # # From this same table we determine L2 cache, so determine if it's RAm or cache # if om.title[0:7] == "L2cache": l2cache = om.aixMemSize l2cache = l2cache * 1024 cputable = tabledata.get("aixProcessorTable") if not cputable: log.warn('No SNMP response from %s for the %s plugin', device.id, self.name()) return relationship = self.relMap() maps = [] cpumap = {} for cpu in cputable.values(): if not self.checkColumns(cpu, self.cpucols, log): continue om = self.objectMap(cpu) om.id = self.prepId(om.title) log.debug('Found %s', om.id) om.setProductKey = MultiArgs(om.setProductKey, "IBM") om.socket = om.title # # If for some reason we get empty entries, just bail out # if not om.clockspeed or om.clockspeed <= 0: continue om.clockspeed = om.clockspeed / 10**6 om.cacheSizeL2 = l2cache om._manuf = "IBM" relationship.append(om) #return rm maps.append(relationship) # # As a final sanity check, see if we found anything. If we # didn't find anything, that's probably an error so just return. # if len(maps) == 0: log.warn("No filesystems found by %s for %s", self.name(), device.id) return return maps