# Local Function Definitions
##############################################################################

def foundDuplicateErrors():
	fileOpen = "smt.txt"
	section = "smt-sync.log"
	content = {}
	DUP_ERROR = re.compile("SCCSync.*Duplicate entry.*/SCCSync.pm line 725", re.IGNORECASE)
	if Core.getSection(fileOpen, section, content):
		for line in content:
			if DUP_ERROR.search(content[line]):
				return True
	return False

##############################################################################
# Main Program Execution
##############################################################################

SMT = SUSE.getServiceInfo('smt')
if( SMT['OnForRunLevel'] or SMT['Running'] > 0 ):
	if foundDuplicateErrors():
		Core.updateStatus(Core.REC, "Detected inconsequential duplicate SCCSync.pm line 725 errors, run smt-repos to confirm functionality.")
	else:
		Core.updateStatus(Core.IGNORE, "No duplicate SCCSync.pm line 725 errors found, AVOIDED")
else:
	Core.updateStatus(Core.ERROR, "ERROR: SMT not enable or running, skipping")

Core.printPatternResults()


def guiModeActive():
	Service = SUSE.getServiceInfo('X')
	if( Service['Running'] > 0 ):
		return True
	return False
					return True
			elif "[global]" in content[line].lower():
				GLOBAL = True
	return False

##############################################################################
# Main Program Execution
##############################################################################

SERVER = SUSE.getHostInfo()
if "s390" in SERVER['Architecture'].lower():
	if( SERVER['DistroVersion'] == 11 and SERVER['DistroPatchLevel'] == 3 ):
		if( sambaMmapFixed() ):
			Core.updateStatus(Core.IGNORE, "Issue AVOIDED, Samba mmap set to no")
		else:
			SERVICE = SUSE.getServiceInfo('smb')
			if( SERVICE['OnForRunLevel'] ):
				if( SERVICE['Running'] < 1 ):
					Core.updateStatus(Core.CRIT, "Samba not running due to incorrect mmap setting in [global] smb.conf")
				else:
					Core.updateStatus(Core.CRIT, "Samba may stop running due to incorrect mmap setting in [global] smb.conf")
			else:
				Core.updateStatus(Core.WARN, "Samba may fail if enabled due to incorrect mmap setting in [global] smb.conf")
	else: 
		Core.updateStatus(Core.ERROR, "Outside the distribution and patch level scope")
else:
	Core.updateStatus(Core.ERROR, "Outside the architecture scope")

Core.printPatternResults()

		for line in content:
			if regresults.search(line):
				return True
	return False

##############################################################################
# Main Program Execution
##############################################################################

RPM_NAME = 'ntp'
RPM_VERSION = '4.2.8'
if( SUSE.packageInstalled(RPM_NAME) ):
	INSTALLED_VERSION = SUSE.compareRPM(RPM_NAME, RPM_VERSION)
	if( INSTALLED_VERSION == 0 ):
		if ( ntpchrootinfo() ):
			SERVICE_INFO = SUSE.getServiceInfo(RPM_NAME)
			if( SERVICE_INFO['OnForRunLevel'] ): # SLES11 SP4 specific
				if ( ntpdnsinfo() ):
					Core.updateStatus(Core.CRIT, "NTP issue resolving DNS detected, disable NTP chroot to resolve.")
				else:
					Core.updateStatus(Core.IGNORE, "Bug not applicate when NTP isn't using DNS.")
			else:
				Core.updateStatus(Core.IGNORE, "Bug not applicable when NTP is not in use.")
		else:
			Core.updateStatus(Core.IGNORE, "Bug not applicable when chroot is disabled.")
	else:
		Core.updateStatus(Core.IGNORE, "Bug doesn't exist in " + RPM_VERSION)
else:
	Core.updateStatus(Core.ERROR, "ERROR: " + RPM_NAME + " not installed")

Core.printPatternResults()
RPM_NAME = 'apache2'
if( SERVER['DistroVersion'] == 10 and SERVER['DistroPatchLevel'] == 4 ):
	RPM_VERSION = '2.2.3-16.50.1'
	IN_SCOPE = True
elif( SERVER['DistroVersion'] == 10 and SERVER['DistroPatchLevel'] == 3 ):
	RPM_VERSION = '2.2.3-16.32.51.2'
	IN_SCOPE = True

if( IN_SCOPE ):
	SERVICE = 'apache2'
	if( SUSE.packageInstalled(RPM_NAME) ):
		INSTALLED_VERSION = SUSE.compareRPM(RPM_NAME, RPM_VERSION)
		if( INSTALLED_VERSION == 0 ):
			if( errorFound() ):
				Core.updateStatus(Core.CRIT, "Detected Apache failed start issue log errors, update server to apply " + RPM_NAME + " fixes")
			else:
				SERVICE_INFO = SUSE.getServiceInfo(SERVICE)
				if( SERVICE_INFO['OnForRunLevel'] ):
					Core.updateStatus(Core.CRIT, "Detected Apache failed start issue, update server to apply " + RPM_NAME + " fixes")
				else:
					Core.updateStatus(Core.WARN, "Apache mail fail to start if used, update server to apply " + RPM_NAME + " fixes")
		else:
			Core.updateStatus(Core.IGNORE, "Apache failed start issue AVOIDED")
	else:
		Core.updateStatus(Core.ERROR, "ERROR: " + RPM_NAME + " not installed")
else:
	Core.updateStatus(Core.ERROR, "Outside Distribution Version and Patch Level scope, Skipping")

Core.printPatternResults()