protected override void CreateSensors() { NVMeHealthInfo log = Smart.GetHealthInfo(); if (log != null) { AddSensor("Temperature", 0, false, SensorType.Temperature, health => health.Temperature); AddSensor("Available Spare", 1, false, SensorType.Level, health => health.AvailableSpare); AddSensor("Available Spare Threshold", 2, false, SensorType.Level, health => health.AvailableSpareThreshold); AddSensor("Percentage Used", 3, false, SensorType.Level, health => health.PercentageUsed); AddSensor("Data Read", 4, false, SensorType.Data, health => UnitsToData(health.DataUnitRead)); AddSensor("Data Written", 5, false, SensorType.Data, health => UnitsToData(health.DataUnitWritten)); int sensorIdx = 6; for (int i = 0; i < log.TemperatureSensors.Length; i++) { int idx = i; if (log.TemperatureSensors[idx] > short.MinValue) { AddSensor("Temperature " + (idx + 1), sensorIdx, false, SensorType.Temperature, health => health.TemperatureSensors[idx]); sensorIdx++; } } } base.CreateSensors(); }
protected override void UpdateSensors() { NVMeHealthInfo health = Smart.GetHealthInfo(); foreach (NVMeSensor sensor in _sensors) { sensor.Update(health); } }
public void Update(NVMeHealthInfo health) { float v = _getValue(health); if (SensorType == SensorType.Temperature) { if (v < -1000 || v > 1000) { return; } } Value = v; }
protected override void GetReport(StringBuilder r) { if (_info == null) { return; } r.AppendLine("PCI Vendor ID: 0x" + _info.VID.ToString("x04")); if (_info.VID != _info.SSVID) { r.AppendLine("PCI Subsystem Vendor ID: 0x" + _info.VID.ToString("x04")); } r.AppendLine("IEEE OUI Identifier: 0x" + _info.IEEE[2].ToString("x02") + _info.IEEE[1].ToString("x02") + _info.IEEE[0].ToString("x02")); r.AppendLine("Total NVM Capacity: " + _info.TotalCapacity); r.AppendLine("Unallocated NVM Capacity: " + _info.UnallocatedCapacity); r.AppendLine("Controller ID: " + _info.ControllerId); r.AppendLine("Number of Namespaces: " + _info.NumberNamespaces); NVMeHealthInfo health = Smart.GetHealthInfo(); if (health == null) { return; } if (health.CriticalWarning == Kernel32.NVME_CRITICAL_WARNING.None) { r.AppendLine("Critical Warning: -"); } else { if ((health.CriticalWarning & Kernel32.NVME_CRITICAL_WARNING.AvailableSpaceLow) != 0) { r.AppendLine("Critical Warning: the available spare space has fallen below the threshold."); } if ((health.CriticalWarning & Kernel32.NVME_CRITICAL_WARNING.TemperatureThreshold) != 0) { r.AppendLine("Critical Warning: a temperature is above an over temperature threshold or below an under temperature threshold."); } if ((health.CriticalWarning & Kernel32.NVME_CRITICAL_WARNING.ReliabilityDegraded) != 0) { r.AppendLine("Critical Warning: the device reliability has been degraded due to significant media related errors or any internal error that degrades device reliability."); } if ((health.CriticalWarning & Kernel32.NVME_CRITICAL_WARNING.ReadOnly) != 0) { r.AppendLine("Critical Warning: the media has been placed in read only mode."); } if ((health.CriticalWarning & Kernel32.NVME_CRITICAL_WARNING.VolatileMemoryBackupDeviceFailed) != 0) { r.AppendLine("Critical Warning: the volatile memory backup device has failed."); } } r.AppendLine("Temperature: " + health.Temperature + " Celsius"); r.AppendLine("Available Spare: " + health.AvailableSpare + "%"); r.AppendLine("Available Spare Threshold: " + health.AvailableSpareThreshold + "%"); r.AppendLine("Percentage Used: " + health.PercentageUsed + "%"); r.AppendLine("Data Units Read: " + health.DataUnitRead); r.AppendLine("Data Units Written: " + health.DataUnitWritten); r.AppendLine("Host Read Commands: " + health.HostReadCommands); r.AppendLine("Host Write Commands: " + health.HostWriteCommands); r.AppendLine("Controller Busy Time: " + health.ControllerBusyTime); r.AppendLine("Power Cycles: " + health.PowerCycle); r.AppendLine("Power On Hours: " + health.PowerOnHours); r.AppendLine("Unsafe Shutdowns: " + health.UnsafeShutdowns); r.AppendLine("Media Errors: " + health.MediaErrors); r.AppendLine("Number of Error Information Log Entries: " + health.ErrorInfoLogEntryCount); r.AppendLine("Warning Composite Temperature Time: " + health.WarningCompositeTemperatureTime); r.AppendLine("Critical Composite Temperature Time: " + health.CriticalCompositeTemperatureTime); for (int i = 0; i < health.TemperatureSensors.Length; i++) { if (health.TemperatureSensors[i] > short.MinValue) { r.AppendLine("Temperature Sensor " + (i + 1) + ": " + health.TemperatureSensors[i] + " Celsius"); } } }
public void Update(NVMeHealthInfo health) { Value = _getValue(health); }