Monday, May 19, 2008

Creating a SCOM MP using the Authoring Console

When setting up monitors, I have found that the toolset provided to me in the SCOM Admin console doesn't provide me with all the necessary functions desired.

Specifically, if I want to monitor a service, I have the option of using the service monitoring wizard – this doesn't provide much flexibility for future configuration, doesn't give the nicer UI functionality for the operators, and is just ugly if I make more than 2 or 3 of them. Alternatively, I can configure a service monitor to look for a service on all servers in a group – this assumes a group is already created, it doesn't perform any discovery, and still doesn't provide the UI functionality the operators will expect.

This leaves me with the requirement of using the MP Authoring Console and configuring all these options there. This means I need to: Create a class, create a discovery for the class, create groups and group populators, create the UI elements, and lastly create the monitors.

Configuring the console

Copy all MPs locally

The easiest way to do this is to perform a wildcard search for *.MP and *.XML against the root management server, the SQL server, and the installation CD. Then copy all these files to a local directory.

In the Authoring Console, select Tools | Options and select the References tab. Click Add and select the path you copied the MP and XML files to.

Configure the namespace

In the Authoring Console, select Tools | Options and on the General tab enter in your default namespace. This should follow a standard naming scheme used in your company, you can look at how Microsoft names their MPs for examples.

Add in additional references

To perform all the functions needed, the authoring console doesn't reference all the needed MPs.

In the Authoring Console, select File | Properties and click the References tab. There you will see 4 MPs referenced, we need to add 2 more.

  • Click Add Reference
  • Browse to your local copy of the MPs
  • Select, click OPEN
  • Repeat for
  • Click OK

Creating a class

Since we are monitoring an application, we first need to create a class for the application. We want to do this so we can limit our monitoring to only those systems we are interested in, as well as limiting the tasks and other functions.

  • Click the Service Model tab in the Authoring Console and click Classes in the tree view.
  • Select New | Windows Local Application
  • Enter the ID following your naming scheme
  • Enter a friendly display name, next
  • Most likely there will be no key properties, so click finish

Creating a discovery

Now that we have our application class, we need to discover the application. The easiest way that I have found to do this is via WMI.

Click the Health Model tab in the Authoring Console and click the Discoveries node

Select New | WMI

Enter various information on the General tab

  • NOTE: the element ID needs to be different every time it is used. So if you created a class with the ID CompanyX.Application, the discovery ID could be CompanyX.Application.Discovery.
  • In the Target section, make sure to select the class you previously created

The WMI query can be simple or it can be complex depending on what you are discovering. If you are not 100% sure what you are typing (and who is?) you can use WBEMTEST to confirm everything

  • WMI Namespace: root\cimv2
  • Query: Select * from Win32_Service where name= 'servicename'
  • Frequency: 86400 (once per day)

Alternatively, you can discover multiple services by using different queries

  • Select * from Win32_Service where name like 'servicename*' (note the * as a wildcard character – this only work in W2k3 and above)
  • Select * from Win32_Service where name='servicename' or name='servicename2' or name='servicename3'

On the Discovery Mapper page

  • Select the Class ID you are discovering
  • Under Key Properties, select Host | Principal Name

Creating groups and populators

Now that we have our class, we need to create a SCOM group for use with the various UI components. The goal here is to create a group of computers that contain the service we are monitoring. This is different than creating a group of the services.This is where it gets a little complicated and some text editing is needed.

Click the Service Model tab of the Authoring Console and select the Classes node

  • Select New | Computer Group
  • Enter the group ID and display name (standard warning on naming scheme)

Once the group is created, we need to create the discovery to populate the group

Click the Health Model tab and select the Discoveries node

  • Select New | Custom Discovery
  • Create a unique identifier and click OK
  • Enter a name and for the target select the computer group you just created (NOTE: its icon should be a gray diamond with an underline, not a blue diamond)
  • On the Discovered Types tab select the bottom Add button (next to Discovered relationships and their attributes)
    • Select Microsoft.SystemCenter.InstanceGroupContainsEntities
  • On the Configuration tab, click Browse for a type
    • Select Group Populator
    • Under Module ID, I don't know what it expects so I think you can put anything there, click OK
    • Note: You will likely receive an error, I believe this can be ignored
  • Back on the Configuration tab, select Edit and replace the Configuration contents with the following














  • Replace "CompanyX.Application" with the correct value for your application
    • NOTE: If this section here is about the only place that can throw errors here. Make sure the MonitoringClass attribute is correct
  • Back in the Configuration tab, click OK

Creating UI components

Now that we have a computer group, we can create views based on that group and the health of the services in it.

Click the Presentation tab in the Authoring Console and select the Views node

  • Click New | Folder
  • Enter in an appropriate ID and click OK
  • Enter a name, click OK

