def _add(func): global _actions logger.debug('decorator: add_action ' + action_name) if action_name in _actions: logger.fatal(action_name + ' already registered!') _actions[action_name] = func return func
def run(self): global _actions conf = config.getConfig() action = conf.require('action') if action not in _actions: logger.fatal('No function for action: ' + action) _actions[action](self)
def outputFormatter(perfList, **kwargs): ''' formats data as specified by outFormat passed in via **kwargs and returns a String. Supported keywords are: outFormat whitelistDict ''' outFormat = None whitelistDict = None debugString="" for key, value in kwargs.items(): debugString += "'%s'='%s';" % (str(key), str(value)) if (key == "outFormat"): outFormat = value elif(key == "whitelistDict"): whitelistDict = value else: l.error("Unsupported key '%s' with value '%s' passed. Exiting ..." % (key, value)) sys.exit(1) l.debug("outputFormatter kwargs: '%s'" % (debugString)) if outFormat.upper() == "DUMMY": formatFunction = fmt.DummyFormatter() elif outFormat.upper() == "SPLUNK": formatFunction = fmt.SplunkFormatter() elif outFormat.upper() == "INFLUX": formatFunction = fmt.InfluxFormatter() else: l.fatal("unknown output formatter: %s", outFormat) timeStamp = time.localtime() return formatFunction(perfList, timeStamp, whitelistDict)