Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Mar 2, 2005

Checking the status of weekly rebooted SQL Servers - Page 2

By Muthusamy Anantha Kumar aka The MAK



Step 6


Create c:\checkreboot\sendsmtp.vbs and copy and paste the code below into it. [Refer Fig 1.5]



'Send SMTP Email
'Created by : MAK
'Contact: mak_999@yahoo.com

VEmail=WScript.Arguments(0)
VFilename=WScript.Arguments(1)
VSubject=WScript.Arguments(2)

Const ForReading = 1 
Const ForWriting = 2 

Set fso = CreateObject
 ("Scripting.FileSystemObject") 

Set ReadFile = fso.OpenTextFile
 (VFilename, ForReading, TristateFalse) 
thisTXT = ReadFile.ReadAll 

Set objMessage = 
 CreateObject("CDO.Message") 
objMessage.Subject = VSubject
objMessage.Sender = VEmail
objMessage.To = VEmail
objMessage.TextBody = thisTXT
'msgbox y
'The line below shows how to send 
'a webpage from a remote site 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/
 configuration/sendusing") = 2 
'Name or IP of Remote SMTP Server 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/
 configuration/smtpserver") = 
  "optonline.net" 
'Server port (typically 25) 
objMessage.Configuration.Fields.Item _ 
("http://schemas.microsoft.com/cdo/
 configuration/smtpserverport") = 25 
objMessage.Configuration.Fields.Update 

objMessage.Send


Fig 1.5

Download sendsmtp.vbs_

Note: Please change the SMTP server name to your SMTP server name.

Step 7

Execute the CheckReboot.bat file as shown below. [Refer Fig 1.6]


Fig 1.6

Once you execute this batch file, it checks the status of all of the listed servers and sends two emails. One email will have all of the servers that were not successfully rebooted along with corresponding error messages [Refer Fig 1.7] and another email will have a list of the servers that were successfully rebooted with the proper server name and version. [Refer Fig 1.8]


Fig 1.7


Fig 1.8

If the reboot cycle is around 1AM, schedule this "checkreboot.bat" to be scheduled for 2AM.

Conclusion

This article examined how to get the status of all the rebooted servers on the network.

» See All Articles by Columnist MAK



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM