Monitor connected consoles

A small and simple script to monitor number of connected SCOM-consoles.

Set oLocator = CreateObject("WbemScripting.SWbemLocator")
Set oWmi = oLocator.ConnectServer(".", "root/snmp/localhost", "")
Set oStats = oWmi.ExecQuery("select * from SNMP_RFC1213_MIB_tcpConnTable where tcpConnLocalPort = 5724 AND tcpConnLocalAddress <> '0.0.0.0' AND tcpConnLocalAddress <> '127.0.0.1'")

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue "ConnectedConsoles", oStats.Count
oAPI.AddItem(oBag)
oAPI.ReturnItems