SQL 데이터베이스를 쿼리해 성능 카운터로 저장 (SCOM 2007) - VB Script(VBS) SystemCenter2009. 12. 23. 13:55
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Dim dbcon, strCon
Set dbcon = createobject("adodb.connection")
strCon = "provider=sqloledb;data source=<DB Server IP>;user id=<ID>;password=<Password>;initial catalog=<DB Name>"
dbcon.open strCon
strSQL ="<SQL Query>"
Set Result = dbcon.execute(strSQL)
Do while not Result.eof
strROW1 = Result(0)
strROW2 = Result(1)
strROW3 = Result(2)
strROW4 = Result(3)
strROW5 = Result(4)
....
Result.movenext
loop
set Result = NOTHING
dbcon.close
Call oBag.AddValue("Object",strROW1)
Call oBag.AddValue("Counter","strROW2)
Call oBag.AddValue("Instance",strROW3)
Call oBag.AddValue("PerfValue",strROW4)
Call oAPI.Return(oBag)
============================================================================
$Data/Property[@Name='Object']$
$Data/Property[@Name='Counter']$
$Data/Property[@Name='Instance']$
$Data/Property[@Name='PerfValue']$