public static SystemInfo_T GetSystemInfo() { var totalMem = PerformanceInfo.GetTotalMemoryInKiB(); var systeminfo = new SystemInfo_T(); systeminfo.uname = new utsname(); systeminfo.uname.sysname = Environment.OSVersion.Platform.ToString(); systeminfo.uname.machine = CPUAchitecture.IsOS64Bit() ? "x86_64" : "x86"; systeminfo.uname.release = Environment.OSVersion.Version.ToString(); // Environment.OSVersion.Version.Build.ToString(); systeminfo.uname.version = Environment.OSVersion.Version.Build.ToString(); systeminfo.collected = DateTime.UtcNow; systeminfo.cpus = SystemStats.GetCPUCoreCount(); systeminfo.total_cpu_syst_percent = SystemStats.GetCPULoadPercentage(); systeminfo.mem_kbyte_max = SystemStats.GetMemorySizeKB(); systeminfo.total_mem_percent = Convert.ToInt16((1 - (int)(PerformanceInfo.GetPhysicalAvailableMemoryInKiB() / (float)totalMem)) * 10); systeminfo.total_mem_kbyte = totalMem - PerformanceInfo.GetPhysicalAvailableMemoryInKiB(); systeminfo.swap_kbyte_max = 0; systeminfo.total_swap_kbyte = 0; systeminfo.loadavg[0] = 0.07; systeminfo.loadavg[1] = 0.03; systeminfo.loadavg[2] = 0.08; return(systeminfo); }
public static Service_T GetSystemService() { var systemService = CreateService(null, SystemStats.GetHostname()); systemService.collected = MonitWindowsAgent.systeminfo.collected; systemService.inf = new ProcessInfo_T { total_cpu_percent = MonitWindowsAgent.systeminfo.total_cpu_syst_percent, total_mem_kbyte = MonitWindowsAgent.systeminfo.total_mem_kbyte, // calculating free mem, then substracting this from 100 to get used mem percentage total_mem_percent = MonitWindowsAgent.systeminfo.total_mem_percent }; //systemService.system = new monitServiceSystem(); //// CPU //systemService.system.cpu = new monitServiceSystemCpu //{ // system = SystemStats.GetCPULoadPercentage(), // user = 0, //}; //// MEMORY //var totalMem = PerformanceInfo.GetTotalMemoryInKiB(); //systemService.system.memory = new monitServiceSystemMemory() //{ // kilobyte = totalMem, // // calculating free mem, then substracting this from 100 to get used mem percentage // percent = Math.Round(100 - ((decimal)PerformanceInfo.GetPhysicalAvailableMemoryInKiB() / (decimal)totalMem) * 100, 1), //}; //// LOAD //systemService.system.load = new monitServiceSystemLoad() //{ // avg01 = 0.07, // avg05 = 0.03, // avg15 = 0.08, //}; //// SWAP //// Possible to use this on windows? //systemService.system.swap = new monitServiceSystemSwap() //{ // kilobyte = 0, // percent = 0, //}; return(systemService); }
public static void parse() { ConfigMgr.ReloadConfig(); Run_T Run = new Run_T(); Run.id = UniqueWindowsId.GetOrCreateUniqueId(); Run.incarnation = SystemStats.ProcessRunningInSec(); Run.controlfile = "none"; //TODO Run.startdelay = 0; //TODO Run.polltime = 120; //TODO Run.Env = new myenvironment(); Run.Env.user = SystemStats.GetHostname(); Run.httpd = new Httpd_T(); Run.httpd.port = ConfigMgr.Config.Httpd.Port; Run.httpd.ssl = ConfigMgr.Config.Httpd.SSL; Run.httpd.address = ConfigMgr.Config.Httpd.BindIp; Run.httpd.credentials = new List <Auth_T>(); Run.httpd.credentials.Add(new Auth_T { uname = ConfigMgr.Config.Httpd.Username, passwd = ConfigMgr.Config.Httpd.Password }); Run.mmonits = new List <Mmonit_T>(); Run.mmonits.Add(new Mmonit_T { url = new URL_T { url = ConfigMgr.Config.MMonits[0].Url, //port = ConfigMgr.Config.MMonits[0].Port, password = ConfigMgr.Config.MMonits[0].Password, user = ConfigMgr.Config.MMonits[0].Username } }); MonitWindowsAgent.servicelist = new List <Service_T>(); MonitWindowsAgent.servicelist_conf = new List <Service_T>(); foreach (var sc in ConfigMgr.Config.Services) { var newS = ServiceHelper.CreateService(sc, sc.Name.ToLower()); if (newS == null) { Logger.Log.Error("Service could not be created!"); } else { if (sc is ProcessConfig) { ProcessHelper.AddProcess(newS); } else if (sc is FilesystemConfig) { FilesystemHelper.AddFilesystem(newS); } } } MonitWindowsAgent.servicegrouplist = new List <ServiceGroup_T>(); MonitWindowsAgent.systeminfo = SystemInfoHelper.GetSystemInfo(); var service = ServiceHelper.GetSystemService(); Run.system = new List <Service_T>(); Run.system.Add(service); MonitWindowsAgent.Run = Run; }