• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3604
  • Last Modified:

Batch Script to Email Event Log Warnings / Alerts

I want to create a batch script that will email me (via our exchange smtp) when a warning or error is logged in event viewer.

I found this post http://www.experts-exchange.com/Operating_Systems/Q_21399340.html ; which has this script.

____________________________________________________________________________________________
@echo off
setlocal ENABLEDELAYEDEXPANSION

dumpel -s \\servername -l system -d 1 -m Eventlog -e 6008|find "6008">alert.log
if not errorlevel 1 smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log
____________________________________________________________________________________________

is there a way i can modify this script to do what i want?

Thanks
Phil
0
detox1978
Asked:
detox1978
2 Solutions
 
SteveGTRCommented:
You could schedule this task to run daily:

@echo off

if exist "ALERT.LOG" del "ALERT.LOG" >NUL

REM ** Change server as needed
for /f "delims=" %%a in ('dumpel -s \\server -l system -d 1') do call :PROCESS "%%a"

REM ** Change email info as needed
if exist "ALERT.LOG" smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log

goto :EOF

:PROCESS

for /f "tokens=4" %%a in ('echo %~1') do if /i "%%a" LEQ 2 call :DUMPIT %1

goto :EOF

:DUMPIT

echo %~1>>ALERT.LOG

Good Luck,
Steve
0
 
CowboyJeeperCommented:
The following code will filter for all the errors in the past day and mail as it did before.

dumpel -l system -c -d 1 |find ",1," > c:\aalert.txt
if not errorlevel 1 smtpsend -falert@mydomain.com -tops@mydomain.com -sAlert on Servername -aalert.log
0
 
detox1978Author Commented:
thanks for the scripts....

I dont have smtpsend, do you know of a free commercial version?


Thanks
phil
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
SteveGTRCommented:
I googled it and came up with a number of links. Here is one:

http://www.naughter.com/smtpsend.html
0
 
detox1978Author Commented:
smtpsend is not free for comercial use, is there a way to use exchanges' smpt?
0
 
SteveGTRCommented:
I don't know.
0
 
detox1978Author Commented:
will post in the exchange section...
0
 
neteducationCommented:
The Microsoft Exchange Resource Kit contains a program, SENDMAIL.EXE, which is a 32-bit command line  utility to send mail messages and file attachments. This program is also available in the Microsoft Mail Resource Kit.

0
 
detox1978Author Commented:
cheers, will look into
0
 
detox1978Author Commented:
thanks for the links and tips....

looked into and it seemed like a lot of work.

ended up buy Selm from GFI.


P
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now