select drive based on arrow keys
This commit is contained in:
@ -40,17 +40,17 @@ void SMART::readSMARTData(Drive* drive)
|
||||
FILE* outputfileSmart = popen(cpComand, "r");
|
||||
|
||||
while ((getline(&cLine, &len, outputfileSmart)) != -1)
|
||||
{
|
||||
string sLine = string(cLine);
|
||||
{
|
||||
string sLine = string(cLine);
|
||||
|
||||
SMART::parseModelFamily(sLine);
|
||||
SMART::parseModelName(sLine);
|
||||
SMART::parseSerial(sLine);
|
||||
SMART::parseCapacity(sLine);
|
||||
SMART::parseErrorCount(sLine);
|
||||
SMART::parsePowerOnHours(sLine);
|
||||
SMART::parsePowerCycle(sLine);
|
||||
}
|
||||
SMART::parseModelFamily(sLine);
|
||||
SMART::parseModelName(sLine);
|
||||
SMART::parseSerial(sLine);
|
||||
SMART::parseCapacity(sLine);
|
||||
SMART::parseErrorCount(sLine);
|
||||
SMART::parsePowerOnHours(sLine);
|
||||
SMART::parsePowerCycle(sLine);
|
||||
}
|
||||
fclose(outputfileSmart);
|
||||
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle); //wirte data in drive
|
||||
}
|
||||
@ -64,11 +64,12 @@ void SMART::parseModelFamily(string sLine)
|
||||
{
|
||||
string search("\"model_family\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos) {
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
modelFamily = sLine;
|
||||
}
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
modelFamily = sLine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,11 +81,12 @@ void SMART::parseModelName(string sLine)
|
||||
{
|
||||
string search("\"model_name\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos) {
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
modelName = sLine;
|
||||
}
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
modelName = sLine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,11 +98,12 @@ void SMART::parseSerial(string sLine)
|
||||
{
|
||||
string search("\"serial_number\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos) {
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
serial = sLine;
|
||||
}
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 3);
|
||||
sLine.erase(sLine.length()-3, 3);
|
||||
serial = sLine;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,11 +115,12 @@ void SMART::parseCapacity(string sLine)
|
||||
{
|
||||
string search("\"bytes\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos) {
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-1, 1);
|
||||
capacity = stol(sLine);
|
||||
}
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-1, 1);
|
||||
capacity = stol(sLine);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,11 +133,11 @@ void SMART::parseErrorCount(string sLine)
|
||||
string search("\"error_count_total\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ")+2);
|
||||
sLine.erase(sLine.length()-2, 2);
|
||||
errorCount = stol(sLine);
|
||||
}
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ")+2);
|
||||
sLine.erase(sLine.length()-2, 2);
|
||||
errorCount = stol(sLine);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,12 +150,12 @@ void SMART::parsePowerOnHours(string sLine)
|
||||
string search("\"hours\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-1, 1);
|
||||
powerOnHours = stol(sLine);
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-1, 1);
|
||||
powerOnHours = stol(sLine);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,11 +168,11 @@ void SMART::parsePowerCycle(string sLine)
|
||||
string search("\"power_cycle_count\": ");
|
||||
size_t found = sLine.find(search);
|
||||
if (found!=string::npos)
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-2, 2);
|
||||
powerCycle = stol(sLine);
|
||||
{
|
||||
sLine.erase(0, sLine.find(": ") + 2);
|
||||
sLine.erase(sLine.length()-2, 2);
|
||||
powerCycle = stol(sLine);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user