5

I need to create several counters for a system health check and monitoring. Since there are numerous tools for logging, reporting and alerting Windows Perfmon data, I am looking to publish that data as Perfmon counters.

Some of the values need to come from a SQL Server 2008 database, examples of such are the number of records in a table used as a queue, and the age of the oldest record in the table. While it looks like this can be accomplished by using a SQL Server, User Settable Object and the stored procedures sp_user_counter1 to sp_user_counter10 this limits me to only 10 counters per server and the counter names and descriptions cannot be customized to reflect what the counter is.

Without creating our own application to create the Perfmon counters, are there any other ways to create counters in SQL Server? If not, are there any tools/projects that allow for the creation of custom counters using SQL queries?

4

4 回答 4

1

Late answer - but can be useful to other thread visitors

Besides other mentioned solutions, I can suggest a 3rd party tool called ApexSQL Monitor. It allows the creation of custom SQL performance counters for specific configuration of system on-demand monitoring, historical trending and alerting.

Custom metrics are T-SQL based queries that can be added to this tool. The data collected by those queries can be analyzed and alerted on, just like other built-in metrics.

The following article provides examples of custom SQL performance counters that may be useful: http://solutioncenter.apexsql.com/using-custom-sql-performance-counters-to-monitor-sql-server/

于 2016-10-05T12:12:38.687 回答
0

I think the only way to specifically use SQL server for the custom perfmon data is to use the ten sp_user_counterX stored procs. I did a bit of searching and the only results that came up in my searching were these stored procs.

I do have another suggestion though which requires a bit of coding. This article explains how to create a small application (be it service or console app) that allows you to create as many of your own performance counters as you like. You could use this to create your own counters.

In our organisation we use Idera Diagnostic Manager which we find very useful as we can use the built in metrics to monitor our servers as well as create our own counters. We find that it works very well and although it has quite a hefty price, it is the only monitoring tool that I know of that does not require any sort of agents on the SQL server.

于 2012-04-03T09:15:36.590 回答
0

If you look at the source for the stored procedures, you get:

ALTER procedure [sys].[sp_user_counter2] @newvalue int as
dbcc setinstance ('SQLServer:User Settable', 'Query', 'User counter 2', @newvalue)

=> you can try and call dbcc setinstance with your own counter name

于 2015-05-12T09:19:33.743 回答
0

This can be done with the undocumented DBCC commands:

To create a new metric:

dbcc addinstance ('SQLServer:User Settable', 'MyNewCounter')

To change its value:

dbcc setinstance ('SQLServer:User Settable', 'Query', 'MyNewCounter', 5)

To delete:

dbcc deleteinstance ('SQLServer:User Settable', 'MyNewCounter')
于 2018-03-01T13:39:27.617 回答