この例では、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%
| Copyright © 2011 CA. All rights reserved. | このトピックについて CA Technologies に電子メールを送信する |