I have configured the below mentioned code on our prod servers services to send email notifications when ever a service fails.
On Error Resume Next
strComputer = "USDFW16AS61"
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
'Function block to dynamically retrieve the file size of the report file.
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Authentication type used for SMTP server.
'We are currently using 0, cdoAnonymous
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
'Creates message subject, we are using variables declared earlier in the script
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "CMS Production service iwutild is stopped"
'Sets the From address
objMessage.From = """Support DL"SupportDL@example.com
'Sets the destination, or TO address
objMessage.To = adminDL@example.com
'Sets the CC address. Only used for testing purpose at the moment. Should be commented out when in use.
'objMessage.CC = ""
'Sets the message body, the actual email message. Variables are used in the message which was declared earlier.
objMessage.TextBody = "Dear Administrators, the xyz service is now in STOPPED state." & vbCRLF & vbCRLF & "Please do not reply to this message as it was sent to you by an automated Script."& vbCRLF & vbCRLF & "Thanks and regards"
'objMessage.TextBody = "Dear Application Administrators," & vbCRLF & ""& vbCRLF & ""& vbCRLF &
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "servername"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
'Your UserID on the SMTP server
("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""
'Your password on the SMTP server
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
'Server port (typically 25)
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'==End remote SMTP server configuration section==
'Sends the message using code.
This script is able to send notification only for the respective service that I have configured it to Run upon failure.
My requirement now is that the script should be able to detect out of the 6 app services that are down & should append the email body with the name of that service & send an email.
I understand Wscript.argument(0) can be of use but not able to use it. Could you kindly help?
P.S: I am not a developer, so kindly bear with me :)
- Changed type AnnaWYModerator Thursday, April 24, 2014 8:55 AM
To solve the script issue, I would like to recommend you to post in the Visual Studio Languages forum for more effective support:
or The Official Scripting Guys Forum!
Thank you for your understanding.
- Edited by AnnaWYModerator Wednesday, April 16, 2014 7:37 AM