def load_cfg(): global params import os, sys from shinken.log import logger from webui.config_parser import config_parser plugin_name = os.path.splitext(os.path.basename(__file__))[0] try: currentdir = os.path.dirname(os.path.realpath(__file__)) configuration_file = "%s/%s" % (currentdir, 'plugin.cfg') logger.debug("Plugin configuration file: %s" % (configuration_file)) scp = config_parser('#', '=') params = scp.parse_config(configuration_file) params['elts_per_page'] = int(params['elts_per_page']) logger.debug("WebUI plugin '%s', configuration loaded." % (plugin_name)) logger.debug("Plugin configuration, elts_per_page: %d" % (params['elts_per_page'])) return True except Exception, exp: logger.warning( "WebUI plugin '%s', configuration file (%s) not available: %s" % (plugin_name, configuration_file, str(exp))) return False
def load_cfg(): global params import os,sys from webui.config_parser import config_parser from shinken.log import logger plugin_name = os.path.splitext(os.path.basename(__file__))[0] try: currentdir = os.path.dirname(os.path.realpath(__file__)) configuration_file = "%s/%s" % (currentdir, 'plugin.cfg') logger.debug("Plugin configuration file: %s" % (configuration_file)) scp = config_parser('#', '=') params = scp.parse_config(configuration_file) logger.debug("WebUI plugin '%s', configuration loaded." % (plugin_name)) return True except Exception, exp: logger.warning("WebUI plugin '%s', configuration file (%s) not available: %s" % (plugin_name, configuration_file, str(exp))) return False
from shinken.log import logger ### Will be populated by the UI with it's own value app = None # Get plugin's parameters from configuration file params = {} import os,sys from webui.config_parser import config_parser plugin_name = os.path.splitext(os.path.basename(__file__))[0] try: currentdir = os.path.dirname(os.path.realpath(__file__)) configuration_file = "%s/%s" % (currentdir, 'plugin.cfg') logger.debug("Plugin configuration file: %s" % (configuration_file)) scp = config_parser('#', '=') params = scp.parse_config(configuration_file) params['default_Lat'] = float(params['default_Lat']) params['default_Lng'] = float(params['default_Lng']) params['default_zoom'] = int(params['default_zoom']) logger.debug("WebUI plugin '%s', configuration loaded." % (plugin_name)) logger.debug("Plugin configuration, default position: %s / %s" % (params['default_Lat'], params['default_Lng'])) logger.debug("Plugin configuration, default zoom level: %d" % (params['default_zoom'])) except Exception, exp: logger.warning("WebUI plugin '%s', configuration file (%s) not available: %s" % (plugin_name, configuration_file, str(exp))) def checkauth(): user = app.get_user_auth()
params['mongo_host'] = "localhost" params['mongo_port'] = 27017 params['db_name'] = "Logs" params['logs_limit'] = 500 params['logs_type'] = [] params['logs_hosts'] = [] params['logs_services'] = [] import os, sys from webui.config_parser import config_parser plugin_name = os.path.splitext(os.path.basename(__file__))[0] try: currentdir = os.path.dirname(os.path.realpath(__file__)) configuration_file = "%s/%s" % (currentdir, 'plugin.cfg') logger.debug("Plugin configuration file: %s" % (configuration_file)) scp = config_parser('#', '=') params = scp.parse_config(configuration_file) # mongo_host = params['mongo_host'] params['mongo_port'] = int(params['mongo_port']) params['logs_limit'] = int(params['logs_limit']) params['logs_type'] = [ item.strip() for item in params['logs_type'].split(',') ] params['logs_hosts'] = [ item.strip() for item in params['logs_hosts'].split(',') ] params['logs_services'] = [ item.strip() for item in params['logs_services'].split(',') ]