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]); }
public void StandardNetworkTraffic() { NetworkTrafficCheck check = new NetworkTrafficCheck(); var store = new Dictionary<string, long>(); store["recv_bytes"] = 10; var result = check.CheckForOverflow("recv", store, 100); Assert.AreEqual(result[0], 90); Assert.AreEqual(result[1], 100); }
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]); }
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]); }
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); } }
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()); 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)) { try { ExtendedMongoDBLoader loader = new ExtendedMongoDBLoader(_config.MongoDBConnectionString, _config.MongoDBReplSet, _config.MongoDBDBStats); ICheck check = loader.Load(); if (check == null) { throw new NullReferenceException(); } Checks.Add(check); } catch (Exception ex) { Log.Error(ex); // If the extended MongoDB checks class can't load, fall back to old school. Checks.Add(new MongoDBCheck(_config.MongoDBConnectionString)); } } // flag check if (Agent.Flags.ContainsKey("FlagCheck")) { Log.Warn("Flag check activated"); } } catch (Exception ex) { Log.Error(ex); } }