Example #1
0
	def __test_monitor_plugin(self, name):

		log.test("monitor plugin: %s" % name)
		log.indent()

		# initialization

		log.test("initialization")
		try:
			exec "from %s.%s import _plugin" % (self.mp_dir, name)
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return None

		log.result()

		# init()

		log.test("call init()")
		try:
			_plugin.init(self.config)
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return None
		log.result()

		# getLoad()

		log.test("call getLoad()")
		try:
			load = _plugin.getLoad()
			if load == None:
				raise Exception("Plugin returned None as a result.")
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return None
		log.result()

		# cleanup()

		log.test("call cleanup()")
		try:
			_plugin.cleanup()
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return load

		log.result()

		log.unindent()
		return load
Example #2
0
	def __test_tuning_plugin(self, name, load):

		log.test("tuning plugin: %s" % name)
		log.indent()

		# initialization

		log.test("initialization")
		try:
			exec "from %s.%s import _plugin" % (self.tp_dir, name)
		except Exception as e:
			log.result_e()
			log.unindent()
			return False
		log.result()

		# init()

		log.test("call init()")
		try:
			_plugin.init(self.config)
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return False
		log.result()

		# setTuning()

		log.test("call setTuning()")

		if load == None:
			log.info("no data from monitor plugin available")
		else:
			try:
				_plugin.setTuning(load)
			except Exception as e:
				log.result_e(e)
				log.unindent()
				return False
			log.result()

		# cleanup()

		log.test("call cleanup()")
		try:
			_plugin.cleanup()
		except Exception as e:
			log.result_e(e)
			log.unindent()
			return False
		log.result()

		log.unindent()
		return True
Example #3
0
	def __check_plugins(self):

		monitorplugins = self.__get_plugins_from_dir(self.mp_dir)
		tuningplugins = self.__get_plugins_from_dir(self.tp_dir)

		# check plugins availability

		self.__check_sibling_plugins(monitorplugins, tuningplugins)

		# monitor plugins test

		log.test("monitor plugins test")
		if len(monitorplugins) == 0:
			log.result("no plugins found")

		log.indent()

		monitor_results = {}
		for mp in monitorplugins:
			load = self.__test_monitor_plugin(mp)
			monitor_results[mp] = load

		log.unindent()

		# tuning plugins test

		log.test("tunning plugins test")

		if len(tuningplugins) == 0:
			log.result("no plugins found")

		log.indent()

		for tp in tuningplugins:
			try:
				load = monitor_results[tp]
			except:
				load = None
			self.__test_tuning_plugin(tp, load)

		log.unindent()
Example #4
0
	def __check_state(self, profile, tuned_running, ktune_running):
		is_ok = True

		if profile == None:
			self.tuned_adm.run(["off"])
			log.test("checking state: off")
		else:
			self.tuned_adm.run(["profile", profile])
			log.test("checking state: %s" % profile)

		log.indent()

		# services status

		log.test("service 'tuned'")
		if self.__service_running("tuned") == tuned_running:
			log.result()
		else:
			is_ok = False
			log.result("should %s" % ( "be running" if tuned_running else "not be running" ))

		log.test("service 'ktune'")
		if self.__service_running("ktune") == ktune_running:
			log.result()
		else:
			is_ok = False
			log.result("should %s" % ( "be running" if ktune_running else "not be running" ))

		# init scripts

		log.test("checking 'tuned' initscript")
		if self.__initscript_enabled("tuned") == tuned_running:
			log.result()
		else:
			is_ok = False
			log.result("%s be enabled" % ( "should" if tuned_running else "should not" ))

		log.test("checking 'ktune' initscript")
		if self.__initscript_enabled("ktune") == ktune_running:
			log.result()
		else:
			is_ok = False
			log.result("%s be enabled" % ( "should" if ktune_running else "should not" ))

		# config files

		want_tunedadm_sh = False
		want_tunedadm_conf = False

		if profile != None:
			want_tunedadm_sh = os.path.exists("%s/%s/ktune.sh" % (self.profiles_fake_dir, profile))
			want_tunedadm_conf = os.path.exists("%s/%s/sysctl.ktune" % (self.profiles_fake_dir, profile))

		log.test("checking '/etc/ktune.d/tunedadm.sh'")
		if want_tunedadm_sh == os.path.exists("/etc/ktune.d/tunedadm.sh"):
			log.result()
		else:
			is_ok = False
			log.result("file should %s" % ( "exist" if want_tunedadm_sh else "not exist" ))

		log.test("checking '/etc/ktune.d/tunedadm.conf'")
		if want_tunedadm_conf == os.path.exists("/etc/ktune.d/tunedadm.conf"):
			log.result()
		else:
			is_ok = False
			log.result("file should %s" % ( "exist" if want_tunedadm_conf else "not exist" ))

		log.unindent()
		return is_ok