此示例监控 Windows 上失败或过度任务的任务排定程序。 它由 sysedge.cf 文件的一组条目以及关联的 schedlgu.cmd 脚本组成。 schedlgu.cmd 脚本对 *.job 文件进行计数,分析 %SystemRoot%\Tasks 目录中的 *.txt 文件,并将结果写入 %CASYSEDGE_DATA%\schedlgu.log 文件。 SystemEDGE 启动脚本并监控 schedlgu.log 文件以评估当前状态。
将 schedlgu.cmd 脚本复制到 %CASYSEDGE%\bin 目录,或将其添加到将其发送到 %CASYSEDGE%\bin\managedscripts 目录的配置部署软件包中。
sysedge.cf 的条目
# Windows sample configuration for monitoring the Task Scheduler for failed or excessive tasks extension 55 integer readonly 'schedlgu.cmd %CASYSEDGE_DATA%\schedlgu.log' watch logfile 55 0x0 '%CASYSEDGE_DATA%\schedlgu.log' 'The task completed with an exit code of [(][0]*[^0].*[)]' 'Windows Task Scheduler Job Execution Errors' '' 10 warning watch logfile 56 0x0 '%CASYSEDGE_DATA%\schedlgu.log' 'WARNING' 'Windows Task Scheduler Warnings' '' 10 major watch logfile 57 0x0 '%CASYSEDGE_DATA%\schedlgu.log' 'ERROR' 'Windows Task Scheduler Errors' '' 10 critical monitor oid extensionGroup.55.0 55 0x100 600 absolute > 15 'Number of Scheduled Tasks > 15' '' 'SysHealth' 'Scheduled Tasks' 'Count' 'minor'
扩展脚本 schedlgu.cmd
@echo off
REM SystemEDGE extension script for monitoring Windows Task Scheduler
setlocal
set SLOG=.\schedlgu.log
if "%1" NEQ "" set SLOG=%1
set SDIR=%SystemRoot%\Tasks
set SREC=
set DONE=N
REM Logical records in the Task Scheduler log file span multiple lines.
REM Convert into single line format (as %SLOG%) for monitoring via SystemEDGE.
if exist %SLOG% del %SLOG%
for /f "tokens=*" %%i in ('type "%SDIR%\schedlgu.txt"') do set LINE=%%i&call :parseline
REM Return number of configured tasks
set COUNT=0
for /f "tokens=*" %%i in ('dir /b "%SDIR%\*.job"') do call :countline
echo %COUNT%
endlocal
goto :EOF
:countline
set /a COUNT+=1
goto :EOF
:parseline
REM Replace double quotes with pound sign
set LINE=%LINE:"=#%
REM Check if we have already processed the most recent record in the log
if "%DONE%" EQU "Y" goto :EOF
REM Check for start of next logical record
if "%LINE:~0,1%" EQU "#" goto :startrecord
if "%LINE%" EQU "[ ***** Most recent entry is above this line ***** ]" set DONE=Y&goto :startrecord
REM Concatenate lines for current record
set SREC=%SREC% %LINE%
goto :EOF
:startrecord
if "%SREC%"=="" goto :initrecord
REM Restore double quotes
set SREC=%SREC:#="%
REM Write current record
@echo %SREC%>>"%SLOG%"
:initrecord
set SREC=%LINE%
|
版权所有 © 2013 CA。
保留所有权利。
|
|