mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-20 10:23:18 +03:00
Get temperature warn/crit from nvme
This commit is contained in:
@@ -411,6 +411,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
QJsonArray ataSelfTestsTable = localObj["ata_smart_self_test_log"].toObject()["standard"].toObject()["table"].toArray();
|
QJsonArray ataSelfTestsTable = localObj["ata_smart_self_test_log"].toObject()["standard"].toObject()["table"].toArray();
|
||||||
|
|
||||||
bool isNvme = (protocol == "NVMe");
|
bool isNvme = (protocol == "NVMe");
|
||||||
|
bool nvmeHasSelfTest = false;
|
||||||
|
|
||||||
auto createTablePopup = [=](QJsonArray selfTestsTable) {
|
auto createTablePopup = [=](QJsonArray selfTestsTable) {
|
||||||
QWidget *popup = new QWidget();
|
QWidget *popup = new QWidget();
|
||||||
@@ -616,9 +617,44 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
totalWritesLineEdit->setText(totalWrites);
|
totalWritesLineEdit->setText(totalWrites);
|
||||||
totalWritesLineEdit->setAlignment(Qt::AlignRight);
|
totalWritesLineEdit->setAlignment(Qt::AlignRight);
|
||||||
|
|
||||||
if (temperatureInt > 60) { // TODO: Let the user set an alarm temp.
|
int warningTemperature = 55;
|
||||||
|
int criticalTemperature = 60;
|
||||||
|
|
||||||
|
if (isNvme) {
|
||||||
|
QString stringValue;
|
||||||
|
warningTemperature = 65;
|
||||||
|
criticalTemperature = 70;
|
||||||
|
for (const QJsonValue &value : outputArray) {
|
||||||
|
stringValue = value.toString();
|
||||||
|
if (stringValue.startsWith("Optional Admin Commands")) {
|
||||||
|
if (stringValue.contains("Self_Test")) {
|
||||||
|
nvmeHasSelfTest = true;
|
||||||
|
}
|
||||||
|
} else if (stringValue.startsWith("Warning Comp. Temp. Threshold")) {
|
||||||
|
int pos = stringValue.indexOf(':');
|
||||||
|
if (pos != -1) {
|
||||||
|
QString thresholdStr = stringValue.mid(pos + 1).trimmed();
|
||||||
|
int temperature = thresholdStr.section(' ', 0, 0).toInt();
|
||||||
|
if (temperature > 0) {
|
||||||
|
warningTemperature = temperature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (stringValue.startsWith("Critical Comp. Temp. Threshold")) {
|
||||||
|
int pos = stringValue.indexOf(':');
|
||||||
|
if (pos != -1) {
|
||||||
|
QString thresholdStr = stringValue.mid(pos + 1).trimmed();
|
||||||
|
int temperature = thresholdStr.section(' ', 0, 0).toInt();
|
||||||
|
if (temperature > 0) {
|
||||||
|
criticalTemperature = temperature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temperatureInt > warningTemperature) { // TODO: Let the user set an alarm temp.
|
||||||
temperatureValue->setStyleSheet("background-color: " + badColor.name() + ";");
|
temperatureValue->setStyleSheet("background-color: " + badColor.name() + ";");
|
||||||
} else if ((temperatureInt < 60) && (temperatureInt > 55)){
|
} else if ((temperatureInt < criticalTemperature) && (temperatureInt > warningTemperature)){
|
||||||
temperatureValue->setStyleSheet("background-color: " + cautionColor.name() + ";");
|
temperatureValue->setStyleSheet("background-color: " + cautionColor.name() + ";");
|
||||||
} else if (temperatureInt == 0) {
|
} else if (temperatureInt == 0) {
|
||||||
temperatureValue->setStyleSheet("background-color: " + naColor.name() + ";");
|
temperatureValue->setStyleSheet("background-color: " + naColor.name() + ";");
|
||||||
@@ -712,18 +748,9 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal
|
|||||||
} else {
|
} else {
|
||||||
addNvmeLogTable(nvmeLogOrdered);
|
addNvmeLogTable(nvmeLogOrdered);
|
||||||
|
|
||||||
bool hasSelfTest = false;
|
|
||||||
selfTestMenu->clear();
|
selfTestMenu->clear();
|
||||||
|
|
||||||
for (const QJsonValue &value : outputArray) {
|
if (nvmeHasSelfTest) {
|
||||||
if (value.toString().startsWith("Optional Admin Commands")) {
|
|
||||||
if (value.toString().contains("Self_Test")) {
|
|
||||||
hasSelfTest = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasSelfTest) {
|
|
||||||
selfTestMenu->setEnabled(true);
|
selfTestMenu->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
selfTestMenu->setDisabled(true);
|
selfTestMenu->setDisabled(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user