def kdumpEnabled(): FILE_OPEN = "crash.txt" CONTENT = {} Enabled = 0 if SUSE.packageInstalled('kdump'): Enabled += 1 if SUSE.packageInstalled('kexec-tools'): Enabled += 1 if Core.listSections(FILE_OPEN, CONTENT): for LINE in CONTENT: if "/etc/sysconfig/kdump" in CONTENT[LINE]: Enabled += 1 break if( Enabled >= 3 ): return True else: return False
def haeEnabled(): """ Determines if an HAE cluster is enabled on the node based on a corosysnc.conf file. Args: None Returns: True if enabled, False if disabled Example: if HAE.haeEnabled(): Core.updateStatus(Core.IGNORE, "HAE Cluster enabled") else: Core.updateStatus(Core.WARN, "HAE Cluster disabled") """ FILE_OPEN = 'ha.txt' CONTENT = {} if Core.listSections(FILE_OPEN, CONTENT): for LINE in CONTENT: # print CONTENT[LINE] if "corosync.conf" in CONTENT[LINE]: return True return False
def getConfigFiles(): """ Stores the non-XML Xen configuration files in list of dictionaries Args: None Returns: List of Dictionaries Example: Pending """ CONFIG_FILES = [] CONFIG_FILE_LIST = [] SECTION_LIST = {} MultiLine = re.compile("=\s*\[") # A line that has an =[ k IN_MULTI_LINE = False VALUES = [] if Core.listSections("xen.txt", SECTION_LIST): for LINE in SECTION_LIST: if SECTION_LIST[LINE].startswith("/etc/xen/vm/"): if '.xml' not in SECTION_LIST[LINE]: CONFIG_FILE_LIST.append(SECTION_LIST[LINE]) for CONFIG in CONFIG_FILE_LIST: #print "----------------------\nGetting", CONFIG CONTENT = [] if Core.getExactSection("xen.txt", CONFIG, CONTENT): CONFIG_VALUES = {} for LINE in CONTENT: LINE = LINE.strip() if( IN_MULTI_LINE ): if LINE.endswith("]"): VALUES.append(LINE) VALUE_STRING = ' '.join(VALUES) TMP = VALUE_STRING.split("=", 1) #print "TMP", TMP CONFIG_VALUES[TMP[0].strip()] = TMP[1].strip('"').strip() #print " CONFIG_VALUES", CONFIG_VALUES IN_MULTI_LINE = False VALUES = [] #prepare for new multiline value in config file else: VALUES.append(LINE) elif( MultiLine.search(LINE) and not LINE.endswith("]")): IN_MULTI_LINE = True VALUES.append(LINE) else: #assume single line entry TMP = LINE.split("=", 1) #print "TMP", TMP, "Length", len(TMP) if( len(TMP) != 2 ): #Invalid entry, assume the config file is invalid and ignore it. #print " Invalid config file" CONFIG_VALUES = {} break elif( "=" in TMP[1] and "]" not in TMP[1] ): #print " Invalid config file" CONFIG_VALUES = {} break else: CONFIG_VALUES[TMP[0].strip()] = TMP[1].strip('"').strip() #print " CONFIG_VALUES", CONFIG_VALUES if( CONFIG_VALUES): CONFIG_FILES.append(CONFIG_VALUES) #if( CONFIG_FILES ): #print "======\n" #for I in range(len(CONFIG_FILES)): #print I, "==", CONFIG_FILES[I], "\n" #else: #print "CONFIG_FILES empty" return CONFIG_FILES
OTHER_LINKS = "META_LINK_TID=https://www.suse.com/support/kb/doc/?id=7021112|META_LINK_DevInfo=https://github.com/systemd/systemd/pull/3753" Core.init(META_CLASS, META_CATEGORY, META_COMPONENT, PATTERN_ID, PRIMARY_LINK, OVERALL, OVERALL_INFO, OTHER_LINKS) ############################################################################## # Main Program Execution ############################################################################## FILE_OPEN = "systemd.txt" SECTIONS = {} CRIT_PERCENT = 90 WARN_PERCENT = 80 CRITICAL_SERVICES = {} WARNING_SERVICES = {} CONTENT = {} if Core.listSections(FILE_OPEN, CONTENT): for LINE in CONTENT: if "/systemctl show" in CONTENT[LINE]: SERVICE_NAME = CONTENT[LINE].split("'")[1] SERVICE_INFO = SUSE.getServiceDInfo(SERVICE_NAME) if ('TasksCurrent' in SERVICE_INFO.keys()): TASK_RATIO = int(SERVICE_INFO['TasksCurrent'])*100/int(SERVICE_INFO['TasksMax']) if( TASK_RATIO > 100 ): TASK_RATIO = 100 if( SERVICE_INFO['MemoryCurrent'] != SERVICE_INFO['TasksCurrent'] ): #Means TasksCurrent is set to unlimited if( TASK_RATIO >= CRIT_PERCENT ): CRITICAL_SERVICES[SERVICE_NAME] = 1 elif( TASK_RATIO >= WARN_PERCENT ): WARNING_SERVICES[SERVICE_NAME] = 1 # print "INFO: " + str(SERVICE_NAME) + ": " + str(TASK_RATIO) + "% " + str(SERVICE_INFO['TasksCurrent']) + "/" + str(SERVICE_INFO['TasksMax'])