read temperature via S.M.A.R.T and display
This commit is contained in:
parent
7dfa805044
commit
2df5ceb0c8
|
@ -44,11 +44,13 @@ private:
|
||||||
uint32_t u32ErrorCount = 0U;
|
uint32_t u32ErrorCount = 0U;
|
||||||
uint32_t u32PowerOnHours = 0U; //in hours
|
uint32_t u32PowerOnHours = 0U; //in hours
|
||||||
uint32_t u32PowerCycles = 0U;
|
uint32_t u32PowerCycles = 0U;
|
||||||
|
uint32_t u32Temperature = 0U; //in Fahrenheit, just kidding: degree Celsius
|
||||||
time_t u32Timestamp = 0U; //unix timestamp for detecting a frozen drive
|
time_t u32Timestamp = 0U; //unix timestamp for detecting a frozen drive
|
||||||
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
|
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
|
||||||
time_t u32TimestampTaskStart = 0U; //unix timestamp for duration of an action
|
time_t u32TimestampTaskStart = 0U; //unix timestamp for duration of an action
|
||||||
time_t u32TaskDuration = 0U; //time needed to complete the task
|
time_t u32TaskDuration = 0U; //time needed to complete the task
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setTimestamp();
|
void setTimestamp();
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ public:
|
||||||
uint32_t getErrorCount(void);
|
uint32_t getErrorCount(void);
|
||||||
uint32_t getPowerOnHours(void); //in hours
|
uint32_t getPowerOnHours(void); //in hours
|
||||||
uint32_t getPowerCycles(void);
|
uint32_t getPowerCycles(void);
|
||||||
|
uint32_t getTemperature(void); //in Fahrenheit, just kidding: degree Celsius
|
||||||
void checkFrozenDrive(void);
|
void checkFrozenDrive(void);
|
||||||
|
|
||||||
void setDriveSMARTData( string modelFamily,
|
void setDriveSMARTData( string modelFamily,
|
||||||
|
@ -76,12 +79,14 @@ public:
|
||||||
uint64_t capacity,
|
uint64_t capacity,
|
||||||
uint32_t errorCount,
|
uint32_t errorCount,
|
||||||
uint32_t powerOnHours,
|
uint32_t powerOnHours,
|
||||||
uint32_t powerCycles);
|
uint32_t powerCycles,
|
||||||
|
uint32_t temperature);
|
||||||
|
|
||||||
string sCapacityToText();
|
string sCapacityToText();
|
||||||
string sErrorCountToText();
|
string sErrorCountToText();
|
||||||
string sPowerOnHoursToText();
|
string sPowerOnHoursToText();
|
||||||
string sPowerCyclesToText();
|
string sPowerCyclesToText();
|
||||||
|
string sTemperatureToText();
|
||||||
|
|
||||||
void setTaskPercentage(double d32TaskPercentage);
|
void setTaskPercentage(double d32TaskPercentage);
|
||||||
double getTaskPercentage(void);
|
double getTaskPercentage(void);
|
||||||
|
|
|
@ -27,6 +27,7 @@ private:
|
||||||
static void parseErrorCount(string sLine);
|
static void parseErrorCount(string sLine);
|
||||||
static void parsePowerOnHours(string sLine);
|
static void parsePowerOnHours(string sLine);
|
||||||
static void parsePowerCycle(string sLine);
|
static void parsePowerCycle(string sLine);
|
||||||
|
static void parseTemperature(string sLine);
|
||||||
|
|
||||||
static string modelFamily;
|
static string modelFamily;
|
||||||
static string modelName;
|
static string modelName;
|
||||||
|
@ -35,6 +36,7 @@ private:
|
||||||
static uint32_t errorCount;
|
static uint32_t errorCount;
|
||||||
static uint32_t powerOnHours;
|
static uint32_t powerOnHours;
|
||||||
static uint32_t powerCycle;
|
static uint32_t powerCycle;
|
||||||
|
static uint32_t temperature;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SMART_H_
|
#endif // SMART_H_
|
|
@ -56,7 +56,7 @@ private:
|
||||||
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
|
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
|
||||||
static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive);
|
static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive);
|
||||||
static WINDOW *overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart);
|
static WINDOW *overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart);
|
||||||
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, bool bSelected);
|
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected);
|
||||||
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
|
static WINDOW *createSystemStats(int iXSize, int iYSize, int iXStart, int iYStart);
|
||||||
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
static WINDOW *createMenuView(int iXSize, int iYSize, int iXStart, int iYStart, struct MenuState menustate);
|
||||||
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
static WINDOW *createDialog(int iXSize, int iYSize, int iXStart, int iYStart, string selectedTask, string optionA, string optionB);
|
||||||
|
|
|
@ -46,6 +46,11 @@ uint32_t Drive::getPowerCycles(void)
|
||||||
return u32PowerCycles;
|
return u32PowerCycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Drive::getTemperature(void)
|
||||||
|
{
|
||||||
|
return u32Temperature;
|
||||||
|
}
|
||||||
|
|
||||||
string Drive::sCapacityToText()
|
string Drive::sCapacityToText()
|
||||||
{
|
{
|
||||||
char acBuffer[16];
|
char acBuffer[16];
|
||||||
|
@ -91,6 +96,11 @@ string Drive::sPowerCyclesToText()
|
||||||
return to_string(getPowerCycles());
|
return to_string(getPowerCycles());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string Drive::sTemperatureToText()
|
||||||
|
{
|
||||||
|
return to_string(getTemperature())+" C";;
|
||||||
|
}
|
||||||
|
|
||||||
void Drive::setTaskPercentage(double d32TaskPercentage)
|
void Drive::setTaskPercentage(double d32TaskPercentage)
|
||||||
{
|
{
|
||||||
if(d32TaskPercentage <= 100)
|
if(d32TaskPercentage <= 100)
|
||||||
|
@ -122,7 +132,8 @@ void Drive::setDriveSMARTData( string modelFamily,
|
||||||
uint64_t capacity,
|
uint64_t capacity,
|
||||||
uint32_t errorCount,
|
uint32_t errorCount,
|
||||||
uint32_t powerOnHours,
|
uint32_t powerOnHours,
|
||||||
uint32_t powerCycle)
|
uint32_t powerCycle,
|
||||||
|
uint32_t temperature)
|
||||||
{
|
{
|
||||||
this->sModelFamily = modelFamily;
|
this->sModelFamily = modelFamily;
|
||||||
sModelName = modelName;
|
sModelName = modelName;
|
||||||
|
@ -131,6 +142,7 @@ void Drive::setDriveSMARTData( string modelFamily,
|
||||||
u32ErrorCount = errorCount;
|
u32ErrorCount = errorCount;
|
||||||
u32PowerOnHours = powerOnHours;
|
u32PowerOnHours = powerOnHours;
|
||||||
u32PowerCycles = powerCycle;
|
u32PowerCycles = powerCycle;
|
||||||
|
u32Temperature = temperature;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ uint64_t SMART::capacity = 0U;
|
||||||
uint32_t SMART::errorCount = 0U;
|
uint32_t SMART::errorCount = 0U;
|
||||||
uint32_t SMART::powerOnHours = 0U;
|
uint32_t SMART::powerOnHours = 0U;
|
||||||
uint32_t SMART::powerCycle = 0U;
|
uint32_t SMART::powerCycle = 0U;
|
||||||
|
uint32_t SMART::temperature = 0U;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief get and set S.M.A.R.T. values in Drive
|
* \brief get and set S.M.A.R.T. values in Drive
|
||||||
|
@ -29,6 +30,7 @@ void SMART::readSMARTData(Drive* drive)
|
||||||
errorCount = 0U;
|
errorCount = 0U;
|
||||||
powerOnHours = 0U;
|
powerOnHours = 0U;
|
||||||
powerCycle = 0U;
|
powerCycle = 0U;
|
||||||
|
temperature = 0U;
|
||||||
|
|
||||||
size_t len = 0; //lenght of found line
|
size_t len = 0; //lenght of found line
|
||||||
char* cLine = NULL; //found line
|
char* cLine = NULL; //found line
|
||||||
|
@ -50,9 +52,10 @@ void SMART::readSMARTData(Drive* drive)
|
||||||
SMART::parseErrorCount(sLine);
|
SMART::parseErrorCount(sLine);
|
||||||
SMART::parsePowerOnHours(sLine);
|
SMART::parsePowerOnHours(sLine);
|
||||||
SMART::parsePowerCycle(sLine);
|
SMART::parsePowerCycle(sLine);
|
||||||
|
SMART::parseTemperature(sLine);
|
||||||
}
|
}
|
||||||
pclose(outputfileSmart);
|
pclose(outputfileSmart);
|
||||||
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle); //wirte data in drive
|
drive->setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, powerCycle, temperature); //wirte data in drive
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,3 +179,26 @@ void SMART::parsePowerCycle(string sLine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief parse temperature
|
||||||
|
* \param string output line of smartctl
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
void SMART::parseTemperature(string sLine)
|
||||||
|
{
|
||||||
|
string search("\"current\": ");
|
||||||
|
size_t found = sLine.find(search);
|
||||||
|
if (found!=string::npos)
|
||||||
|
{
|
||||||
|
sLine.erase(0, sLine.find(": ") + 2);
|
||||||
|
sLine.erase(sLine.length()-1, 2);
|
||||||
|
if(sLine == "{")
|
||||||
|
{
|
||||||
|
temperature = 0U; // this drive doesn't support temperatur
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temperature = stol(sLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -74,11 +74,12 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||||
{
|
{
|
||||||
string sModelFamily = it->getModelFamily();
|
string sModelFamily = it->getModelFamily();
|
||||||
string sSerial = it->getSerial();
|
string sSerial = "SN: " + it->getSerial();
|
||||||
string sCapacity = it->sCapacityToText();
|
string sCapacity = it->sCapacityToText();
|
||||||
string sState = " ";
|
string sState = " ";
|
||||||
string sSpeed = " ";
|
string sSpeed = " ";
|
||||||
string sTime = " ";
|
string sTime = " ";
|
||||||
|
string sTemp = it->sTemperatureToText();
|
||||||
|
|
||||||
bool bSelectedEntry = false;
|
bool bSelectedEntry = false;
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, (distance(plistDrives->begin(), it)+1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, bSelectedEntry);
|
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, (distance(plistDrives->begin(), it)+1), sModelFamily, sSerial, sCapacity, sState, sTime, sSpeed, sTemp, bSelectedEntry);
|
||||||
wrefresh(tmp);
|
wrefresh(tmp);
|
||||||
u8Index++;
|
u8Index++;
|
||||||
}//end loop though drives
|
}//end loop though drives
|
||||||
|
@ -308,7 +309,7 @@ WINDOW* TUI::overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart)
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, bool bSelected)
|
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, int iListIndex, string sModelFamily, string sSerial, string sCapacity, string sState, string sTime, string sSpeed, string sTemp, bool bSelected)
|
||||||
{
|
{
|
||||||
WINDOW *newWindow;
|
WINDOW *newWindow;
|
||||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||||
|
@ -333,6 +334,7 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
||||||
mvwaddstr(newWindow,1, 5, sModelFamily.c_str());
|
mvwaddstr(newWindow,1, 5, sModelFamily.c_str());
|
||||||
mvwaddstr(newWindow,2, 5, sSerial.c_str());
|
mvwaddstr(newWindow,2, 5, sSerial.c_str());
|
||||||
mvwaddstr(newWindow,3, 5, sCapacity.c_str());
|
mvwaddstr(newWindow,3, 5, sCapacity.c_str());
|
||||||
|
mvwaddstr(newWindow,3, 5+sCapacity.length()+3, sTemp.c_str());
|
||||||
|
|
||||||
mvwaddstr(newWindow,1, iXSize-sSpeed.length()-5, sSpeed.c_str());
|
mvwaddstr(newWindow,1, iXSize-sSpeed.length()-5, sSpeed.c_str());
|
||||||
mvwaddstr(newWindow,2, iXSize-sState.length()-5, sState.c_str());
|
mvwaddstr(newWindow,2, iXSize-sState.length()-5, sState.c_str());
|
||||||
|
|
Loading…
Reference in New Issue