none
scom and sql query

    Question

  • hi

    i need to monitor mssql db with sql query for example: select a from b. and create alert if a=0 (critical state), no alert if a=1 (health state)

    how can i do it?

    may be with two state monitor, but i need script on step "Script"))

    can anyone help?

    thanks in advance

    Wednesday, December 19, 2012 1:38 PM

Answers

All replies

  • Hi

    Try this here http://contoso.se/blog/?p=1346

    Cheers,

    Stefan


    Blog: http://blog.scomfaq.ch

    Wednesday, December 19, 2012 2:07 PM
  • thank you, this link halp me.

    if interesting:

    Dim oAPI, oBag

    Const adOpenStatic = 3
    Const adLockOptimistic = 3

    Set oAPI = CreateObject("MOM.ScriptAPI")
    Set oBag = oAPI.CreatePropertyBag()

    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordSet = CreateObject("ADODB.Recordset")

    objConnection.Open "Provider=SQLOLEDB;Data Source=computer name;Trusted_Connection=Yes;Initial Catalog=db name;User ID=user name;Password=password;"
    objRecordSet.Open "SELECT * FROM c where id=1 AND [date] > DATEADD(minute, -10, getdate())", objConnection, adOpenStatic, adLockOptimistic
    varNo = objRecordSet.RecordCount
    If varNO = 0 Then
    Call oBag.AddValue("Status","Error")
    Call oAPI.Return(oBag)
    Else
    Call oBag.AddValue("Status","Ok")
    Call oAPI.Return(oBag)
    End If

    Friday, December 21, 2012 11:34 AM