Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

Active Monitor issues with WhatsUp Gold

$
0
0
Has anyone here written an active script for WhatsUp Gold to monitor that your SQL Service is actually running?

I've been working on customizing a script, which was publicly available from IPSwitch, to do so for my organization, but regardless of whether my server is actually up or down, it's returning an "UP" status.

My script is below:


On Error Resume Next

'Sending log message to the WhatsUp Event Viewer
Context.LogMessage "Checking Address=" & Context.GetProperty("Address")

'Set the result code of the check (0=Success, 1=Error)
Context.SetResult 0, "No error"



strQuery = "select count( *) as count from nowhere"

'Create connection and recordset objects
Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

'In my actual script it has the real server name, databasename, username and password
'Create the connection string based on the device credentials
objConn.ConnectionString = "Driver={SQL Server};Server=MyServerName;Database=MyDBName;uid=MyUserName;pwd=MyPassword;"

'Open and connect to the database
objConn.Open

'Perform the query and move to the first recordset entry
'in my actual script, this has my real tablename too
'this table always has values in it, so it should always return a count of at least 1 row
objRS.Open "select count( *) as count from tablename", objConn, 3, 3
objRS.MoveFirst


' If there are no records, then no value was returned; therefore an alert should be set off
IF IsNull(objRS) Then
Context.SetResult 1, "SQL Down"
'otherwise, if there IS a result set, the server is up, and it will notify the alert that SQL UP
ELSE
Context.SetResult 0, "SQL Up"
END IF

'Tidy up the objects
objRS.Close
objConn.Close

Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>