Windows log Monitoring

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.