def errorMessagesFound(): FILE_OPEN = "messages.txt" ERROR_MSG = re.compile("OraInstall.*libmawt.so.*cannot open shared object file.*No such file or directory", re.IGNORECASE) SECTION = "/var/log/warn" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR_MSG.search(LINE): return True SECTION = "/var/log/messages" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR_MSG.search(LINE): return True return False
def panicDetected(): PANIC = re.compile("exception RIP.*update_group_capacity", re.IGNORECASE) FILE_OPEN = "boot.txt" SECTION = "dmesg" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if PANIC.search(LINE): return True FILE_OPEN = "messages.txt" SECTION = "/var/log/warn" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if PANIC.search(LINE): return True return False
def nullVM(): FILE_OPEN = "xen.txt" SECTION = "xl list$" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if LINE.startswith('(null)'): return True return False
def validAutoinst(): FILE_OPEN = "y2log.txt" SECTION = "/root/autoinst.xml" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if '<peer>' in LINE: return True return False
def cloneSystemAttempted(): FILE_OPEN = "y2log.txt" SECTION = "/var/log/YaST2/y2log" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if "clone_system.rb" in LINE: return True return False
def fatalErrors(): fileOpen = "messages.txt" section = "/var/log/warn" content = [] MountError = re.compile("kernel.*CIFS VFS.*cifs_mount failed", re.IGNORECASE) if Core.getRegExSection(fileOpen, section, content): for LINE in content: if MountError.search(LINE): return True return False
def foundACPI5(): fileOpen = "boot.txt" section = "/dmesg" content = [] acpi5msg = re.compile("ACPI Warning.*FADT.*revision 5.*is longer than ACPI 2.0 version", re.IGNORECASE) if Core.getRegExSection(fileOpen, section, content): for line in content: if acpi5msg.search(line): return True return False
def excessiveWinBindKey(): fileOpen = "samba.txt" section = "log.winbindd" content = [] excessiveKeyLength = re.compile("cache_traverse_validate_fn.*key length too large", re.IGNORECASE) if Core.getRegExSection(fileOpen, section, content): for line in content: if excessiveKeyLength.search(line): return True return False
def delayedBootMessages(): FILE_OPEN = "boot.txt" SECTION = "/dmesg" CONTENT = [] ERROR_STRING = re.compile("pci.*vpd.*failed.*firmware bug", re.IGNORECASE) if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR_STRING.search(LINE): return True return False
def pathFailure(): FILE_OPEN = "messages.txt" SECTION = "/var/log/messages" CONTENT = [] Failure = re.compile("multipath.*failed path|multipath.*failing path|multipath.*mark as failed", re.IGNORECASE) if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if Failure.search(LINE): return True return False
def ntpchrootinfo(): fileOpen = "sysconfig.txt" section = "/etc/sysconfig/ntp" content = [] regresults = re.compile("CHROOTED.*yes", re.IGNORECASE) if Core.getRegExSection(fileOpen, section, content): for line in content: if regresults.search(line): return True return False
def ntpdnsinfo(): fileOpen = "ntp.txt" section = "/etc/ntp.conf" content = [] regresults = re.compile("^(server|fudge|restrict)[ \t][a-zA-Z0-9\.]*[a-zA-Z]", re.IGNORECASE) if Core.getRegExSection(fileOpen, section, content): for line in content: if regresults.search(line): return True return False
def be2netError(): FILE_OPEN = "messages.txt" SECTION = "/var/log/messages" CONTENT = [] oopsError = re.compile("Modules linked in:.*be2net", re.IGNORECASE) if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if oopsError.search(LINE): return True return False
def multipleCrons(): FILE_OPEN = "basic-health-check.txt" SECTION = "ps axwwo" CONTENT = [] CRONS = 0 if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if "cron" in LINE: CRONS += 1 if( CRONS > 1 ): return True return False
def clusterRequestFailure(): fileOpen = "lvm.txt" section = "/vgs" content = [] IN_STATE = False if Core.getRegExSection(fileOpen, section, content): for line in content: if( IN_STATE ): if "Can't get lock for" in line: return True elif "cluster request failed" in line: IN_STATE = True return False
def getDiskID(DEVICE_PATH): """ Gets the system disk (sd?) or world wide name ID for use in MPIO managed disk lookup. Returns and sd disk device without partition numbers or a wwid """ ID = '' DEV = DEVICE_PATH.split("/")[-1] + " " Digits = re.compile("\d+") #print "Evaluate", DEV if DEV.startswith("sd"): #check for system device name in the form sd? because they are easy to find ID = re.sub(Digits, "", DEV) else: CONTENT = [] UDEV_CONTENT = [] if Core.getRegExSection('mpio.txt', 'ls -lR.*/dev/disk/', CONTENT): #find out how the xen config device is symbolically linked for LINE in CONTENT: if DEV in LINE: #found the symlink for the xen device #print " ", LINE LINKED_DEV = LINE.split()[-1].split("/")[-1] #just get the last part of the linked path after the last / #print " ", LINKED_DEV if LINKED_DEV.startswith("sd"): #the symlink was linked to a system device ID = re.sub(Digits, "", LINKED_DEV) else: Core.getRegExSection('mpio.txt', '/udevadm info -e', UDEV_CONTENT) BlockDev = re.compile('^P:\s+/devices/virtual/block/' + str(LINKED_DEV)) EndBlockDev = re.compile('^$') IN_DEV = False for UDEV_LINE in UDEV_CONTENT: if( IN_DEV ): if EndBlockDev.search(UDEV_LINE): IN_DEV = False elif "DM_NAME=" in UDEV_LINE: ID = UDEV_LINE.split("=")[-1] IN_DEV = False break elif BlockDev.search(UDEV_LINE): IN_DEV = True #print " ", ID, "\n" return ID.strip()
def errorFound(): ERROR = re.compile("kernel BUG at.*block/blk-core.c:2392", re.IGNORECASE) FILE_OPEN = "boot.txt" SECTION = "/dmesg" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR.search(LINE): return True FILE_OPEN = "messages.txt" SECTION = "/var/log/warn" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR.search(LINE): return True SECTION = "/var/log/messages" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if ERROR.search(LINE): return True return False
def susceptibleNTPConfig(): FILE_OPEN = "ntp.txt" SECTION = "/etc/ntp.conf" CONTENT = [] SERVER = False FUDGE = False if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if 'server' in LINE.lower(): SERVER = True if 'fudge' in LINE.lower(): FUDGE = True if( SERVER and FUDGE ): return True else: return False
def devicesManaged(): """ Determines if any disks are managed with MPIO. It looks at the multipath -ll output for device lines with -+- in them. Args: None Returns: True or False True if devices are being managed False if they are not. Example: if( SUSE.mpioDevicesManaged() ): Core.updateStatus(Core.IGNORE, "MPIO Disks are being managed") else: Core.updateStatus(Core.WARNG, "No MPIO Disks are being managed") """ FILE_OPEN = "mpio.txt" SECTION = "multipath -ll" CONTENT = [] if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if '-+-' in LINE: return True return False
OVERALL = Core.TEMP OVERALL_INFO = "NOT SET" OTHER_LINKS = "META_LINK_TID=https://www.suse.com/support/kb/doc.php?id=7017137" Core.init(META_CLASS, META_CATEGORY, META_COMPONENT, PATTERN_ID, PRIMARY_LINK, OVERALL, OVERALL_INFO, OTHER_LINKS) ############################################################################## # Main Program Execution ############################################################################## FILE_OPEN = "systemd.txt" SECTION = "systemctl --failed" CONTENT = [] FAILED_SERVICES = [] IDX_UNIT_NAME = 0 #find any systemd units that have failed if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): failedState = re.compile("loaded.*failed", re.IGNORECASE) for LINE in CONTENT: if failedState.search(LINE): FAILED_SERVICES.append(LINE.split()[IDX_UNIT_NAME]) if( len(FAILED_SERVICES) > 0 ): Core.updateStatus(Core.CRIT, "Systemd units currently in a failed state: " + ", ".join(FAILED_SERVICES)) else: Core.updateStatus(Core.IGNORE, "No failed systemd units found") Core.printPatternResults()
def getManagedDevices(): """ Normalizes the multipath -ll output into a list of dictionaries. The multipath -ll output looks similar to: #==[ Command ]======================================# # /sbin/multipath -ll mpathe (3600601609e003700bd875493d3ade411) dm-2 DGC,VRAID size=1.0T features='1 queue_if_no_path' hwhandler='1 emc' wp=rw |-+- policy='round-robin 0' prio=4 status=active | |- 2:0:1:4 sdai 66:32 active ready running | `- 1:0:1:4 sdo 8:224 active ready running `-+- policy='round-robin 0' prio=1 status=enabled |- 1:0:0:4 sde 8:64 active ready running `- 2:0:0:4 sdy 65:128 active ready running Args: None Returns: List of Dictionaries Example: Though the order of the elements will be different that shown. These are ordered to demonstrate the key value pairs. getManagedDevices would return a list of dictionaries for the example above as follows: [ {'alias': 'mpathe', 'wwid': '3600601609e003700bd875493d3ade411', 'dmdev': 'dm-2', 'description': 'DGC,VRAID', 'size': '1.0T', 'features': '1 queue_if_no_path', 'hwhandler': '1 emc', 'wp': 'rw', 'devicepath': [ {'path_group_policy': 'round-robin 0', 'path_state': 'running', 'path_group_status': 'active', 'path_devnode': 'sdai', 'path_group_prio': '4', 'dm_status': 'ready', 'path_major_minor': '66:32', 'path_scsi_addr': '2:0:1:4', 'path_status': 'active'}, {'path_group_policy': 'round-robin 0', 'path_state': 'running', 'path_group_status': 'active', 'path_devnode': 'sdo', 'path_group_prio': '4', 'dm_status': 'ready', 'path_major_minor': '8:224', 'path_scsi_addr': '1:0:1:4', 'path_status': 'active'}, {'path_group_policy': 'round-robin 0', 'path_state': 'running', 'path_group_status': 'enabled', 'path_devnode': 'sde', 'path_group_prio': '1', 'dm_status': 'ready', 'path_major_minor': '8:64', 'path_scsi_addr': '1:0:0:4', 'path_status': 'active'}, {'path_group_policy': 'round-robin 0', 'path_state': 'running', 'path_group_status': 'enabled', 'path_devnode': 'sdy', 'path_group_prio': '1', 'dm_status': 'ready', 'path_major_minor': '65:128', 'path_scsi_addr': '2:0:0:4', 'path_status': 'active'} ] }] """ FILE_OPEN = "mpio.txt" SECTION = "multipath -ll" CONTENT = [] DEVICES = [] IN_DEVICE = False MPATH = {} ENTRIES = [] DeviceStart = re.compile(" dm-\d+ ") DeviceEntry = re.compile("\d+:\d+:\d+:\d+\s+\D+\s+\d+:\d+", re.IGNORECASE) if Core.getRegExSection(FILE_OPEN, SECTION, CONTENT): for LINE in CONTENT: if DeviceStart.search(LINE): if( len(MPATH) > 1 ): DEVICES.append(dict(MPATH)) MPATH = {'devicepath': []} PARTS = LINE.split() PATH_GROUP_VALUES = {} if PARTS[1].startswith('('): # user alias names in use MPATH['alias'] = PARTS[0] MPATH['wwid'] = PARTS[1].strip('()') MPATH['dmdev'] = PARTS[2] del PARTS[0:3] MPATH['description'] = ' '.join(PARTS) else: MPATH['alias'] = '' MPATH['wwid'] = PARTS[0] MPATH['dmdev'] = PARTS[1] del PARTS[0:2] MPATH['description'] = ' '.join(PARTS) elif "size=" in LINE: KEY_VALUES = convertKeyValue(LINE) MPATH.update(KEY_VALUES) elif '-+-' in LINE: D = convertKeyValue(LINE) #print "==Insert path_group_", D PATH_GROUP_VALUES = {} # prepend "path_group_" before each PATH_GROUP_VALUES key for KEY in D.keys(): NEW_KEY = "path_group_" + str(KEY) PATH_GROUP_VALUES[NEW_KEY] = D[KEY] #print "KEY", KEY #print "NEW_KEY", NEW_KEY #print "RESULT:", PATH_GROUP_VALUES, "\n" del D elif DeviceEntry.search(LINE): TMP = LINE.split() ENTRIES = {} while TMP[0].startswith(('|','`')): del TMP[0] COUNT = len(TMP) if( TMP > 5 ): ENTRIES = {"path_scsi_addr": TMP[0], "path_devnode": TMP[1], "path_major_minor": TMP[2], "path_status": TMP[3], "dm_status": TMP[4], "path_state": TMP[5]} elif( TMP > 4 ): ENTRIES = {"path_scsi_addr": TMP[0], "path_devnode": TMP[1], "path_major_minor": TMP[2], "path_status": TMP[3], "dm_status": TMP[4]} elif( TMP > 3 ): ENTRIES = {"path_scsi_addr": TMP[0], "path_devnode": TMP[1], "path_major_minor": TMP[2], "path_status": TMP[3]} elif( TMP > 2 ): ENTRIES = {"path_scsi_addr": TMP[0], "path_devnode": TMP[1], "path_major_minor": TMP[2]} else: ENTRIES = {"path_scsi_addr": TMP[0], "path_devnode": TMP[1]} if( PATH_GROUP_VALUES ): ENTRIES.update(PATH_GROUP_VALUES) MPATH['devicepath'].append(ENTRIES) if( len(MPATH) > 1 ): DEVICES.append(dict(MPATH)) #print "\n=============\n" #for I in range(len(DEVICES)): #print "\nDEVICES[" + str(I) + "] =" #for X in DEVICES[I]: #if ( "devicepath" == X ): #print " {0:12} = ".format(X) #for Y in DEVICES[I][X]: #print " ", Y #else: #print " {0:12} = {1}".format(X, DEVICES[I][X]) #print "\n" return DEVICES