?
Solved

vbs script to check MSSQLSERVER

Posted on 2013-10-24
2
Medium Priority
?
229 Views
Last Modified: 2013-11-01
I have the following script running as a scheduled task (has been running for over a year)

(note: computer/email names changed for security)

Set objComputer = GetObject("WinNT://test123,computer")
objComputer.Filter = Array("Service")
            Dim iMsg
            Dim iConf
            Dim Flds
            Dim strHTML
            Dim strSmartHost

            Const cdoSendUsingPort = 2
            StrSmartHost = "mail.test.local"

            set iMsg = CreateObject("CDO.Message")
            set iConf = CreateObject("CDO.Configuration")

            Set Flds = iConf.Fields


            With Flds
                  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
                  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmartHost
                  .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
                  .Update
            End With
For Each aService In objComputer
      select case aService.Name
            case "MSSQLSERVER"
                  if aService.Status <> 4 then
      
                        With iMsg
                              Set .Configuration = iConf
                              .To = "IT@elgin.com"
                              .From = "Webdbadmin@elgin.com"
                              .Subject = "The SQL Server on test123 is not running!"
                              .TextBody = "SQL Server is not running. ."
                              .Send
                        End With
            
                  end if

                  end select
      
Next

      Set iMsg = Nothing
      Set iConf = Nothing
      Set Flds = Nothing


We started receiving the message saying it is not running when it is

Any one have ideas as to why the false negative?
0
Comment
Question by:johnnyg123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Expert Comment

by:lcohan
ID: 39598233
I suggest you add more areas to the Topic (and tags) as this is not (purely) a MS SQL Server question in my opinion.
0
 
LVL 12

Accepted Solution

by:
Seaton007 earned 2000 total points
ID: 39598347
Does this script run locally on the SQL server, or does it run on a remote machine?

Also, it could be that the service had issues, the email was sent, the issues resolved themselves, then somebody checked on the server and found no issues.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question