罪と罰++二律背反

	@REM -------------------------------   日付
	@set A=%date%
	@set D=%A:~5,2%/%A:~8,2%/%A:~0,4%
	@Set F=%A:~2,2%%A:~5,2%%A:~8,2%

	@REM -------------------------------   出力ファイル
	@set LC_DIR=C:\logcheck
	@set L=%LC_DIR%\event_daily\ev%F%.txt

	@REM -------------------------------   時刻チェック
	@echo 時刻チェック
	@echo ローカルタイム %A% %time% > %L%
	@echo ------------------------------ >> %L%

	net time \\SERVER-1 >> %L%
	net time \\SERVER-2 >> %L%
	net time \\SERVER-3 >> %L%

	@REM -------------------------------   
	@set H=SERVER-1
	@echo %H%処理中
	@echo === DATE:%D% HOST:%H% === >> %L%
	@cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L System >> %L%
	@cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L Application >> %L%
	@REM cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L Security >> %L%

	@REM -------------------------------   
	@set H=SERVER2
	@echo %H%処理中
	@echo === DATE:%D% HOST:%H% === >> %L%
	@cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L System >> %L%
	@cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L Application >> %L%
	@REM cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /L Security >> %L%

	@REM -------------------------------   エラーのみを収集
	@set H=SERVER3
	@echo %H%処理中
	@echo === DATE:%D% HOST:%H% === >> %L%
	cscript c:\windows\system32\eventquery.vbs /S %H% /FI "Datetime gt %D%,01:00:00AM" /FI "Type eq Error" >> %L%

	@REM @call %L%
	@REM メールで送信
	@Call cscript %LC_DIR%\mail.vbs %L%
	Set oMsg = CreateObject("CDO.Message")

	' 引数を取得
	Set args = Wscript.Arguments

	' -------------------------------------------------------------------
	' 設定

	' サーバ名
	server_name = "SERVER-1"
	notify_addr = "<hoge@example.com>"
	' 送信ファイル名
	mail_file = args(0)
	
	' 送信元
	oMsg.From = server_name & notify_addr
	' 宛て先
	oMsg.To = notify_addr
	' 件名
	oMsg.Subject = "定期ログ:" & server_name
	' メールサーバ
	mail_server = "mail.example.com"


	' ファイル読み込み
	Set oFS = CreateObject("Scripting.FileSystemObject")
	Set oFile = oFS.OpenTextFile (mail_file, 1)
	text1 = oFile.ReadAll
	oFile.Close
	
	oMsg.TextBody = Now & vbCrlf & text1
	oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mail_server
	oMsg.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	oMsg.Configuration.Fields.Update
	oMsg.Send

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2012-06-08 (金) 00:24:46 (4341d)