def main(): """ Entry point when called as a script. """ if len(sys.argv) != 4: sys.exit("usage: ./mock_plugin.py config topic message") conf = config.from_env(constants.CONFIG_ENV) topic = sys.argv[2] message = sys.argv[3] broker = conf.get("zmq.mauka.plugin.pub.interface") produce(broker, topic, message)
def setUp(self): self.config = config.from_env(constants.CONFIG_ENV) self.noise_floor = float( self.config["plugins.TransientPlugin.noise.floor"]) self.filter_order = int( self.config["plugins.MakaiEventPlugin.filterOrder"]) self.cutoff_frequency = float( self.config["plugins.MakaiEventPlugin.cutoffFrequency"]) self.configs = { "noise_floor": float(self.config["plugins.TransientPlugin.noise.floor"]), "filter_cutoff_frequency": float(self.config["plugins.MakaiEventPlugin.cutoffFrequency"]), "filter_order": float(self.config["plugins.MakaiEventPlugin.filterOrder"]), "oscillatory_min_cycles": int(self.config["plugins.TransientPlugin.oscillatory.min.cycles"]), "oscillatory_low_freq_max": float( self. config["plugins.TransientPlugin.oscillatory.low.freq.max.hz"]), "oscillatory_med_freq_max": float( self. config["plugins.TransientPlugin.oscillatory.med.freq.max.hz"]), "oscillatory_high_freq_max": float(self.config[ "plugins.TransientPlugin.oscillatory.high.freq.max.hz"]), "arc_zero_xing_threshold": int(self.config[ "plugins.TransientPlugin.arcing.zero.crossing.threshold"]), "max_lull_ms": float(self.config["plugins.TransientPlugin.max.lull.ms"]), "max_std_periodic_notching": float(self.config[ "plugins.TransientPlugin.max.periodic.notching.std.dev"]), "auto_corr_thresh_periodicity": float( self. config["plugins.TransientPlugin.auto.corr.thresh.periodicity"]) }
if cmd == "exit": logger.info("Exiting mauka-cli") sys.exit(0) if cmd == "completions": zmq_request_socket.send_string("completions") completions = zmq_request_socket.recv_string() vocabulary = set(completions.split(",")) readline.set_completer(make_completer(vocabulary)) logger.debug(ok("Completions updated")) continue zmq_request_socket.send_string(cmd.strip()) logger.debug(zmq_request_socket.recv_string()) except (EOFError, KeyboardInterrupt): logger.info("Exiting mauka-cli") sys.exit(0) if __name__ == "__main__": # Entry point to plugin manager repl/cli logger.info("Starting OpqMauka CLI") if len(sys.argv) <= 1: logger.error("Configuration file not supplied") logger.error("usage: python3 -m plugins.manager mauka.config.json") exit(0) config_path = sys.argv[1] configuration = config.from_env(constants.CONFIG_ENV) run_cli(configuration)
def main(): """ Entry point to OPQ Mauka. """ logger.info("Starting OpqMauka") conf = config.from_env(constants.CONFIG_ENV) bootstrap(conf) plugin_manager = services.plugin_manager.PluginManager(conf) plugin_manager.register_plugin( plugins.box_optimization_plugin.BoxOptimizationPlugin) plugin_manager.register_plugin( plugins.frequency_variation_plugin.FrequencyVariationPlugin) plugin_manager.register_plugin( plugins.ieee1159_voltage_plugin.Ieee1159VoltagePlugin) plugin_manager.register_plugin(plugins.itic_plugin.IticPlugin) plugin_manager.register_plugin(plugins.laha_gc_plugin.LahaGcPlugin) plugin_manager.register_plugin(plugins.makai_event_plugin.MakaiEventPlugin) plugin_manager.register_plugin(plugins.outage_plugin.OutagePlugin) plugin_manager.register_plugin(plugins.semi_f47_plugin.SemiF47Plugin) plugin_manager.register_plugin(plugins.status_plugin.StatusPlugin) plugin_manager.register_plugin( plugins.system_stats_plugin.SystemStatsPlugin) plugin_manager.register_plugin(plugins.thd_plugin.ThdPlugin) plugin_manager.register_plugin( plugins.threshold_optimization_plugin.ThresholdOptimizationPlugin) plugin_manager.register_plugin(plugins.transient_plugin.TransientPlugin) plugin_manager.register_plugin(plugins.trigger_plugin.TriggerPlugin) broker_process = None makai_bridge_event_process = None if conf.get("mauka.startPubSubBroker"): broker_process = services.brokers.start_mauka_pub_sub_broker(conf) if conf.get("mauka.startEventBroker"): makai_bridge_event_process = services.brokers.start_makai_event_bridge( conf) incident_id_process = services.brokers.start_incident_id_service(conf) # start-stop-daemon sends a SIGTERM, we need to handle it to gracefully shutdown mauka def sigterm_handler(signum, frame): """ Custom sigterm handler. :param signum: Number of the signal. :param frame: Frame of signal. """ logger.info("Received exit signal %s %s", str(signum), str(frame)) if conf.get("mauka.startPlugins"): plugin_manager.clean_exit() signal.signal(signal.SIGTERM, sigterm_handler) signal.signal(signal.SIGINT, sigterm_handler) try: if conf.get("mauka.startPlugins"): plugin_manager.run_all_plugins() plugin_manager.start_tcp_server() if broker_process is not None: logger.info("Killing broker process") broker_process.terminate() if makai_bridge_event_process is not None: logger.info("Killing makai event bridge process") makai_bridge_event_process.terminate() if incident_id_process is not None: logger.info("Killing incident id process") incident_id_process.terminate() logger.info("Goodbye") sys.exit(0) except KeyboardInterrupt: sigterm_handler(None, None)
def setUp(self): self.freq_ref = constants.CYCLES_PER_SECOND self.config = config.from_env(constants.CONFIG_ENV) self.window_size = int(self.config["plugins.MakaiEventPlugin.frequencyWindowCycles"] * constants.SAMPLES_PER_CYCLE) self.downsample_factor = int(self.config["plugins.MakaiEventPlugin.frequencyDownSampleRate"])