Add advwb1_applylogemail.vbs and advwb2_applylogemail.vbs to periodically send emails containing the applylog.log from the standby server.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@5456 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2008-06-24 15:44:05 +00:00
parent 1e11213b27
commit dbb94fffbd
2 changed files with 144 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
REM $Id$
const scripts_src = "\\advwb2\scripts"
const logship_user = "advweb\logship"
const logship_pwd = "logship"
const strFrom = "webmip@AdvanticaGroup.com"
const strTo = "Andrew.Hardy@AdvanticaGroup.com"
const strSub = "MIP: ApplyLog"
const strSubError = "MIP: ApplyLog Error"
strBody = "ApplyLog Completed Successfully"
const strSMTP = "relay01.sleek.net"
ShowApplyLog scripts_src, logship_user, logship_pwd
Sub ShowApplyLog(strDest, strUser, strPwd)
Dim strAttachment
strAttachment = "X:\applylog.log"
Dim strRemoteDrive
strRemoteDrive = "X:"
'error handling
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
SendEmail strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment
objNetwork.RemoveNetworkDrive strRemoteDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
End Sub
' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0
Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment)
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.AddAttachment strAttachment
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send
If Err.Number <> 0 Then
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Email sent"
End Sub

View File

@@ -0,0 +1,72 @@
REM $Id$
const scripts_src = "\\advwb1\scripts"
const logship_user = "advweb\logship"
const logship_pwd = "logship"
const strFrom = "webmip@AdvanticaGroup.com"
const strTo = "Andrew.Hardy@AdvanticaGroup.com"
const strSub = "MIP: ApplyLog"
const strSubError = "MIP: ApplyLog Error"
strBody = "ApplyLog Completed Successfully"
const strSMTP = "relay01.sleek.net"
ShowApplyLog scripts_src, logship_user, logship_pwd
Sub ShowApplyLog(strDest, strUser, strPwd)
Dim strAttachment
strAttachment = "X:\applylog.log"
Dim strRemoteDrive
strRemoteDrive = "X:"
'error handling
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strRemoteDrive, strDest, false, strUser, strPwd
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Mapping " & strDest & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
SendEmail strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment
objNetwork.RemoveNetworkDrive strRemoteDrive
'handle error
If Err.Number <> 0 Then
SendEmail strFrom, StrTo, strSubError, "Error Removing Remote Folder " & strRemoteDrive & ":" & Err.Description, StrSMTP
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
End Sub
' From the book "Windows Server Cookbook" by Robbie Allen
' ISBN: 0-596-00633-0
Sub SendEmail(strFrom, StrTo, strSub, strBody, StrSMTP, strAttachment)
set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.AddAttachment strAttachment
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send
If Err.Number <> 0 Then
Wscript.Echo "Error number " & Err.Number & " occured: " & Err.Description
Wscript.Echo ""
Wscript.Quit Err.Number
End If
WScript.Echo "Email sent"
End Sub