Windows Server 2008发送错误消息事件日志错误

我们目前有一台Windows Server 2008计算机,我们使用“自定义任务”configuration了每当某个事件日志中发生错误时发送电子邮件。 触发器完美工作,并在需要时发送电子邮件。

但是,我们无法find让电子邮件包含错误信息的方法,特别是错误信息。 有没有办法根据事件日志错误的内容来更改消息?

也许eventtriggers是你的答案? 我对Server 2008还不是很熟悉,但是我曾经在2003年一直使用事件触发器。让我们做任何你想做的事情,因为你可以运行你写的任何命令或脚本。

http://www.petri.co.il/how-to-use-eventtriggersexe-to-send-e-mail-based-on-event-ids.htm

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/eventtriggers.mspx?mfr=true

使用eventtriggers来触发VBscript运行。 您可以使用像下面这样的脚本来发送最近发生的错误,但是我还没有把它放到生产环境中,因为它在WMIPRVSE.EXE服务器上导致了高CPU占用率(我假设这是处理WMI查询)。

警告:以下脚本会导致CPU使用率过高,并且尚未准备好用于高使用率/任务关键型系统

strComputer = "." Dim emailText emailText = "An error has occurred on [server_name]. This email was generated by eventtriggers.exe on [server_name]. Run eventtriggers.exe /? at the command prompt on [server_name] for help with managing event triggers." & vbNewLine & vbNewLine & "Recent Errors:" & vbCrLf Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colLoggedEvents = objWMIService.ExecQuery _ ("Select * from Win32_NTLogEvent " _ & "Where Type = 'Error'") Dim count count=0 For Each objEvent in colLoggedEvents emailText = emailText & "*****************************************************************************" & vbNewLine & vbNewLine & objEvent.Message & vbNewLine & vbNewLine count = count + 1 If count > 4 then Exit For End If Next Set objEmail = CreateObject("CDO.Message") objEmail.From = "[email protected]" objEmail.To = "[email protected]" objEmail.Subject = "Server Error" objEmail.Textbody = emailText objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "[ENTER YOUR SERVER HERE]" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objEmail.Configuration.Fields.Update objEmail.Send 

或者,看看这个答案: Windows事件日志 – 电子邮件通知