Beispiel #1
0
        public void HigherStandardNetworkTraffic()
        {
            NetworkTrafficCheck check = new NetworkTrafficCheck();

            var store = new Dictionary <string, long>();

            store["recv_bytes"] = 30000000;

            var result = check.CheckForOverflow("recv", store, 30001000);

            Assert.AreEqual(result[0], 1000);
            Assert.AreEqual(result[1], 30001000);
        }
Beispiel #2
0
        public void StandardNetworkTrafficWithOverFlow()
        {
            NetworkTrafficCheck check = new NetworkTrafficCheck();

            var store = new Dictionary <string, long>();

            store["recv_bytes"] = UInt32.MaxValue - 100;

            var result = check.CheckForOverflow("recv", store, 100);

            Assert.AreEqual(200, result[0]);
            Assert.AreEqual(100, result[1]);
        }
Beispiel #3
0
        private void InitializeConfig()
        {
            try
            {
                Checks.Add(new SystemStatsCheck());

                _networkTrafficCheck = new NetworkTrafficCheck();

                Checks.Add(_networkTrafficCheck);
                Checks.Add(new DriveInfoBasedDiskUsageCheck());
                Checks.Add(new ProcessorCheck());
                Checks.Add(new ProcessCheck());
                Checks.Add(new PhysicalMemoryFreeCheck());
                Checks.Add(new PhysicalMemoryUsedCheck());
                Checks.Add(new PhysicalMemoryCachedCheck());
                Checks.Add(new SwapMemoryFreeCheck());
                Checks.Add(new SwapMemoryUsedCheck());
                Checks.Add(new IOCheck());

                if (_config.IISStatus)
                {
                    Checks.Add(new IISCheck());
                }

                if (_config.PluginDirectory != null && Directory.Exists(_config.PluginDirectory))
                {
                    Checks.Add(new PluginCheck(_config.PluginDirectory));
                }

                if (_config.SQLServerStatus)
                {
                    Checks.Add(new SQLServerCheck(_config.CustomPrefix));
                }

                if (!string.IsNullOrEmpty(_config.MongoDBConnectionString))
                {
                    Checks.Add(new ExtendedMongoDBCheck(_config.MongoDBConnectionString, _config.MongoDBReplSet, _config.MongoDBDBStats));
                }

                // flag check
                if (Agent.Flags.ContainsKey("FlagCheck"))
                {
                    Log.Warn("Flag check activated");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Beispiel #4
0
        public void DoubleStandardNetworkTraffic()
        {
            NetworkTrafficCheck check = new NetworkTrafficCheck();

            var store = new Dictionary <string, long>();

            store["recv_bytes"] = 1216986405;

            var result = check.CheckForOverflow("recv", store, 1217007129);

            store["recv_bytes"] = result[1];

            var second_result = check.CheckForOverflow("recv", store, 1217010727);

            Assert.AreEqual(3598, second_result[0]);
            Assert.AreEqual(1217010727, second_result[1]);
        }
Beispiel #5
0
        public void AfterOverFlow()
        {
            NetworkTrafficCheck check = new NetworkTrafficCheck();

            var store = new Dictionary <string, long>();

            store["recv_bytes"] = UInt32.MaxValue - 100;

            long target = UInt32.MaxValue;

            target += 100;

            var result = check.CheckForOverflow("recv", store, 100);

            store["recv_bytes"] = result[0];

            var second_result = check.CheckForOverflow("recv", store, 100 + result[0]);

            Assert.AreEqual(100, second_result[0]);
        }