Now we have a folder to place objects in, we can now create a state view

  • Click New | State View
  • Fill out the general tab, selecting the computer group previously created as the target
  • Click OK and once the wizard is finished, open the object again
  • On the Folder tab, uncheck Monitoring and check the subfolder you previously created
    • NOTE: This is to stop the view from appearing at the root of the management console and be more organized

Creating Monitors

Lastly we need to create a monitor. To be simple, we will only monitor a service state:

Click the Health Model tab in the Authoring Console and select the Monitors node

Select New | Windows services | Basic Service Monitor

Fill out the general information screen

  • Again, note that the Element ID must be something unique. One example could be CompanyX.Application.ServiceY
  • Target is the target class you initially created
  • Parent Monitor should select Availability (or otherwise appropriate category)
  • On the Service Name page, enter the name of the service, click finish

Once the Wizard is completed, we need to perform more editing to configure alerting

Select the monitor you just created and click Properties

  • On the Configuration tab you can see the service configuration.
    • NOTE: the CheckStartupType option allows you to specify if you want to monitor only services configured to Auto start or all startup types. If you wish to change this you will have to click Edit… to open the text editor and change this option to true
  • On the Health tab you select the states for a running or not running service.
  • The Alerting tab allows you to select if you want to generate alerts or not, and according to what state
  • The Diagnostic and Recovery tab allows for automatic recovery tasks to take effect
  • Lastly the Product Knowledge tab allows for custom knowledge to be imported

Monday, May 05, 2008

Report Server log file growing nonstop

Last friday I was alerted to the log drive filling up on a SQL 2005 server. I looked into it and found that my SQL Report Services log file (ReportServer_Log.LDF) was increasing in size and filling up the drive.
My first thought was to simply shrink the file via SQL Server Management Studio - select the DB, select Tasks, Shrink, Files, and select the appropriate log file. This however failed to do anything and the drive was continuing to fill. So before it got any worse, I capped the log file size to keep the drive from filling up and created another temporary log file on a drive that had more room.
I tried shrinking the file various ways in the UI and via dbcc shrinkfile, all without success. Some googling reminded me that the log files wont truncate until they are backed up, so I try backing up the log file:
backup log reportserver to DISK='f:\test.bak'

That also failed, but it finally gave me an interesting error message:
The log was not truncated because records at the beginning of the log are pending replication. Ensure the Log Reader Agent is running or use sp_repldone to mark transactions as distributed.

Some more googling and I found which discussed this error also. For some reason my database thought it was configured for replication even though I am not using replication. In a replication scenario the logs are only truncated after the transactions have been replicated to the second server. So to resolve this we need to make it think replication is working and then turn it off.

1. Following the article I begin by setting the replication to TRUE
sp_replicationdboption 'ReportServer','publish',true
This however fails because there is no distributor setup
The Distributor has not been installed correctly. Could not enable database for publishing.
2. Configure Distribution on the server
using the wizard I configured distribution, pointing the files to paths on drives with plenty of space
3. Now that replication is setup, set replication to TRUE
sp_replicationdboption 'ReportServer','publish',true
4. Using sp_repldone, clear the logs
EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @time = 0, @reset = 1
5. Now, unpublish the DB
sp_replicationdboption 'ReportServer','publish','false'
6. Now that the DB no longer thinks its published, we can backup the log file
backup log reportserver to DISK='f:\test.bak'
7. Finally we can shrink the file
dbcc shrinkfile('reportserver_log',10)
8. Lastly, cleanup the mess you just made by disabling replication and deleting your backup file

Now all thats left is to delete the temporary log file that was created to keep the initial drive from filling.
The normal shrink process doesnt seem to be working and the log files are emptying to allow for their deletion. I ran into this once before and remember that it had to do with how SQL places data in the logical and virtual logs. More googling to find the answer...

Friday, May 02, 2008

Setting up DOS in a Windows VPC 2007

Microsoft has "officially" discontinued support for MSDOS under virtual PC, which makes it difficult for us to enjoy our old DOS games (like MechWarrior). However, most of the support files for DOS are still included on the VPC additions ISO, and we just need a little tweaking to make it work. I reviewed the "Dos Virtual Machine Additions.vfd" from VPC2004 and came up with the following steps for VPC2007.

1. Create a directory in the root of C:\ named vmadd
2. Copy cdrom.sys, fshare.exe,, and from the VMAdditions.iso to C:\vmadd
3. Edit Autoexec.bat and add the following lines
mscdex.exe /D:IDECD001 /L:E
4. Edit Config.sys by adding the following lines

Reboot and you should be good to go, the CDROM will be drive letter R, the mouse will work as it always did under DOS (which is poorly), and the shared folders will allow you to map your PC files.

Remember to use the right ALT key to release the mouse.