display shred speed
This commit is contained in:
parent
0e391cebf3
commit
0d72829f61
@ -1 +1,2 @@
|
|||||||
4673974d
|
4673974d
|
||||||
|
2cb3dea4
|
||||||
|
@ -22,6 +22,13 @@ public:
|
|||||||
FROZEN
|
FROZEN
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
time_t u32ShredTimeDelta;
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> chronoShredTimestamp;
|
||||||
|
unsigned long ulWrittenBytes;
|
||||||
|
} sShredSpeed;
|
||||||
|
|
||||||
|
|
||||||
bool bWasShredded = false;
|
bool bWasShredded = false;
|
||||||
bool bWasDeleteted = false;
|
bool bWasDeleteted = false;
|
||||||
bool bIsOffline = false;
|
bool bIsOffline = false;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Logic
|
// Logic
|
||||||
#define DRYRUN //don´t touch the drives
|
//#define DRYRUN //don´t touch the drives
|
||||||
#define FROZEN_ALERT //show alert if drive is frozen
|
#define FROZEN_ALERT //show alert if drive is frozen
|
||||||
|
|
||||||
//IPC pipes
|
//IPC pipes
|
||||||
|
@ -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, string sModelFamily, string sModelName, string sCapacity, string sState, string sTime, bool bSelected);
|
static WINDOW *createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity, string sState, string sTime, string sSpeed, 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);
|
||||||
@ -65,6 +65,7 @@ private:
|
|||||||
|
|
||||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||||
string formatTimeDuration(time_t u32Duration);
|
string formatTimeDuration(time_t u32Duration);
|
||||||
|
string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // TUI_H_
|
#endif // TUI_H_
|
@ -70,6 +70,9 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
|||||||
|
|
||||||
blockcount_max = SHRED_ITERATIONS*(drive->getCapacity()/4096);
|
blockcount_max = SHRED_ITERATIONS*(drive->getCapacity()/4096);
|
||||||
|
|
||||||
|
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();; //set inital timestamp for speed metric
|
||||||
|
unsigned long ulSpeedMetricBytesWritten = 0U; //uses to calculate speed metric
|
||||||
|
|
||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("Shred-Task: Max-BlockCount: " + to_string(blockcount_max) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: Max-BlockCount: " + to_string(blockcount_max) + " - Drive: " + drive->getSerial());
|
||||||
#endif
|
#endif
|
||||||
@ -177,6 +180,14 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
|||||||
#ifdef LOG_LEVEL_HIGH
|
#ifdef LOG_LEVEL_HIGH
|
||||||
Logger::logThis()->info("Shred-Task: BlockCount: " + to_string(blockcount) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
Logger::logThis()->info("Shred-Task: BlockCount: " + to_string(blockcount) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//set metrics for calculating shred speed
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> chronoCurrentTimestamp = std::chrono::system_clock::now();
|
||||||
|
drive->sShredSpeed.u32ShredTimeDelta = (chronoCurrentTimestamp - drive->sShredSpeed.chronoShredTimestamp).count();
|
||||||
|
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();
|
||||||
|
drive->sShredSpeed.ulWrittenBytes = ulSpeedMetricBytesWritten;
|
||||||
|
ulSpeedMetricBytesWritten = 0U;
|
||||||
|
|
||||||
write(*ipSignalFd, "A",1);
|
write(*ipSignalFd, "A",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +205,9 @@ void Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
|||||||
last = 1;
|
last = 1;
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
l -= write(f, buf, (noround && last) ? l : blksz);
|
size_t write_return = write(f, buf, (noround && last) ? l : blksz);
|
||||||
|
ulSpeedMetricBytesWritten += write_return;
|
||||||
|
l -= write_return;
|
||||||
if (errno)
|
if (errno)
|
||||||
{
|
{
|
||||||
perror(cpDrivePath);
|
perror(cpDrivePath);
|
||||||
|
20
src/tui.cpp
20
src/tui.cpp
@ -78,7 +78,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||||||
string sCapacity = it->sCapacityToText();
|
string sCapacity = it->sCapacityToText();
|
||||||
string sState = " ";
|
string sState = " ";
|
||||||
string sTime = " ";
|
string sTime = " ";
|
||||||
|
string sSpeed = " ";
|
||||||
|
|
||||||
bool bSelectedEntry = false;
|
bool bSelectedEntry = false;
|
||||||
|
|
||||||
@ -107,6 +107,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||||||
|
|
||||||
it->calculateTaskDuration();
|
it->calculateTaskDuration();
|
||||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||||
|
sSpeed = this->formatSpeed(it->sShredSpeed.u32ShredTimeDelta, it->sShredSpeed.ulWrittenBytes);
|
||||||
break;
|
break;
|
||||||
case Drive::DELETE_ACTIVE:
|
case Drive::DELETE_ACTIVE:
|
||||||
sState = "Deleting ...";
|
sState = "Deleting ...";
|
||||||
@ -142,7 +143,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, sModelFamily, sModelName, sCapacity, sState, sTime, bSelectedEntry);
|
WINDOW * tmp = createEntryWindow( ((int)(u16StdscrX/3) - 2), 5, 3, (5* (u8Index) )+3, sModelFamily, sModelName, sCapacity, sState, sTime, sSpeed, bSelectedEntry);
|
||||||
wrefresh(tmp);
|
wrefresh(tmp);
|
||||||
u8Index++;
|
u8Index++;
|
||||||
}//end loop though drives
|
}//end loop though drives
|
||||||
@ -296,7 +297,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, string sModelFamily, string sModelName, string sCapacity, string sState, string sTime, bool bSelected)
|
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity, string sState, string sTime, string sSpeed, bool bSelected)
|
||||||
{
|
{
|
||||||
WINDOW *newWindow;
|
WINDOW *newWindow;
|
||||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||||
@ -320,8 +321,9 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
|||||||
mvwaddstr(newWindow,2, 1, sModelName.c_str());
|
mvwaddstr(newWindow,2, 1, sModelName.c_str());
|
||||||
mvwaddstr(newWindow,3, 1, sCapacity.c_str());
|
mvwaddstr(newWindow,3, 1, sCapacity.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());
|
||||||
mvwaddstr(newWindow,3, iXSize-sState.length()-5, sTime.c_str());
|
mvwaddstr(newWindow,3, iXSize-sTime.length()-5, sTime.c_str());
|
||||||
|
|
||||||
return newWindow;
|
return newWindow;
|
||||||
}
|
}
|
||||||
@ -461,6 +463,16 @@ string TUI::formatTimeDuration(time_t u32Duration)
|
|||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string TUI::formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes){
|
||||||
|
std::ostringstream out;
|
||||||
|
double dDeltaSec = ((double)((u32ShredTimeDelta)/1000000000.0)); //convert nano in sec
|
||||||
|
double speed = ((ulWrittenBytes/1000000.0)/dDeltaSec);
|
||||||
|
char s[25];
|
||||||
|
sprintf(s, "%0.2lf MB/s", speed);
|
||||||
|
out << s;
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
|
||||||
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
void TUI::displaySelectedDrive(Drive drive, int stdscrX, int stdscrY)
|
||||||
{
|
{
|
||||||
struct MenuState menustate;
|
struct MenuState menustate;
|
||||||
|
Loading…
Reference in New Issue
Block a user