def processResults(self, cmd, result): """ Process the results for command "lsdrive -delim :". """ update = False datapointMap = dict([(dp.id, dp) for dp in cmd.points]) devname = cmd.deviceConfig.device # returned from datasource component field with ${here/id} componentid = cmd.component rresult = Utils.cmdParser(cmd.result.output,'id','DRIVE_ID') # specific component device rresult = rresult[componentid] # drive status raise event if rresult['status']!='online': result.events.append(Utils.getEvent(cmd,"Drive status not online",clear=False)) update = True # drive error sequence number if rresult['error_sequence_number']!='': result.events.append(Utils.getEvent(cmd,"Drive error sequence number: "+rresult['error_sequence_number'],clear=False)) update = True # update current component if needed if update: scriptbase = ZenScriptBase(noopts = 1, connect = True) device = scriptbase.findDevice(devname) component = device.drives.findObjectsById(componentid)[0] component.drive_status=rresult['status'] component.error_sequence_number=rresult['error_sequence_number'] commit()
def processResults(self, cmd, result): """ Process the results for command "lseventlog -message no -fixed no -delim :". """ devname = cmd.deviceConfig.device rresult = Utils.cmdParser(cmd.result.output,'event_id','EVT_ID') for key,evt in rresult.iteritems(): result.events.append(Utils.getEvent(cmd,key+':'+evt['description'],clear=False))
def processResults(self, cmd, result): """ Process the results for command "lseventlog -message no -fixed no -delim :". """ devname = cmd.deviceConfig.device rresult = Utils.cmdParser(cmd.result.output, 'event_id', 'EVT_ID') for key, evt in rresult.iteritems(): result.events.append( Utils.getEvent(cmd, key + ':' + evt['description'], clear=False))
def processResults(self, cmd, result): """ Process the results for command "lsenclosurebattery -delim :". """ datapointMap = dict([(dp.id, dp) for dp in cmd.points]) devname = cmd.deviceConfig.device # returned from datasource component field with ${here/id} componentid = cmd.component rresult = Utils.cmdParser(cmd.result.output,'battery_id','BAT_ID') # specific component device rresult = rresult[componentid] # recondition_needed raise event if rresult['recondition_needed']!='no': result.events.append(Utils.getEvent(cmd,"Battery recondition needed",clear=False)) #Battery end of life warning raise event if rresult['end_of_life_warning']!='no': result.events.append(Utils.getEvent(cmd,"Battery end of life warning",clear=False)) # update current component # zencommand does not have direct access to the model and components but # maybe theres another way to do this scriptbase = ZenScriptBase(noopts = 1, connect = True) device = scriptbase.findDevice(devname) component = device.batteries.findObjectsById(componentid)[0] component.battery_status=rresult['status'] component.charging_status=rresult['charging_status'] component.recondition_needed=rresult['recondition_needed'] component.percent_charged=int(rresult['percent_charged']) component.end_of_life_warning=rresult['end_of_life_warning'] commit()
def processResults(self, cmd, result): """ Process the results for command "lsdrive -delim :". """ update = False datapointMap = dict([(dp.id, dp) for dp in cmd.points]) devname = cmd.deviceConfig.device # returned from datasource component field with ${here/id} componentid = cmd.component rresult = Utils.cmdParser(cmd.result.output, 'id', 'DRIVE_ID') # specific component device rresult = rresult[componentid] # drive status raise event if rresult['status'] != 'online': result.events.append( Utils.getEvent(cmd, "Drive status not online", clear=False)) update = True # drive error sequence number if rresult['error_sequence_number'] != '': result.events.append( Utils.getEvent(cmd, "Drive error sequence number: " + rresult['error_sequence_number'], clear=False)) update = True # update current component if needed if update: scriptbase = ZenScriptBase(noopts=1, connect=True) device = scriptbase.findDevice(devname) component = device.drives.findObjectsById(componentid)[0] component.drive_status = rresult['status'] component.error_sequence_number = rresult['error_sequence_number'] commit()
def process(self, device, results, log): maps = [] #striping the commands results data = results.split("__COMMAND__\n") # gathering info for lssystem command try: total_mdisk_capacity = data[0].split( 'total_mdisk_capacity')[1].split('\n')[0].strip() except: total_mdisk_capacity = "unknown" try: total_used_capacity = data[0].split( 'total_used_capacity')[1].split('\n')[0].strip() except: total_used_capacity = "unknown" maps.append( self.objectMap({ 'total_mdisk_capacity': total_mdisk_capacity, 'total_used_capacity': total_used_capacity })) # parsing data for lsdrive command # results contents.. #id:status:error_sequence_number:use:tech_type:capacity:mdisk_id:mdisk_name:member_id:enclosure_id:slot_id:node_id:node_name:auto_manage #0:online::member:sas_nearline_hdd:1.8TB:0:mdisk0:1:1:3:::inactive #1:online::spare:sas_nearline_hdd:1.8TB::::1:1:::inactive #2:online::member:sas_nearline_hdd:1.8TB:0:mdisk0:4:1:6:::inactive #3:online::member:sas_nearline_hdd:1.8TB:0:mdisk0:5:1:7:::inactive lsdrivedata = Utils.cmdParser(data[1], 'id', 'DRIVE_ID') drives = [] for key, item in lsdrivedata.iteritems(): drives.append( ObjectMap( data={ 'id': self.prepId(key), 'title': key, 'drive_status': item['status'], 'error_sequence_number': item['error_sequence_number'], 'use': item['use'], 'tech_type': item['tech_type'], 'capacity': item['capacity'], 'enclosure_id': int(item['enclosure_id']), 'slot_id': int(item['slot_id']), })) maps.append( RelationshipMap(relname='drives', modname='ZenPacks.community.IBMV7000.Drive', objmaps=drives)) # parsing data for lsenclosure command # results contents.. #enclosure_id:battery_id:status:charging_status:recondition_needed:percent_charged:end_of_life_warning #2:1:online:idle:no:100:no #2:2:online:idle:no:99:no lsenclosuredata = Utils.cmdParser(data[2], 'id', 'ENC_ID') enclosures = [] for key, item in lsenclosuredata.iteritems(): enclosures.append( ObjectMap( data={ 'id': self.prepId(key), 'title': key, 'enclosure_status': item['status'], 'enclosure_type': item['type'], 'product_MTM': item['product_MTM'], 'serial_number': item['serial_number'], 'total_canisters': int(item['total_canisters']), 'online_canisters': int(item['online_canisters']), 'total_PSUs': int(item['total_PSUs']), 'online_PSUs': int(item['online_PSUs']), 'drive_slots': int(item['drive_slots']), 'total_fan_modules': int(item['total_fan_modules']), 'online_fan_modules': int(item['online_fan_modules']), })) maps.append( RelationshipMap(relname='enclosures', modname='ZenPacks.community.IBMV7000.Enclosure', objmaps=enclosures)) # parsing data for lsenclosurebattery command # results contents.. #enclosure_id:battery_id:status:charging_status:recondition_needed:percent_charged:end_of_life_warning #2:1:online:idle:no:100:no #2:2:online:idle:no:99:no lsenclosurebattery = Utils.cmdParser(data[3], 'battery_id', 'BAT_ID') batteries = [] for key, item in lsenclosurebattery.iteritems(): batteries.append( ObjectMap( data={ 'id': self.prepId(key), 'title': key, 'battery_status': item['status'], 'charging_status': item['charging_status'], 'recondition_needed': item['recondition_needed'], 'percent_charged': int(item['percent_charged']), 'end_of_life_warning': item['end_of_life_warning'], })) maps.append( RelationshipMap(relname='batteries', modname='ZenPacks.community.IBMV7000.Battery', objmaps=batteries)) return maps