SQL MP Extensions – MP Authoring Tutorial Part 1 – Getting Ready

In the main post (here) I published the SQL MP Extensions Management Pack and within this post series I will be providing an Authoring Tutorial explaining the MP. This first post of the tutorial series is focusing how to get ready to start authoring.

To author an MP requires to be confident on the following bullets.

  • Knowing the Scenario; Learn the problem and scope your solution to an achievable goal.
  • Knowing the Target Technology; Colloborate with the SMEs of the techonolgy you are going to monitor. Try to understand
    • How to monitor, What method?
    • What are the cons of the method advised?
  • Knowing SCOM;
    • With what MPElements will you achieve your goal?
      • Do I need a custom MonitorType? Custom DataSource?
      • Is cookdown needed?
    • Can this be achievable via SCOM Console?


Knowing the Scenario

It was a common request from customers that they need to figure out unused databases in order to decomission and gain resources back (disk, cpu, memory). So the major idea here was return of unused resources.

Knowing the Target Technology

I queried my SQL colleagues Sibel (CTS) and Batuhan (PFE)  on how to pull this information out of SQL. There was no perfect feature for this but we had one. SQL Index Usage Statistics (sys.dm_db_index_usage_stats - http://msdn.microsoft.com/en-us/library/ms188755.aspx)

Sth similar to this will do fine;

select DB_NAME(database_id) as dbname, datediff(dd,max(isnull(isnull(last_user_scan, last_user_update), isnull(last_user_seek, last_system_scan))),GETDATE()) as numofdays from sys.dm_db_index_usage_stats  group by DB_NAME(database_id)

My colleagues also warned my that these statistics are reset once the SQL service restarted which is very important on my monitoring model. I was fine with this because my main goal was to figure out if a database was unused for "sometime" so it might reset the state to "green" when the service starts but if it is really unused it will go "red" after the threshold speciefied is reached. Kind of flip-flop but as rare as the service starts.

The only problem might be the databases which are idle for long and only used in long intervals (payrolls db once a month???) but if this is documented (Knowledge Articles) then the DBA and SCOM Admin knows how to override the threshold and the problem is solved.

Knowing SCOM

I now know that index usage tables has the information and I have the sql query that pulls the information as well as the problems I might hit with acceptable solutions. There was nothing stopping me (Really??? - Actually no - just be patient:) ) to use the existing Monitor type Timed Script Two State Monitor and Author the MP Through Operations Console (hell no!).

I would have easily jumped in the Operations Console and create a monitor based on the “Timed Script Two State Monitor” type (I didnt!!!)


But when I finish NEXTing this Wizard My Monitor will be targeted to the SQL 2008 Database Class since I want to affec the health of the Databases. What about if I have a SQL Server with 10 Instances and 50 databases on each instance??? the answer is easy if I use the OOB MonitorType 500 scripts will run at a time. I wouldnt want this to occur on my servers.

The existing MonitorType didnt help in this case (it only does if you have few instances of what you target) and I need to create my own MonitorType which does run the script once and collects data for all (this is named as cookdown).

Tools Required

Authoring a monitortype which has a datasource that supports cookdown is not avaiable in Operations Console. But is available via

  • MP authoring console – This is retired and we wont use it.
  • Visual Studio Authoring Extensions – This is the new tool with following major benefits.
    • Great documentation on TechNet Wiki
    • Management Pack Browser; makes it super easy to find out what you refer to
    • Keeps you tidy with MP Fragments / folders


    • Supports advanced build options (seal the mp, edit mp header)
    • Solve the problem before you import (Visual Studio Build errors)
  • A favorite text editor – you always need one, choose your own, I have one : ) 



I am now confident that I will need;

  • to Develop a vbscript that queries to figure out unused Databsaes through Index Usage Statistics of SQL
  • a custom MonitorType that runs this script but in a way that will not burn cpu with hundreds of vb scripts (cookdown support)
  • to document my cons so that I can help managing false positive alerts and noise
  • a way to Show the results (a custom report maybe)
  • to use Visual Studio Authoring Extensions as the development environment.

My Scope is done for now, on the next post I will be starting the Cookdown supporting datasaource development.

Comments (2)

  1. Ernie says:

    Hello Emre

    When will you be posting the other series in this set please?



  2. Altug ERBASI says:

    Where is the other parts?

Skip to main content