예제 #1
0
        public void Performance_counter_consists_of_a_single_value()
        {
            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName));

            monitor.GetValues().Should().HaveCount(1);
        }
예제 #2
0
        public void Health_check_consists_of_a_single_monitor()
        {
            var healthCheck = new HealthCheck(MonitorConfig.Build("Test"), () => true);

            healthCheck.GetAllMonitors().Should().HaveCount(1);
            healthCheck.GetAllMonitors().Single().Should().BeSameAs(healthCheck);
        }
예제 #3
0
        public MonitorConfig GetBackMonitor(int recordid)
        {
            Predicate <MonitorConfig> predicate4 = null;
            Predicate <MonitorConfig> match      = null;

            lock (this)
            {
                Predicate <MonitorConfig> predicate3 = null;
                Predicate <MonitorConfig> predicate2 = null;
                if (match == null)
                {
                    if (predicate4 == null)
                    {
                        predicate4 = x => x.RecordId == recordid;
                    }
                    match = predicate4;
                }
                MonitorConfig cfg = this._Monitors.Find(match);
                if (cfg != null)
                {
                    if (predicate2 == null)
                    {
                        if (predicate3 == null)
                        {
                            predicate3 = x => (((x.Line != cfg.Line) && (x.Status == "ok")) && (x.DomainId == cfg.DomainId)) && (x.Subdomain == cfg.Subdomain);
                        }
                        predicate2 = predicate3;
                    }
                    return(this._Monitors.Find(predicate2));
                }
                return(null);
            }
        }
