EDIT: Hold off on using the code below, it is not correctly detecting the servioce freeze as the log file continues to be written with updated timestamps even when the values are not being updated. I forgot this when creating the code.
Hi all,
OK, I think I've got the batch file working, it's a bit of a kludge, if anyone would like to improve it, feel free! At the moment, all values are hardcoded, I may update it in the future to allow timeouts to be easily edited but this works for me.
1/ Set iCue to output sensor logs to a local folder every 120 seconds (this can be altered but not more than 600 seconds).
2/ Copy the code below into a file and name it 'Check.bat'. Be careful of Windows hiding the file extension 'Check.bat.txt' will not work. Ensure this file is in the same folder as the .csv files that are output by iCue.
3/ Use Windows Task Scheduler to run the batch file once every 5 minutes. Make sure you check the setting shown in the last image ("Run task as soon as possible after a scheduled start is missed") if you shut down your computer at night.
The batch file will search the folder for the most recent .csv file and will create a copy (because iCue holds a lock on the original file). It will then delete any .csv files more than 1 day old. It will extract the last line from the file and parse out the time of the most recent entry. If this entry is more than 5 minutes old, it will restart the "Corsair Service" on the local machine.
Testing has been limited, this is more of a starting point but should work fine however, it should go without saying that using this is at your own risk, I cannot see how it would cause any harm but....
Also, I will be around to assist if possible but responses may be slow!
Finally; a rant! Whilst this certainly doesn't address the root cause of the issue, I feel it would not take much effort from Corsair to implement something internally!
@echo off
cls
setlocal EnableDelayedExpansion
del "tempBat.txt"
for /f %%i in ('dir /b/a-d/od/t:c') do set LAST=%%i
echo The most recently created file is %LAST%
copy %LAST% "tempBat.txt"
echo Removing all old files...
forfiles /D -1 /M *.csv /C "cmd /c del @file"
set /A firstTail=1, lastTail=0
for /F "delims=" %%a in (tempBat.txt) do (
set /A lastTail+=1, lines=lastTail-firstTail+1
set "lastLine[!lastTail!]=%%a"
if !lines! gtr 1 (
set "lastLine[!firstTail!]="
set /A firstTail+=1
)
)
@for /L %%i in (%firstTail%,1,%lastTail%) do (set logTime=!lastLine[%%i]:~0,21!)
@echo.
if %logTime:~4,1%==/ (
set logTime=%logTime:~10,8%
) else (
set logTime=%logTime:~11,8%
)
set logTime=%logTime%.00
@echo logTime: %logTime%
@echo ActualTime: %TIME%
set startTime=%logTime%
set endTime=%TIME%
@echo.
rem Get elapsed time:
set "end=!endTime:%time:~8,1%=%%100)*100+1!" & set "start=!startTime:%time:~8,1%=%%100)*100+1!"
set /A "elap=((((10!end:%time:~2,1%=%%100)*60+1!%%100)-((((10!start:%time:~2,1%=%%100)*60+1!%%100)"
echo Elapsed (Seconds): %elap:~0,-2%
set %elap%=%elap:~0,-2%
@echo.
if %elap% gtr 60000 (
@echo Service Failed
net stop "Corsair Service"
net Start "Corsair Service"
) else (
@echo Service Running
)
@echo.