BAT script, the main role, every five minutes to read the new content of the day text, to make the wrong choice, if there is an error message, the error message sent to the administrator.
where awk and sed need to be manually downloaded
: Reads the number.txt document to get the number of rows of the file at the last execution
for/f "delims="%%f in (number.txt) does (
Set a=%%f
)
: Read the new row, error filter, import the selection information into the Err file
D:\tools\awk\awk.exe ' {print NR ' "$} ' D:\unitrade\esblls\logs\app.log | D:\tools\sed\sed.exe-n "%a%, $p" | findstr "ERROR" > Error_tj.log
: This is the most time-consuming place for this script, because when I have an error in awk ' Nr>%a%{print}, I add the SED selection start line
Set var= "Error_tj.log"
: Gets the number of file rows, if NULL, no error
for/f "delims="%%i in (%var%) does (
set/a n+=1
)
:::::::::::::------Message parameter::::::::-::::
Set [email protected]
Set User=xxx
Set Pass=xxx
Set to= recipient
Set subj= log Monitoring
Set Mail=error_tj.log
Set Attach=*.jpg
Set server=smtp.163.com
Set Debug=-debug-log Blat.log-timestamp
: Determine if there is data in the Err file, and then send the Err file to the administrator by mail
If%n% GTR 0 (D:\tools\Blat250\full\blat.exe%mail%-to%to%-base64-charset gb2312-subject%subj%-attach%attach%-se RVer%server%-F%from%-u%user%-pw%pass%%debug%)
: Gets the most recent line number and logs it to the Number.txt file
D:\tools\awk\awk.exe ' {print NR} ' D:\unitrade\esblls\logs\app.log | D:\tools\sed\sed.exe-n "$p" > Number.txt
Windows log Monitoring