예제 #4
0
        public static void MonitorThead()
        {
            MonitorConfig cfg = System.Configuration.ConfigurationManager.GetSection("winSrvMonitor") as MonitorConfig;

            while (!bStop)
            {
                foreach (var srv in cfg.MonitorServerList)
                {
                    if (srv.EnableMonitor)
                    {
                        // 如果需要监控,则发现停止的时候将其启动
                        if (srv.StartServer())
                        {
                            continue;
                        }
                    }

                    if (srv.EnableRestart)
                    {
                        if (srv.IsRestartTime())
                        {
                            srv.RestartServer();
                        }
                    }
                }

                Thread.Sleep(1000 * 60);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MonitorConfigDetailForm"/> form.
        /// </summary>
        /// <param name="monitorConfig">The location.</param>
        public MonitorConfigDetailForm(MonitorConfig monitorConfig)
        {
            InitializeComponent();
            serverComboBox.Initialize(new List <string>()
            {
                "FileServer", "Solution"
            });
            _monitorConfig            = monitorConfig;
            _errorProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink;

            monitorType_ComboBox.DataSource    = GetMonitorTypes();
            monitorType_ComboBox.SelectedIndex = -1;

            //Wire up events
            serverComboBox.Validating                 += serverComboBox_Validating;
            monitorType_ComboBox.Validating           += monitorType_ComboBox_Validating;
            monitorType_ComboBox.SelectedIndexChanged += monitorType_ComboBox_SelectedIndexChanged;

            // Initialize controls with data from MonitorConfig
            ServerInfo server = ConfigurationServices.AssetInventory.GetServers().FirstOrDefault(n => n.HostName == _monitorConfig.ServerHostName);

            if (server != null)
            {
                serverComboBox.SelectedServer = server;
            }

            // If this is a "create new" operation, the monitor type will be blank
            if (string.IsNullOrEmpty(monitorConfig.MonitorType) == false)
            {
                monitorType_ComboBox.SelectedValue = _monitorConfig.MonitorType;
            }

            UserInterfaceStyler.Configure(this, FormStyle.SizeableDialog);
        }
예제 #6
0
            public void ShouldBeAbleToPullExistingInfoFromCache()
            {
                var monitorConfig = new MonitorConfig { Name = "Test" };
                var reduceLevels = new List<ReduceLevel>();

                var connection = new Mock<IDbConnection>();
                var connectionInstance = connection.Object;

                var storageCommands = new Mock<IStorageCommands>();
                storageCommands.Setup(x => x.CreateConfigAndReduceLevels(monitorConfig, reduceLevels, connectionInstance));

                var setupSystemTables = new Mock<ISetupSystemTables>();
                setupSystemTables.Setup(x => x.ValidateAndCreateDataTables(connectionInstance)).Verifiable();

                var monitorConfigsDictionary = new ConcurrentDictionary<string, MonitorConfig>();

                var cache = new Mock<IDataCache>();
                cache.SetupGet(x => x.MonitorConfigs).Returns(monitorConfigsDictionary).Verifiable();

                var storageFactory = new Mock<IStorageFactory>();
                storageFactory.Setup(x => x.CreateConnection()).Returns(connectionInstance).Verifiable();

                var settings = BuildSettings();

                var defaults = new SetupMonitorConfig(storageCommands.Object, setupSystemTables.Object, cache.Object, storageFactory.Object, settings.Object);
                defaults.CreateDefaultReduceLevels(monitorConfig, reduceLevels);

                Assert.Equal(1, monitorConfigsDictionary.Count);
                Assert.True(monitorConfigsDictionary.ContainsKey("Test"));

                storageCommands.VerifyAll();
                setupSystemTables.VerifyAll();
                storageFactory.VerifyAll();
                cache.VerifyAll();
            }
예제 #7
0
        public void Do_not_send_data_and_reset_when_nothing_registered()
        {
            var timer = new TimerAbsentFilter(new Timer(MonitorConfig.Build("Test")));

            timer.GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((ITimer)timer).GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #8
0
        public void Do_not_send_data_when_nothing_registered()
        {
            var counter = new CounterAbsentFilter <long>(new Counter(MonitorConfig.Build("Test")));

            counter.GetValues().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((ICounter <long>)counter).GetValues().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #9
0
        public void Value_is_called_value()
        {
            var monitor = new PerformanceCounterMonitor(MonitorConfig.Build("Test"),
                                                        PerformanceCounterConfig.Build("Process", "Private Bytes", Process.GetCurrentProcess().ProcessName));

            monitor.GetValues().Single().Name.Should().Be("value");
        }
예제 #10
0
        public void Consists_of_a_single_monitor()
        {
            var gauge = new MinGauge(MonitorConfig.Build("Test"));

            gauge.GetAllMonitors().Should().HaveCount(1);
            gauge.GetAllMonitors().Single().Should().BeSameAs(gauge);
        }
예제 #11
0
        private void remove_ToolStripButton_Click(object sender, EventArgs e)
        {
            if (monitor_DataGridView.SelectedRows.Count > 0)
            {
                DataRowView   dataItem        = (DataRowView)monitor_DataGridView.SelectedRows[0].DataBoundItem;
                Guid          monitorConfigId = (Guid)dataItem[MonitorConfigColumn.MonitorConfigId];
                MonitorConfig configItem      = _context.MonitorConfigs.FirstOrDefault(n => n.MonitorConfigId == monitorConfigId);

                DialogResult dialogResult = MessageBox.Show
                                            (
                    $"Delete {configItem.MonitorType} monitor configuration item on {configItem.ServerHostName}?",
                    "Delete Monitor Configuration Item",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question
                                            );

                if (DialogResult.Yes == dialogResult)
                {
                    _context.MonitorConfigs.Remove(configItem);
                    _context.SaveChanges();
                    RefreshServerService(configItem.ServerHostName);
                    RefreshData();
                }
            }
        }
예제 #12
0
        public MarketIncrementalProcessor(ChannelUMDFState state, ChannelUMDFConfig config, MonitorConfig monitorConfig) :
            base(config.MDIncrementalHost, config.MDIncrementalPorta, config.TemplateFile, config.ChannelID, config.LocalInterfaceAddress)
        {
            this.channelConfig = config;
            this.channelState  = state;
            this.processorType = ProcessorType.MarketIncremental;
            this.monitorConfig = monitorConfig;

            ProcessamentoMensagensEnabled    = false;
            ProcessamentoMensagensLockObject = new object();
            ReplayLockObject = new object();

            logger = LogManager.GetLogger("MarketIncrementalProcessor-" + config.ChannelID);

            MDSUtils.AddAppender("MarketIncrementalProcessor-" + config.ChannelID, logger.Logger);

            //if (int.Parse(channelConfig.ChannelID) <= 10)
            //    tcpReplayBMF = TCPReplayBMF.GetInstance(this, channelConfig, config.TemplateFile, qUdpPkt, ReplayLockObject);
            //else
            //    tcpReplayBovespa = new TCPReplayBovespa(this, channelConfig, config.TemplateFile, qUdpPkt, ReplayLockObject);

            //if (channelConfig.IsPuma)
            //    tcpReplayBMF = TCPReplayBMF.GetInstance(this, channelConfig, config.TemplateFile, qUdpPktReplay, ReplayLockObject);
            //else
            //    tcpReplayBovespa = new TCPReplayBovespa(this, channelConfig, config.TemplateFile, qUdpPktReplay, ReplayLockObject);

            fixInitiator = new FixInitiator(this, channelConfig, config.TemplateFile, qUdpPktReplay, ReplayLockObject);
        }
예제 #13
0
 public LogStream(IHubContext <MonitorHub> context, MonitorConfig config)
 {
     this.context  = context;
     this.config   = config;
     cs            = ClientSingleton.Create(config.Hostname, config.SymmetricKey);
     cs.OnReceive += Cs_OnReceive;
 }
예제 #14
0
        public void Configs_with_same_name_and_tags_are_equal()
        {
            var config1 = new MonitorConfig("Test", new[] { new Tag("tag", "value") });
            var config2 = new MonitorConfig("Test", new[] { new Tag("tag", "value") });

            config1.Should().Be(config2);
        }
예제 #15
0
        public void Configs_with_same_name_and_tags_should_have_same_hash_code()
        {
            var config1 = new MonitorConfig("Test", new[] { new Tag("tag", "value") });
            var config2 = new MonitorConfig("Test", new[] { new Tag("tag", "value") });

            config1.GetHashCode().Should().Be(config2.GetHashCode());
        }
예제 #16
0
 private void SendProjCmd(MonitorConfig mc, ProjectorCommand pc)
 {
     try
     {
         //send the command
         if (mc.m_displayconnectionenabled == false)
         {
             DebugLogger.Instance().LogWarning("Display connection not enabled");
             return;
         }
         //Find the driver
         DeviceDriver driver = UVDLPApp.Instance().m_deviceinterface.FindProjDriverByComName(mc.m_displayconnection.comname);
         if (driver == null)
         {
             DebugLogger.Instance().LogError("Driver not found");
             return;
         }
         if (driver.Connected == true)
         {
             //send the command.
             driver.Write(pc.GetBytes(), pc.GetBytes().Length);
         }
         else
         {
             DebugLogger.Instance().LogError("Driver not connected");
             return;
         }
     }
     catch (Exception ex)
     {
         DebugLogger.Instance().LogError(ex);
     }
 }
 public static Profile BuildProfile(
     string id,
     string name,
     string type,
     string location,
     Dictionary <string, string> tags,
     string profileStatus,
     string trafficRoutingMethod,
     string trafficViewEnrollmentStatus,
     long?maxReturn,
     DnsConfig dnsConfig,
     MonitorConfig monitorConfig,
     Endpoint[] endpoints)
 {
     return(new Profile(
                id: id,
                name: name,
                type: type,
                location: location,
                tags: tags,
                profileStatus: profileStatus,
                trafficRoutingMethod: trafficRoutingMethod,
                trafficViewEnrollmentStatus: trafficViewEnrollmentStatus,
                maxReturn: maxReturn,
                dnsConfig: dnsConfig,
                monitorConfig: monitorConfig,
                endpoints: endpoints));
 }
예제 #18
0
        public void Consists_of_a_single_monitor()
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.GetAllMonitors().Should().HaveCount(1);
            counter.GetAllMonitors().Single().Should().BeSameAs(counter);
        }
        private void UpdateProjConnected()
        {
            try
            {
                int idx = cmbDisplays.SelectedIndex;
                if (idx == -1)
                {
                    return;
                }
                MonitorConfig mc = UVDLPApp.Instance().m_printerinfo.m_lstMonitorconfigs[idx];
                //magic needs to happen here with the serial connection to the monitor

                /*
                 * if (UVDLPApp.Instance().m_deviceinterface.ConnectedProjector)
                 * {
                 *  cmdConnect.Text = "Disconnect Monitor";
                 * }
                 * else
                 * {
                 *  cmdConnect.Text = "Connect Monitor";
                 * }
                 */
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
        }
예제 #20
0
        public void Do_not_send_data_and_reset_when_nothing_registered()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
            ((IGauge <long>)gauge).GetValuesAndReset().ShouldBeEquivalentTo(new IMeasurement[0]);
        }
예제 #21
0
 public MonitorHub(MonitorConfig config, ILogStream logStream)
 {
     this.config        = config;
     this.logStream     = logStream;
     moduleSubcriptions = new HashSet <string>();
     appSubscriptions   = new HashSet <string>();
 }
예제 #22
0
        public void Send_data_when_Reset()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Reset();

            gauge.GetValues().Single();
        }
예제 #23
0
        public void Config_with_multiple_tags_in_one_call_has_all_the_tags_specified()
        {
            var expectedTags = new[] { new Tag("key", "value"), new Tag("key2", "value") };

            var config = MonitorConfig.Build("Anything").WithTags(expectedTags);

            config.Tags.Should().BeEquivalentTo(expectedTags);
        }
예제 #24
0
        public void Incrementing_the_counters_works_as_expected(int amount)
        {
            var counter = new CumulativeCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValues().First().Value.Should().Be(amount);
        }
예제 #25
0
 public int Save(MonitorConfig config)
 {
     if (config.id > 0)
     {
         return(_mconfigDao.Update(config));
     }
     return(_mconfigDao.Insert(config));
 }
예제 #26
0
        public void Send_data_when_registered(int someValue)
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Set(someValue);

            gauge.GetValues().Single();
        }
예제 #27
0
        public void Send_data_and_reset_when_registered()
        {
            var gauge = new GaugeAbsentFilter <long>(new LongGauge(MonitorConfig.Build("Test")));

            gauge.Set(33);

            gauge.GetValuesAndReset().Single();
        }
예제 #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LANFaxMonitor"/> class.
 /// </summary>
 /// <param name="monitorConfig">The monitor configuration.</param>
 public LANFaxMonitor(MonitorConfig monitorConfig)
     : base(monitorConfig, new string[] { "*.tif" })
 {
     // For the LAN Fax monitoring, we are always interested in the HPF metadata
     // file that is created. Without it, we cannot process the file correctly.
     Configuration.LookForMetadataFile   = true;
     Configuration.MetadataFileExtension = "hpf";
 }
예제 #29
0
        public void Incrementing_the_counters_works_as_expected(int amount)
        {
            var counter = new BasicCounter(MonitorConfig.Build("Test"));

            counter.Increment(amount);

            counter.GetValue().Should().Be(amount);
        }
 public CounterServoMetric(MonitorConfig config, HystrixServoMetricsPublisherAbstract publisher, Func <T> getValue)
     : base(config
            .withAdditionalTag(DataSourceType.COUNTER)
            .withAdditionalTag(publisher.ServoTypeTag)
            .withAdditionalTag(publisher.ServoInstanceTag))
 {
     this.getValue = getValue;
 }
 public InformationalServoMetric(MonitorConfig config, HystrixServoMetricsPublisherAbstract publisher, Func <T> getValue)
     : base(config
            .withAdditionalTag(DataSourceType.INFORMATIONAL)
            .withAdditionalTag(publisher.ServoTypeTag)
            .withAdditionalTag(publisher.ServoInstanceTag))
 {
     this.getValue = getValue;
 }
예제 #32
0
        private static TestData PopulateTestData(bool populateAll)
        {
            //Define Defaults
            var defineDefaults = new Mock<ISetupMonitorConfig>();
            defineDefaults.Setup(x => x.CreateDefaultReduceLevels(It.IsAny<MonitorConfig>(), It.IsAny<List<ReduceLevel>>(), It.IsAny<IDbConnection>())).Verifiable();

            //Cache
            var monitorInfoDictionary = new ConcurrentDictionary<string, MonitorInfo>();
            var monitorConfigsDictionary = new ConcurrentDictionary<string, MonitorConfig>();

            var reductionLevel = new ReduceLevel { Resolution = 1000 };
            var monitorConfig = new MonitorConfig { Name = "Test", ReduceLevels = new List<ReduceLevel> { reductionLevel } };
            var monitorInfo = new MonitorInfo { TablesCreated = false, MonitorRecords = new List<MonitorRecord<double>> { new MonitorRecord<double>(DateTime.Now, 5) }, MonitorConfig = monitorConfig };

            monitorInfoDictionary.TryAdd("Test", monitorInfo);
            monitorConfigsDictionary.TryAdd("Test", monitorConfig);

            reductionLevel = new ReduceLevel { Resolution = 1000 };
            monitorConfig = new MonitorConfig { Name = "Jester", ReduceLevels = new List<ReduceLevel> { reductionLevel } };
            monitorInfo = new MonitorInfo { TablesCreated = false, MonitorRecords = new List<MonitorRecord<double>> { new MonitorRecord<double>(DateTime.Now, 5) }, MonitorConfig = monitorConfig };

            monitorInfoDictionary.TryAdd("Jester", monitorInfo);
            monitorConfigsDictionary.TryAdd("Jester", monitorConfig);

            var cache = new Mock<IDataCache>();
            cache.SetupGet(x => x.MonitorInfo).Returns(monitorInfoDictionary);
            cache.SetupGet(x => x.MonitorConfigs).Returns(monitorConfigsDictionary);

            //Storage
            var storage = new Mock<IStorageCommands>();
            storage.Setup(x => x.Insert(It.IsAny<string>(), It.IsAny<IEnumerable<MonitorRecord<double>>>(), It.IsAny<IDbConnection>(), It.IsAny<IDbTransaction>())).Verifiable();

            //Logic
            var logic = new Mock<IRecordFlushUpdate>();
            logic.Setup(x => x.UpdateExisting(It.IsAny<string>(), It.IsAny<SortedDictionary<long, MonitorRecord<double>>>(), It.IsAny<IDbConnection>(), It.IsAny<IDbTransaction>())).Verifiable();

            //Db Provider
            var transaction = new Mock<IDbTransaction>();
            transaction.SetupGet(x => x.IsolationLevel).Returns(IsolationLevel.Serializable).Verifiable();
            transaction.Setup(x => x.Rollback()).Verifiable();
            transaction.Setup(x => x.Commit()).Verifiable();

            var connection = new Mock<IDbConnection>();
            connection.Setup(x => x.Open()).Verifiable();
            connection.Setup(x => x.BeginTransaction()).Returns(transaction.Object).Verifiable();
            connection.Setup(x => x.BeginTransaction(It.IsAny<IsolationLevel>())).Returns(transaction.Object).Verifiable();

            var dbProviderFactory = new Mock<IStorageFactory>();
            dbProviderFactory.Setup(x => x.CreateConnection()).Returns(connection.Object).Verifiable();

            //Settings
            var settings = BuildSettings();

            return new TestData { Settings = settings, Cache = cache, DbProviderFactory = dbProviderFactory, Logic = logic, Storage = storage, Transaction = transaction, Connection = connection, DefineDefaults = defineDefaults };
        }
예제 #33
0
 public NodeHeartBeatMonitor(MonitorConfig config)
     : base(config)
 {
 }