/// <summary> /// Loads the default settings. /// </summary> public WsapmSettings GetDefaultSettings() { var newSettings = new WsapmSettings(); newSettings.MonitoringTimerInterval = WsapmTools.GetOptimalCheckIntervalInMinutes(); newSettings.MaxLogFileSize = WsapmConvert.ConvertKBToByte(100); newSettings.NetworkInterfacesToMonitor = new System.Collections.Generic.List <NetworkInterfaceToMonitor>(); newSettings.HddsToMonitor = new System.Collections.Generic.List <HddToMonitor>(); newSettings.EnableCheckNetworkResourceAccess = false; newSettings.CheckNetworkResourcesType = NetworkShareAccessType.Files; newSettings.CpuLoad = 0.0f; newSettings.MemoryLoad = 0.0f; newSettings.UptimeSchedulers = new System.Collections.Generic.List <UptimeScheduler>(); newSettings.WakeSchedulers = new System.Collections.Generic.List <WakeScheduler>(); newSettings.LogMode = LogMode.Normal; newSettings.EnableRemoteShutdown = false; newSettings.RemoteShutdownPort = 9; newSettings.RemoteShutdownPasswordHash = string.Empty; return(newSettings); }
/// <summary> /// Checks if the HDD load is over the HDD load value in the settings. /// </summary> /// <param name="settings"></param> /// <returns>True, if the current HDD load is greater than the HDD load value in the settings, otherwise false.</returns> public CheckSuspendResult CheckHddLoad(WsapmSettings settings) { if (settings == null || !settings.EnableHddsToMonitor) { return(new CheckSuspendResult(false, String.Empty)); } var availableHdds = WsapmTools.GetAvailableLogicalVolumeNames(); foreach (var hddToMonitor in settings.HddsToMonitor) { if (hddToMonitor.Drive != WsapmConstants.AllHddsName && !availableHdds.Contains(hddToMonitor.Drive)) { // HDD not available -> don't check, just write entry in log. WsapmLog.Log.WriteLine(string.Format(Wsapm.Core.Resources.Wsapm_Core.HddLoadCheck_HddNotAvailable, hddToMonitor.Drive), LogMode.Normal); continue; } bool checkAllHdds = false; string hddName = hddToMonitor.Drive; if (hddToMonitor.Drive == WsapmConstants.AllHddsName) { checkAllHdds = true; hddName = WsapmTools.GetCommonDiaplayNameAllDrives(); } // Check load. try { if (hddToMonitor.EnableCheckHddLoad && hddToMonitor.HddLoad != 0.0f) { var averageHddLoad = 0.0f; if (checkAllHdds) { averageHddLoad = this.hddLoad.GetAverageHddLoadAllVolumesInBytesPerSecond(); // Byte/s } else { averageHddLoad = this.hddLoad.GetAverageHddLoadInBytesPerSecond(hddToMonitor.Drive); // Byte/s } var result = averageHddLoad > WsapmConvert.ConvertKBToByte(hddToMonitor.HddLoad); // Settings are saved as KBit/s. if (result) { return(new CheckSuspendResult(true, String.Format(Resources.Wsapm_Core.HddLoadCheck_HddLoadReason, hddName, hddToMonitor.HddLoad, WsapmConvert.ConvertByteToKB(averageHddLoad).ToString("0")))); } else { return(new CheckSuspendResult(false, String.Empty)); } } } catch (Exception ex) { // Might happen if the performance counters get broken. WsapmLog.Log.WriteError(ex); } } return(new CheckSuspendResult(false, String.Empty)); }
/// <summary> /// Initializes a new instance of ServiceLog. /// </summary> /// <param name="logMode">The LogMode defining the level of detail of the log.</param> private WsapmLog(LogMode logMode) : this(logMode, WsapmConvert.ConvertKBToByte(0)) { }
/// <summary> /// Initializes a new instance of ServiceLog. /// </summary> private WsapmLog() : this(LogMode.Normal, WsapmConvert.ConvertKBToByte(0)) { }