Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query to be run from a vbscript in SCOM 2007

Status
Not open for further replies.

AshGoon

Technical User
Aug 9, 2007
5
GB
Hi all

I'm pretty new to both sql queries and vbscript, and yet have been tasked to create a script to run a sql query and add the results to SCOM for alerting and performance data!!

Anyway, I have a query supplied by the vendor and need to know how to incorporate it into a script. The query is:

DECLARE @transPerSec int
EXEC [dbo].[uspCheckTransactionRates]
@nfr = 'NFR-PE01',
@sampleMinutes = 15,
@transPerSec = @transPerSec OUTPUT
SELECT @transPerSec as N'@transPerSec'


I got started with this:

Option Explicit
Dim oArgs, oAPI, oBag, oConnection, oRecordset
Dim transpersec
Dim propertybag

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

transpersec = Int(oArgs.Item(0))

Set oConnection = CreateObject(”ADODB.Connection”)
Set oRecordSet = CreateObject(”ADODB.Recordset”)
Set oCommand = createobject("ADODB.Command")

oConnection.Open "Provider=SQLOLEDB;Data Source=SSM_OLTP;User ID=xx\xxx;Password=;”

Don't know hat you all think of that as a start?

Now I have no idea how to add variables from sql into vbscript. I toyed with strsql to run all of this, but I would think I somehow need to declare these parameters prior to running the SP, but I just don't know how to go about doing this.

The latter part would look something like this:

oBag.AddValue ("transpersec", "transpersec")
oAPI.AddItem(oBag)
oAPI.ReturnItems

But again I'm clutching at straws as to how to get the data into SCOM.

Any help would be much appreciated!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top