Ejemplo n.º 1
0
def getDefaults (check , warning , critical ) :
	if check == 'backends' : 
		# only whole digits and percentages allowed, an or separator is also allowed 
		return fac.getNumberPercentMix (warning, critical, '80%', '90%' )
	elif check == 'wals' :
		# -- warning 70%Max count
		# -- critical 80%Max count
		return fac.getNumberPercentMix (warning, critical, '70%', '80%' )
	elif check == 'autovacuum' or check == 'vacuum' or check == 'autoanalyze' or check == 'analyze':
		# -- warning = 1 week
		# -- critical = 2 weeks
		return fac.getTimeDefaults (warning, critical , '1wk', '2wks',0.8)
	elif check == 'table_bloat' or check == 'index_bloat' :
		#  Warning and/or Critical must be provided
		return fac.warningAndOrCriticalProvided (warning,critical,0.8)
	elif check == 'table_size' or check == 'index_size' or check == 'database_size' :
		# warning and/or critical value must be supplied
		return fac.warningAndOrCriticalProvided (warning,critical,0.5) 
	elif check == 'nonblocking' or check == 'blocking' :
		# --warning = 2min
		# critical = 3min
		return fac.getTimeDefaults (warning, critical , '1min', '2mins', 0.8) 
	elif check == 'checkpoints' :
		# warning and/or critical value must be supplied
		return None
	elif check == 'replica_lag' :
		# -- warning = 5 wal files
		# -- critical = 10 wal files 
		return fac.getNumberPercentMix (warning, critical, '5', '10' ) 
	elif check == 'connections' :
		return {'warning':'dummy', 'critical' :'dummy'}	
Ejemplo n.º 2
0
def getDefaults(check, warning, critical):
    if check == 'backends':
        # only whole digits and percentages allowed, an or separator is also allowed
        return fac.getNumberPercentMix(warning, critical, '80%', '85%')
    elif check == 'connections':
        return {'warning': 'dummy', 'critical': 'dummy'}
    elif check == 'autovacuum' or check == 'vacuum' or check == 'autoanalyze' or check == 'analyze':
        crit = critical if critical != None else '0min'
        warn = warning if warning != None else '1month'
        if fac.checkDigit(crit.split()) == True and fac.checkDigit(
                warn.split()) == True:
            return {'warning': warn, 'critical': crit}
        else:
            return None
    elif check == 'table_size' or check == 'index_size' or check == 'database_size':
        crit = critical if critical != None else '0kb'
        warn = warning
        if warn == None and crit != '0kb':
            warn = critical
        elif warn == None and crit == '0kb':
            return None

        if fac.checkDigit(crit.split()) == True and fac.checkDigit(
                warn.split()) == True:
            return {'warning': warn, 'critical': crit}
        else:
            return None
    elif check == 'table_bloat' or check == 'index_bloat':
        crit = critical if critical != None else '0kb'
        warn = warning if warning != None else '1gb'
        if fac.checkDigit(crit.split()) == True and fac.checkDigit(
                warn.split()) == True:
            return {'warning': warn, 'critical': crit}
        else:
            return None
    elif check == 'nonblocking' or check == 'blocking':
        crit = critical if critical != None else '0min'
        warn = warning if warning != None else '1min'
        if fac.checkDigit(crit.split()) == True and fac.checkDigit(
                warn.split()) == True:
            return {'warning': warn, 'critical': crit}
        else:
            return None
    elif check == 'replica_lag':
        return fac.getNumberPercentMix(warning, critical, '5', '10')
    else:
        if warning != None or critical != None:
            warn = warning
            crit = critical if critical != None else 0

            if crit != 0 and warning == None:
                warn = warning if warning != None else crit

            if check == 'wals':
                # -- warning and/or critical must be supplied
                if str(warn).isdigit() and str(crit).isdigit():
                    return {'warning': warn, 'critical': crit}
                else:
                    return None
            #elif check == 'checkpoints' :
            # warning and/or critical value must be supplied
            #	return None
        else:
            print("Warning and/or critical value required for this check")
            return None
Ejemplo n.º 3
0
def getDefaults (check , warning , critical ) :
	if check == 'backends' : 
		# only whole digits and percentages allowed, an or separator is also allowed 
		return fac.getNumberPercentMix (warning, critical, '80%', '85%' )
	elif check == 'connections' :
                return {'warning':'dummy', 'critical' :'dummy'}
	elif check == 'autovacuum' or check == 'vacuum' or check == 'autoanalyze' or check == 'analyze':
		crit = critical if critical != None else '0min'
		warn = warning if warning != None else '1month'
		if fac.checkDigit(crit.split()) == True and fac.checkDigit(warn.split()) == True :
			return {'warning' : warn , 'critical' : crit}
		else :
			return None		
	elif check == 'table_size' or check == 'index_size' or check == 'database_size' :
		crit = critical if critical != None else '0kb'
		warn = warning
		if warn == None and crit != '0kb' :
			warn = critical
		elif warn == None and crit == '0kb' :
			return None

		if fac.checkDigit(crit.split()) == True and fac.checkDigit(warn.split()) == True :
                        return {'warning' : warn , 'critical' : crit}
                else :
                        return None
	elif check == 'table_bloat' or check == 'index_bloat' :
		crit = critical if critical != None else '0kb'
		warn = warning if warning != None else '1gb'
		if fac.checkDigit(crit.split()) == True and fac.checkDigit(warn.split()) == True :
			return {'warning' : warn , 'critical' : crit}
		else :
                        return None
	elif check == 'nonblocking' or check == 'blocking' :
                crit = critical if critical != None else '0min'
                warn = warning if warning != None else '1min'
                if fac.checkDigit(crit.split()) == True and fac.checkDigit(warn.split()) == True :
                        return {'warning' : warn , 'critical' : crit}
                else :
                        return None  
	elif check == 'replica_lag' :
		return fac.getNumberPercentMix (warning, critical, '5', '10' ) 
	else :
		if warning != None or critical != None :
			warn = warning 
			crit = critical if critical != None else 0			


                        if crit != 0 and warning == None :
                        	warn = warning if warning != None else crit
			

			if check == 'wals' :
				# -- warning and/or critical must be supplied
				if str(warn).isdigit() and str(crit).isdigit()  :
					return {'warning' : warn , 'critical' : crit}
				else :
					return None  
			#elif check == 'checkpoints' :
				# warning and/or critical value must be supplied
			#	return None
		else :
			print ("Warning and/or critical value required for this check")
			return None