Home » Posts tagged 'Ops Mgr R2'

Tag Archives: Ops Mgr R2

Microsoft.MOM.UI.Console.exe /viewname

I have seen a  number of questions about open the Ops Mgr console with a definite view. If you want to do that you can run the Microsoft.MOM.UI.Console.exe command with the /viewname switch. To get the viewname you can follow some tips in this post or you can look in the management pack XML code.

If you for example export and look in the Microsoft.Windows.Server.Library MP you will see a line starting with <View ID=”Microsoft.Windows.Server.Computer.AlertsView”. To start the console with that view run:

Microsoft.MOM.UI.Console.exe /viewname:Microsoft.Windows.Server.Computer.AlertsView

Query a database with a monitor

I have seen a number of questions about how to run queries against a database and verify the answer. One way is to run a script inside a monitor. In this blog I wrote how to setup a script in a two state monitor. The script in this post will count number of  fields, if there are more then five, status of the monitor will be changed. Note that counting starts at 0 with fields collection.

 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=R2B1;” & _
“Trusted_Connection=Yes;Initial Catalog=ContosoConfiguration;” & _
“User ID=CORP\Administrator;Password=;”

objRecordSet.Open “SELECT * FROM roles”, _
objConnection, adOpenStatic, adLockOptimistic

varNo = objRecordSet.Record.Count

If varNO > 5 Then
Call oBag.AddValue(“SQL_Status”,”Error”)
Else
Call oBag.AddValue(“SQL_Status”,”Ok”)
End If

Call oAPI.Return(oBag)