detect frozen drives and show that the user

This commit is contained in:
2020-09-11 17:18:53 +02:00
parent 5f593682e2
commit 67b8e302be
7 changed files with 103 additions and 15 deletions

View File

@ -91,6 +91,7 @@ void Drive::setTaskPercentage(double d32TaskPercentage)
if(d32TaskPercentage <= 100)
{
this->d32TaskPercentage = d32TaskPercentage;
this->setTimestamp(); //set timestamp for this progress for detecting a frozen drive
}
}
double Drive::getTaskPercentage(void)
@ -125,4 +126,24 @@ void Drive::setDriveSMARTData( string modelFamily,
u32ErrorCount = errorCount;
u32PowerOnHours = powerOnHours;
u32PowerCycles = powerCycle;
}
void Drive::setTimestamp()
{
time(&this->u32Timestamp);
}
void Drive::checkFrozenDrive(void)
{
time_t u32localtime;
time(&u32localtime);
if((u32localtime - this->u32Timestamp) >= (FROZEN_TIMEOUT*60) && (this->u32Timestamp > 0))
{
Logger::logThis()->warning("Drive Frozen: " + this->getModelName() + " " + this->getSerial());
this->bWasDeleteted = false;
this->bWasShredded = false;
this->state = Drive::FROZEN;
}
}