public void Initialize() { Logger.WriteEvent("Initializing...", ZifliService._INFO); ServerRemoting.createChannelTcp(); this.tmrZifli.Interval = (this.intPollInterval * 1000); Misc oMisc = new Misc(); this.strMachineName = oMisc.GetMachineName(); this.strMACAddress = oMisc.GetMacAddress(4); DateTime dt = DateTime.Now; dt = dt.AddSeconds(intPollInterval); Computer oComputer = new Computer(); oComputer.addALInterfaces(); this.oComputer = oComputer; ArrayList alIfaceNames = new ArrayList(); alIfaceNames = oComputer.getInterfaceNames(); string strMatcher = "[Gg]igabit"; foreach (string strIfaceName in alIfaceNames) { if (Regex.IsMatch(strIfaceName, strMatcher)) { Logger.WriteEvent("mac address: " + oComputer.getActiveMACAdress(oComputer.getInterfaceByName(strIfaceName)), ZifliService._INFO); } } Logger.WriteEvent("...finished initializing.", ZifliService._INFO); }
void tmrZifli_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Logger.WriteEvent("Tick", ZifliService._INFO); DateTime dt = DateTime.Now; Misc dtConvert = new Misc(); this.lUnixTS = dtConvert.getUnixTimeStamp(dt); dt = dt.AddSeconds(intPollInterval); Poller oPoller = new Poller(); Result aResult = oPoller.queryProviderByName("Win32_PerfFormattedData_PerfOS_Processor", "_Total", "PercentProcessorTime"); Misc oUploader = new Misc(); try { oUploader.uploadResults(this.strMACAddress, this.strDSName, aResult, this.strMachineName, this.lUnixTS, this.strEmailAddress, this.strPassword); Logger.WriteEvent("Uploaded results successfully.", ZifliService._DEBUG); } catch { Logger.WriteEvent("Failed to upload results.", ZifliService._WARN); } }