public void HostNetInfo_1() { var hi = HostNetInfo.ForThisHost(); Console.WriteLine(hi.ToJSON(JSONWritingOptions.PrettyPrint)); if (System.Environment.MachineName == "SEXTOD") { Assert.IsTrue(hi.Adapters["{C93B4009-15C0-46A3-8C95-91610CAEBC4F}::Local Area Connection"].Addresses.ContainsName("192.168.1.70")); } else { Assert.Inconclusive("This test can only run on SEXTOD"); } }
public static HostInfo ForThisHost() { var cpu = Computer.CurrentProcessorUsagePct; var ram = Computer.GetMemoryStatus(); var result = new HostInfo { m_Name = AgniSystem.HostName,//the HostName does not have spaces in dynamic host name m_UTCTimeStamp = App.TimeSource.UTCNow, m_LastWarning = App.Log.LastWarning.ThisOrNewSafeWrappedException(), m_LastError = App.Log.LastError.ThisOrNewSafeWrappedException(), m_LastCatastrophe = App.Log.LastCatastrophe.ThisOrNewSafeWrappedException(), m_CurrentCPULoad = cpu, m_CurrentRAMStatus = ram, m_NetInfo = HostNetInfo.ForThisHost(), m_SystemBuildInfo = BuildInformation.ForFramework, m_AgniBuildInfo = AgniSystem.CoreBuildInfo }; if (result.UTCTimeStamp.Millisecond % s_MyEntropyMs == 0) { int entropy = unchecked (641 * cpu * ((int)ram.AvailablePhysicalBytes % 65171)); //we purposely want to have "low" entropy so higher bytes are USUALLY 0 NFX.ExternalRandomGenerator.Instance.FeedExternalEntropySample(entropy); } if ( (cpu > 25 && cpu < 50 && (cpu & 0x1) == 0) || (cpu > 0 && cpu % 7 == 0) ) { result.m_RandomSample = NFX.ExternalRandomGenerator.Instance.NextRandomInteger; } return(result); }