none
How does targeting a specific instance works in SCOM ?

    Pregunta

  • Hello,

    So we have the follow question/situation.

    We have made a very simple VBS script that runs a store procedure and the result of it is being used for a two state monitor. Pretty straight forward, here is the script itself:

    Dim Connection
    Dim Recordset
    Dim SQL
    Dim Server
    Dim field
    Dim oAPI
    Dim oBag
    
    SQL = "exec get_rawdata_delay"
    Set Connection = CreateObject("ADODB.Connection")
    Set Recordset = CreateObject("ADODB.Recordset")
    Connection.Open "Provider=SQLOLEDB;Data Source=localhost\HiD_19505;Database=master;UID=scomdelaycheck;PWD=somepassword
    Recordset.Open SQL,Connection
    
    If not Recordset.EOF Then
    field = Recordset(0)
    wscript.echo field
    End If
    
    Recordset.Close
    Set Recordset=nothing
    Connection.Close
    Set Connection=nothing
    
    'SCOM Parms
    Set oAPI = CreateObject("MOM.ScriptAPI")
    Set oBag = oAPI.CreatePropertyBag()
    Call oBag.AddValue("DelayInSeconds",field)
    Call oAPI.Return(oBag)  

    The two state monitor is being targeted to the global class of "SQL Server 2012 DB Engine" and disabled as default.

    What we would like to understand and to achieve is how to edit the connection string in the VBS Script, so that it can properly work on specific targeted instances of our SQL DB servers?

    I understood that based on the overrides made in the system, I can target specific objects(instances) of SQL DB engine.

    The thing is that even though a proper override is made for the desired instance, when we edit the connection string in the VBS and remove let's say the "Data Source=localhost\HRD_19505" the script stops working.
    Maybe we just need to put for Data Source localhost, even thought this again doesn't work :(

    So it is a bit confusing how to make it so it can work on different instances.


    Thank you.







    • Editado Sakrayaami miércoles, 4 de julio de 2018 12:31
    miércoles, 4 de julio de 2018 12:19

