fix(bklog):Fix flip-flopped buffer start/end timestamps
[EVA-2020-02.git] / exec / bklog
index 62c0901f9b9e099bc00ccf384bf7cc412a4f90e0..b4c8257ea8ee9bf782c08fbeaef3429e0e2581c9 100644 (file)
@@ -11,7 +11,7 @@ dirTmpDefault="/dev/shm"; # Default parent of working directory
 
 # Script Metadata
 scriptName="bklog";             # Define basename of script file.
 
 # Script Metadata
 scriptName="bklog";             # Define basename of script file.
-scriptVersion="0.1.27";          # Define version of script.
+scriptVersion="0.1.28-test3";          # Define version of script.
 scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script.
 scriptTimeStart="$(date +%Y%m%dT%H%M%S.%N)"; # YYYYmmddTHHMMSS.NNNNNNNNN
 scriptHostname=$(hostname);     # Save hostname of system running this script.
 scriptURL="https://gitlab.com/baltakatei/ninfacyzga-01"; # Define wesite hosting this script.
 scriptTimeStart="$(date +%Y%m%dT%H%M%S.%N)"; # YYYYmmddTHHMMSS.NNNNNNNNN
 scriptHostname=$(hostname);     # Save hostname of system running this script.
@@ -1431,14 +1431,13 @@ main() {
     while [[ $SECONDS -lt "scriptTTL" ]]; do
        vbm "STATUS:$fn:Starting buffer round:$bufferRound";
        bufferTOD="$(( (1+bufferRound)*bufferTTL ))" && vbm "DEBUG :$fn:bufferTOD:$bufferTOD"; # Set buffer round time-of-death
     while [[ $SECONDS -lt "scriptTTL" ]]; do
        vbm "STATUS:$fn:Starting buffer round:$bufferRound";
        bufferTOD="$(( (1+bufferRound)*bufferTTL ))" && vbm "DEBUG :$fn:bufferTOD:$bufferTOD"; # Set buffer round time-of-death
-       # Note start time of data collection
-       timeBufferStartEpoch="$(date +%s)" && vbm "DEBUG :$fn:timeBufferStartEpoch:$timeBufferStartEpoch";
        # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
        while read -r -t "$bufferTTL" line && [[ $SECONDS -lt "$bufferTOD" ]]; do
            # Append line to buffer array
            buffer+=("$line");
        done;
        # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
        while read -r -t "$bufferTTL" line && [[ $SECONDS -lt "$bufferTOD" ]]; do
            # Append line to buffer array
            buffer+=("$line");
        done;
-       # Note end time of data collection
+       # Mark time for buffer
+       timeBufferStartEpoch="$timeBufferEndEpoch" && vbm "DEBUG :$fn:timeBufferStartEpoch:$timeBufferStartEpoch";
        timeBufferEndEpoch="$(date +%s)" && vbm "DEBUG :$fn:timeBufferEndEpoch:$timeBufferEndEpoch";
        # Create dir_tmp if missing
        if ! [[ -d "$dir_tmp" ]]; then
        timeBufferEndEpoch="$(date +%s)" && vbm "DEBUG :$fn:timeBufferEndEpoch:$timeBufferEndEpoch";
        # Create dir_tmp if missing
        if ! [[ -d "$dir_tmp" ]]; then