Compare commits
4 Commits
b0.2.2
...
9863c5591e
Author | SHA1 | Date | |
---|---|---|---|
9863c5591e | |||
c61859ed4e | |||
8de45505e4 | |||
f8ba9c6732 |
@ -22,6 +22,12 @@ public:
|
||||
FROZEN
|
||||
} state;
|
||||
|
||||
struct {
|
||||
time_t u32ShredTimeDelta;
|
||||
std::chrono::time_point<std::chrono::system_clock> chronoShredTimestamp;
|
||||
unsigned long ulWrittenBytes;
|
||||
} sShredSpeed;
|
||||
|
||||
bool bWasShredded = false;
|
||||
bool bWasDeleteted = false;
|
||||
bool bIsOffline = false;
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
static WINDOW *createOverViewWindow( int iXSize, int iYSize);
|
||||
static WINDOW *createDetailViewWindow( int iXSize, int iYSize, int iXStart, Drive drive);
|
||||
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 *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);
|
||||
@ -66,6 +66,7 @@ private:
|
||||
|
||||
void displaySelectedDrive(Drive drive, int stdscrX, int stdscrY);
|
||||
string formatTimeDuration(time_t u32Duration);
|
||||
string formatSpeed(time_t u32ShredTimeDelta, unsigned long ulWrittenBytes);
|
||||
|
||||
};
|
||||
#endif // TUI_H_
|
4
makefile
4
makefile
@ -12,7 +12,7 @@ LIBS =
|
||||
# General compiler flags
|
||||
COMPILE_FLAGS = -std=c++17 -Wall -Wextra -g
|
||||
# Additional release-specific flags
|
||||
RCOMPILE_FLAGS = -D NDEBUG
|
||||
RCOMPILE_FLAGS = -D NDEBUG -O3
|
||||
# Additional debug-specific flags
|
||||
DCOMPILE_FLAGS = -D DEBUG
|
||||
# Add additional include paths
|
||||
@ -51,7 +51,7 @@ ifeq ($(V),true)
|
||||
endif
|
||||
|
||||
# Combine compiler and linker flags
|
||||
release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS)
|
||||
release: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(RCOMPILE_FLAGS)
|
||||
release: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(RLINK_FLAGS)
|
||||
debug: export CXXFLAGS := $(CXXFLAGS) $(COMPILE_FLAGS) $(DCOMPILE_FLAGS)
|
||||
debug: export LDFLAGS := $(LDFLAGS) $(LINK_FLAGS) $(DLINK_FLAGS)
|
||||
|
@ -2,15 +2,17 @@
|
||||
|
||||
echo starting update
|
||||
|
||||
systemctl stop /lib/systemd/system/getty@tty1.service.d
|
||||
|
||||
cd /root/reHDD/
|
||||
|
||||
FILE=./ignoreDrives.conf
|
||||
if test -f "$FILE"; then
|
||||
echo backup exits
|
||||
else
|
||||
cp reHDD/ignoreDrives.conf ./ignoreDrives.conf
|
||||
cp /root/reHDD/ignoreDrives.conf /root/ignoreDrives.conf
|
||||
fi
|
||||
|
||||
cd reHDD
|
||||
|
||||
git reset
|
||||
|
||||
git stash force
|
||||
@ -23,4 +25,6 @@ git pull
|
||||
|
||||
make release
|
||||
|
||||
cp ../ignoreDrives.conf ./
|
||||
cp /root/ignoreDrives.conf /root/reHDD/ignoreDrives.conf
|
||||
|
||||
systemctl start /lib/systemd/system/getty@tty1.service.d
|
@ -64,6 +64,8 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
}
|
||||
|
||||
this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr);
|
||||
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
|
||||
Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial());
|
||||
@ -73,6 +75,7 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
{
|
||||
unsigned long ulDriveByteCounter = 0U; //used for one shred-iteration to keep track of the current drive position
|
||||
uint32_t u32ChunkDimensionIndex = 0U;
|
||||
|
||||
|
||||
if(uiShredIterationCounter == (SHRED_ITERATIONS-1))
|
||||
{
|
||||
@ -136,14 +139,25 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
ulDriveByteCounter += iByteShredded;
|
||||
ulDriveByteOverallCount += iByteShredded;
|
||||
d32Percent = this->calcProgress();
|
||||
ulSpeedMetricBytesWritten += iByteShredded;
|
||||
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("Shred-Task: ByteCount: " + to_string(ulDriveByteCounter) + " - iteration: " + to_string((uiShredIterationCounter+1)) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||
#endif
|
||||
if((d32Percent-d32TmpPercent) >= 0.01)
|
||||
{
|
||||
//set shred percantage
|
||||
drive->setTaskPercentage(d32TmpPercent);
|
||||
d32TmpPercent = d32Percent;
|
||||
|
||||
//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;
|
||||
|
||||
//signal process in shreding
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
|
||||
|
20
src/tui.cpp
20
src/tui.cpp
@ -77,9 +77,9 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
string sModelName = it->getModelName();
|
||||
string sCapacity = it->sCapacityToText();
|
||||
string sState = " ";
|
||||
string sSpeed = " ";
|
||||
string sTime = " ";
|
||||
|
||||
|
||||
bool bSelectedEntry = false;
|
||||
|
||||
if(u8SelectedEntry == u8Index)
|
||||
@ -107,6 +107,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
|
||||
it->calculateTaskDuration();
|
||||
sTime = this->formatTimeDuration(it->getTaskDuration());
|
||||
sSpeed = this->formatSpeed(it->sShredSpeed.u32ShredTimeDelta, it->sShredSpeed.ulWrittenBytes);
|
||||
break;
|
||||
case Drive::DELETE_ACTIVE:
|
||||
sState = "Deleting ...";
|
||||
@ -151,7 +152,7 @@ void TUI::updateTUI(list <Drive>* plistDrives, uint8_t u8SelectedEntry)
|
||||
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);
|
||||
u8Index++;
|
||||
}//end loop though drives
|
||||
@ -305,7 +306,7 @@ WINDOW* TUI::overwriteDetailViewWindow( int iXSize, int iYSize, int iXStart)
|
||||
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;
|
||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||
@ -329,8 +330,9 @@ WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart,
|
||||
mvwaddstr(newWindow,2, 1, sModelName.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,3, iXSize-sState.length()-5, sTime.c_str());
|
||||
mvwaddstr(newWindow,3, iXSize-sTime.length()-5, sTime.c_str());
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
@ -506,6 +508,16 @@ string TUI::formatTimeDuration(time_t u32Duration)
|
||||
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)
|
||||
{
|
||||
struct MenuState menustate;
|
||||
|
Reference in New Issue
Block a user