上一主题: 通过 SNMP 重新配置扩展脚本下一主题: 监控进程


监控日志文件并通过电子邮件发送通知

此示例监控 Windows 修补程序日志文件是否出现致命字符串。 如果出现致命字符串,SystemEDGE 将通过电子邮件发送通知。 此示例由 sysedge.cf 文件的条目以及关联的 Send_Notification_Mail.cmd 脚本组成。

注意:#no_actions 指令不得处于活动状态。 可在其前面放置注释 (#) 字符。

watch logfile 44 0x8 ‘%windir%\KB*.log 'fatal' 'check KB for fatal occurrence in MS hotfix log' "%CASYSEDGE%\My_Scripts\Send_Notification_Mail.cmd" 1 warning

脚本 Send_Notification_Mail.cmd

rem *** Get arguments in which we are interested ***
set regexpr=%3
set lasttime=%5
set description=%6

rem  *** Shift to get argument %10 as %9 ***
shift
set current_file=%9

rem *** Call email *** 
“c:\Program Files\CA\SystemEDGE\bin\email.exe” -r smtp.company.com sysedge@% COMPUTERNAME% you@company.com 'KB log fatal found' ’File monitor %description% activated. %regexpr% pattern found in %current_file% at time %lasttime%’