Todas las respuestas

  • You need to pass the target's connection string as a parameter to the script, with something like 

    $Target/Property/[Type="SQL2012!Microsoft.SQLServer.2012.DBEngine"]/ConnectionString$

    And then fetch the parameter inside the script : 

    Dim ConnectionString

    ConnectionString = WScript.Arguments(0)

    And use this variable in your Connection.Open line.

    miércoles, 4 de julio de 2018 12:58
  • 1) In script monitor wizard, click parameters button to add following as parameter $Target/Property[Type="MicrosoftSQLServerCoreLibrary67650!Microsoft.SQLServer.Core.DBEngine"]/MachineName$
    2) Also on script monitor add following statement as a datasource name
    sComputerName = WScript.Arguments(0)

    Roger


    jueves, 5 de julio de 2018 3:37
  • Thank you for the replies guys,

    Should I define this:

    sComputerName = WScript.Arguments(0)

    As a parameter and then use the sComputerName as a parameter in the Data Source name?

    • Editado Sakrayaami jueves, 5 de julio de 2018 6:40
    jueves, 5 de julio de 2018 6:32
  • no, the parameter should be the $Target/blabla thing.

    sComputerName = WScript.Arguments(0) goes inside the script, it is used to map this parameter to a variable you can use inside the script.

    And then yes you use the variable (sComputerName or sConnectionString, depending on which one you'd like to use) in the data source

    jueves, 5 de julio de 2018 6:57
  • Ok Thanks,

    I understood this with the parameter.

    Now when I try to create the monitor I got the following Error:

    Note:  The following information was gathered when the operation was attempted.  The information may appear cryptic but provides context for the error.  The application will continue to run.
    
    : Verification failed with 1 errors:
    -------------------------------------------------------
    Error 1:
    Found error in 1|ManagementPack2|1.0.0.0|UIGeneratedMonitor43a9582631f54ab98410b2ae72ca9c3b|| with message:
    Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor43a9582631f54ab98410b2ae72ca9c3b failed.
    : Cannot resolve identifier MicrosoftSQLServerCoreLibrary67650!Microsoft.SQLServer.Core.DBEngine in the context of management pack ManagementPack2. Unknown alias: MicrosoftSQLServerCoreLibrary67650
    
    -------------------------------------------------------
    
    
    : Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor43a9582631f54ab98410b2ae72ca9c3b failed.
    
    : Cannot resolve identifier MicrosoftSQLServerCoreLibrary67650!Microsoft.SQLServer.Core.DBEngine in the context of management pack ManagementPack2. Unknown alias: MicrosoftSQLServerCoreLibrary67650
    
    

    I'm using a MP in which I've placed all of the SQL mp references provided within the original SQL 2012 MP>

    Any ideas?

    lunes, 9 de julio de 2018 6:40
  • You're not using the proper alias, double check what alias you used in the References part of the MP
    lunes, 9 de julio de 2018 6:52
  • Really strange,

    I have tried to place all the available aliases for SQL mp in the new MP inside VSAE, and still I got this error.
    Do you know where to find MicrosoftSQLServerCoreLibrary67650 in order to include it as an alias/reference?

    lunes, 9 de julio de 2018 8:09
  • There is 2 things you need to consider : 

    1. As you say, you need to add it as a reference. If you don't have done it already, you can find it in the MP for any SQL version from technet (not the exact same version though, if you do actually need 6.7.65.0 you wil find it here 

    2. You need to check what Alias you used to reference it. Right now, it could be already be referenced as "SQLCore" or maybe "MSSCoreLib" or whatever instead of MicrosoftSQLServerCoreLibrary67650. So in VSAE, double check what alias is used.

    lunes, 9 de julio de 2018 8:20
  • Alright,
    I got a small progress.
    I've found that in the MP that I'm using the Sql Core Lib alias is named "SQL" so I have edited the script parameters to $Target/Property

    [Type="SQL!Microsoft.SQLServer.Core.DBEngine"]/MachineName$

    Now I got a slightly different error message:


    Date: 09.07.2018 15:16:30
    Application: Operations Manager
    Application Version: 7.1.10226.1387
    Severity: Error
    Message: 
    
    : Verification failed with 1 errors:
    -------------------------------------------------------
    Error 1:
    Found error in 1|Intel.Raw.Data.Delay|1.0.0.0|UIGeneratedMonitor72e73902420e47409aa72fb4371fe916|| with message:
    Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor72e73902420e47409aa72fb4371fe916 failed.
    : Cannot find ManagementPackElement [Type=ManagementPackClass, ID=Microsoft.SQLServer.Core.DBEngine] in management pack ManagementPack:[Name=Microsoft.SQLServer.Library, KeyToken=31bf3856ad364e35, Version=7.0.4.0].
    
    -------------------------------------------------------
    
    
    : Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor72e73902420e47409aa72fb4371fe916 failed.
    
    : Cannot find ManagementPackElement [Type=ManagementPackClass, ID=Microsoft.SQLServer.Core.DBEngine] in management pack ManagementPack:[Name=Microsoft.SQLServer.Library, KeyToken=31bf3856ad364e35, Version=7.0.4.0].
    




    • Editado Sakrayaami lunes, 9 de julio de 2018 13:19
    lunes, 9 de julio de 2018 13:17
  • Microsoft.SQLServer.Core.DBEngine class is contained in Microsoft.SQLServer.Core.Library management pack, not in Microsoft.SQLServer.Library management pack.

    • Editado CyrAz lunes, 9 de julio de 2018 14:24
    lunes, 9 de julio de 2018 14:24
  • Ok I understood my mistake in that case, and I have used the Microsoft.SQLServer.Core.Library  instead of Microsoft.SQLServer.Library management pack.

    Now it seems that there is a different error:

    : Verification failed with 1 errors:
    -------------------------------------------------------
    Error 1:
    Found error in 1|test|1.0.0.0|UIGeneratedMonitor954b8c63840247a98a9e0d892f173985|| with message:
    Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor954b8c63840247a98a9e0d892f173985 failed.
    : Host reference error in expression: $Target/Property[Type="Alias6!Microsoft.SQLServer.Core.DBEngine"]/MachineName$
    The specified ClassType was 'Microsoft.SQLServer.Core.DBEngine' and the resolved ClassType (evaluating the /Host references) was 'Microsoft.SQLServer.DBEngine'.
    Check the number of '/Host' references in this expression.
    
    -------------------------------------------------------
    
    
    : Verification of Monitor Configuration with MonitorType schema for Monitor UIGeneratedMonitor954b8c63840247a98a9e0d892f173985 failed.
    
    : Host reference error in expression: $Target/Property[Type="Alias6!Microsoft.SQLServer.Core.DBEngine"]/MachineName$
    The specified ClassType was 'Microsoft.SQLServer.Core.DBEngine' and the resolved ClassType (evaluating the /Host references) was 'Microsoft.SQLServer.DBEngine'.
    Check the number of '/Host' references in this expression.






    • Editado Sakrayaami miércoles, 11 de julio de 2018 6:19
    miércoles, 11 de julio de 2018 6:19
  • Your rule or monitor is targeted at Microsoft.SQLServer.DBEngine class, while you are trying to use a property belonging to another class (Microsoft.SQLServer.Core.DBEngine).

    So you may target your rule or monitor at Microsoft.SQLServer.Core.DBEngine class, or if there is a hosting relationship between the two classes you can write it like that : $Target/Host/Property[Type="Alias6!Microsoft.SQLServer.Core.DBEngine"]/MachineName$



    • Editado CyrAz miércoles, 11 de julio de 2018 10:45
    miércoles, 11 de julio de 2018 8:42
  • Alright,

    The only way this works is if I targeted it to MSSQL: Generic DB Engine.
    If I try for example to target it to the SQL DB Engine again I got an error like the one above.

    And when I try to use the MSSQL: Generic DB Engine, I'm unable to set override in order to enable the monitor just for specific instances on which the Monitor should be enabled.

    Trying out other targets, but the situation is the same.

    Hey and thank you very much for the effort of still following up on the topic, I will make a nice walk through how to do this type of monitor as soon as I make it work in my environment.


    • Editado Sakrayaami miércoles, 11 de julio de 2018 10:49
    miércoles, 11 de julio de 2018 10:44