copy newer S.M.A.R.T. values to existing drive

This commit is contained in:
Hendrik Schutter 2022-08-24 16:11:36 +02:00
parent 2df5ceb0c8
commit 69fd10207d
3 changed files with 30 additions and 25 deletions

View File

@ -37,19 +37,22 @@ public:
private:
string sPath;
string sModelFamily;
string sModelName;
string sSerial;
uint64_t u64Capacity = 0U; //in byte
uint32_t u32ErrorCount = 0U;
uint32_t u32PowerOnHours = 0U; //in hours
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
double d32TaskPercentage = 0U; //in percent for Shred (1 to 100)
time_t u32TimestampTaskStart = 0U; //unix timestamp for duration of an action
time_t u32TaskDuration = 0U; //time needed to complete the task
struct
{
string sModelFamily;
string sModelName;
string sSerial;
uint64_t u64Capacity = 0U; //in byte
uint32_t u32ErrorCount = 0U;
uint32_t u32PowerOnHours = 0U; //in hours
uint32_t u32PowerCycles = 0U;
uint32_t u32Temperature = 0U; //in Fahrenheit, just kidding: degree Celsius
} sSmartData;
private:
void setTimestamp();

View File

@ -14,41 +14,41 @@ string Drive::getPath(void)
string Drive::getModelFamily(void)
{
return sModelFamily;
return sSmartData.sModelFamily;
}
string Drive::getModelName(void)
{
return sModelName;
return sSmartData.sModelName;
}
string Drive::getSerial(void)
{
return sSerial;
return sSmartData.sSerial;
}
uint64_t Drive::getCapacity(void)
{
return u64Capacity;
return sSmartData.u64Capacity;
}
uint32_t Drive::getErrorCount(void)
{
return u32ErrorCount;
return sSmartData.u32ErrorCount;
}
uint32_t Drive::getPowerOnHours(void)
{
return u32PowerOnHours;
return sSmartData.u32PowerOnHours;
}
uint32_t Drive::getPowerCycles(void)
{
return u32PowerCycles;
return sSmartData.u32PowerCycles;
}
uint32_t Drive::getTemperature(void)
{
return u32Temperature;
return sSmartData.u32Temperature;
}
string Drive::sCapacityToText()
@ -124,6 +124,7 @@ double Drive::getTaskPercentage(void)
* \param uint32_t errorCount
* \param uint32_t powerOnHours
* \param uint32_t powerCycle
* \param uint32_t temperature
* \return void
*/
void Drive::setDriveSMARTData( string modelFamily,
@ -135,15 +136,14 @@ void Drive::setDriveSMARTData( string modelFamily,
uint32_t powerCycle,
uint32_t temperature)
{
this->sModelFamily = modelFamily;
sModelName = modelName;
sSerial = serial;
u64Capacity = capacity;
u32ErrorCount = errorCount;
u32PowerOnHours = powerOnHours;
u32PowerCycles = powerCycle;
u32Temperature = temperature;
this->sSmartData.sModelFamily = modelFamily;
this->sSmartData.sModelName = modelName;
this->sSmartData.sSerial = serial;
this->sSmartData.u64Capacity = capacity;
this->sSmartData.u32ErrorCount = errorCount;
this->sSmartData.u32PowerOnHours = powerOnHours;
this->sSmartData.u32PowerCycles = powerCycle;
this->sSmartData.u32Temperature = temperature;
}
void Drive::setTimestamp()

View File

@ -264,6 +264,8 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
if((itOld->getSerial() == itNew->getSerial()) || (itOld->getPath() == itNew->getPath()))
{
itOld->bIsOffline = false; //drive is still attached
//copy new smart data to existing drive
itOld->setDriveSMARTData(itNew->getModelFamily(), itNew->getModelName(), itNew->getSerial(), itNew->getCapacity(), itNew->getErrorCount(), itNew->getPowerOnHours(), itNew->getPowerCycles(), itNew->getTemperature());
#ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("Delete new drive, because allready attached: " + itNew->getModelName());
#endif