// TODO object caching where possible... // TODO read all from config file... (monitrc) public static monitServer GetMonitServerData() { var data = new monitServer(); data.controlfile = "none"; // TODO data.startdelay = 0; // TODO data.localhostname = SystemStats.GetHostname(); data.httpd = new monitServerHttpd() { address = ConfigMgr.Config.HttpdBindIp, port = ConfigMgr.Config.HttpdPort, ssl = (byte)(ConfigMgr.Config.HttpdSSL ? 1 : 0), // TODO }; data.credentials = new monitServerCredentials() { password = ConfigMgr.Config.HttpdPassword, username = ConfigMgr.Config.HttpdUsername }; data.poll = 120; // TODO return(data); }
/// <summary> /// Get "frame"-xml-data which is the same for different usecases /// </summary> /// <param name="type"></param> /// <returns></returns> private monitService GetNewServiceSkeleton(MonitServiceType type) { var serviceSekeleton = new monitService(); serviceSekeleton.name = SystemStats.GetHostname(); serviceSekeleton.type = (int)type; serviceSekeleton.status = 0; // "error". Error flags bitmap, See MonitEventTable serviceSekeleton.status_hint = 0; // "error_hint" See MonitEventTable serviceSekeleton.monitor = (int)MonitMonitorStateType.MONITOR_YES; serviceSekeleton.monitormode = (int)MonitMonitorModeType.MODE_ACTIVE; // default var tf = Timing.GetTimingFraction(); serviceSekeleton.collected_sec = tf.Timestamp; serviceSekeleton.collected_usec = tf.Usec; return(serviceSekeleton); }
private monitService GetSystemService() { var systemService = GetNewServiceSkeleton(MonitServiceType.TYPE_SYSTEM); systemService.system = new monitServiceSystem(); systemService.name = SystemStats.GetHostname(); // CPU systemService.system.cpu = new monitServiceSystemCpu { system = m_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 MonitWindowsAgent() { 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 } }); servicelist = new List <Service_T>(); servicelist_conf = new List <Service_T>(); ConfigMgr.Config.Services.ForEach(sc => { 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); } } }); servicegrouplist = new List <ServiceGroup_T>(); systeminfo = SystemInfoHelper.GetSystemInfo(); m_timer = new Timer(ConfigMgr.Config.Period); m_timer.Elapsed += DoPeriodicCheck; m_timer.AutoReset = true; m_mMonitClient = new Collector(); var service = ServiceHelper.GetSystemService(); Run.system = new List <Service_T>(); Run.system.Add(service); }