Script: Query Value from SQL Database (for 2-state monitor)

This sample monitoring script illustrates how run a T-SQL query on a database and sets monitor state based on value returned. Good example of how to dynamically create the connection string when database server & database name must be discovered at runtime.

In this sample, we actually run a query to retrieve the ‘Pending Actions’ count from the SCOM 2007 Operational database. Since the name and server location are up to the administrator, this script actually retrieves the server and database name from the registry (when run on Mgmt Server or RMS), and runs the query.

If the count of Pending Actions is greater than your user defined threshold, it sets the health of a 2-state monitor to BAD.

This sample is intended to run on the RMS to query the Operational Database. For targeting assistance, see the sample MP from which this script was derived, the OpsMgr 2007 Extensions MP

For detailed steps on how to use a script in a script-based 2-state monitor, see the tutorial at the link below.

How to create a script-based 2-state monitor http://www.systemcentercentral.com/Downloads/DownloadsDetails/tabid/144/IndexID/7362/Default.aspx