def start(options): AMHostMonitoringService.set_ctrl_c_handler(ctrlHandler) if options.is_process: #Run as a normal process. Invoke the ServiceMain directly. stopHandler = StopHandler(AMHostMonitoringService._heventSvcStop) bind_signal_handlers(stopHandler) server_process_main(stopHandler) else: AMHostMonitoringService.Start()
def SvcDoRun(self): scmStatus = SvcStatusCallback(self) self.redirect_output_streams() stopHandler = StopHandler(AMHostMonitoringService._heventSvcStop) bind_signal_handlers(stopHandler) AMHostMonitoringService.set_ctrl_c_handler(ctrlHandler) server_process_main(stopHandler, scmStatus) pass
def testRetryFetch(self, url_open_mock): stop_handler = bind_signal_handlers() config = Configuration() application_metric_map = ApplicationMetricMap("host", "10.10.10.10") application_metric_map.clear() application_metric_map.put_metric("APP1", {"metric1": 1}, 1) emitter = Emitter(config, application_metric_map, stop_handler) emitter.RETRY_SLEEP_INTERVAL = .001 emitter.submit_metrics() self.assertEqual(url_open_mock.call_count, 3) self.assertUrlData(url_open_mock)
def testJavaHomeAvailableCheck(self, url_open_mock): url_open_mock.return_value = MagicMock() url_open_mock.return_value.getcode.return_value = 200 self.assertEqual(urllib2.urlopen(None, None).getcode(), 200) url_open_mock.reset_mock() stop_handler = bind_signal_handlers() config = Configuration() application_metric_map = ApplicationMetricMap("host", "10.10.10.10") application_metric_map.clear() application_metric_map.put_metric("APP1", {"metric1": 1}, 1) emitter = Emitter(config, application_metric_map, stop_handler) emitter.submit_metrics() self.assertEqual(url_open_mock.call_count, 1) self.assertUrlData(url_open_mock)
def main(argv=None): # Allow Ctrl-C stop_handler = bind_signal_handlers() server_process_main(stop_handler)