Management Pack to Monitor and Reduce Health Service Store Size

A customer of mine monitors some agents that only have 1gb of storage, so disk space must be conserved as much as possible. The Health Service store file (a JET database named HealthServiceStore.edb) on these Agents is around 100mb-200mb, which is pretty normal for a SCOM Agent.

I researched this a bit and found that unused space in the Health Service store is not cleaned up automatically. To clean it up and reduce the size of the file, you can do an offline defragmentation of the file by doing the following:

  1. Stop the Microsoft Monitoring Agent service (HealthService)

  2. Open an admin command prompt and run the following command (modify the file path as needed)

    esentutl /d "C:\Program Files\Microsoft Monitoring Agent\Agent\Health Service State\Health Service Store\HealthServiceStore.edb"

  3. Restart the Microsoft Monitoring Agent service

Doing this in my test environment will generally reduce the file size from ~110mb to ~25mb

To help my customer detect and automate this, I’ve created the attached Management Pack to monitor, collect, and reduce the size of the Health Service store file.

 The Management Pack contains:

  • A Monitor to check the size of the Health Service database file
    • Monitor name is “Health Service Store File Size Check”
    • Targeted at the “Agent” class
    • Disabled by default
    • Warning Alert/State Change is generated if the file size is greater than the defined threshold
    • File size threshold is 100mb by default and can be configured via override
  • A Rule to collect the size of the Health Service database file
    • Rule name is “Collection: Health Service Database File Size”
    • Targeted at the “Agent” class
    • Collected performance counter is
      • Object: Health Service Database
      • Counter: File Size
      • Instance: <Path to health service store file>
  • A Task to manually do an offline defrag of the Health Service database file
    • Task name is “Health Service Database Offline Defrag”
    • Targeted at the “Agent” class
  • A Recovery to automatically do an offline defrag of the Health Service database file when the monitor detects the size is over the defined threshold
    • Disabled by default

Details of the workflows

  • The Monitor runs a PowerShell script that gets the Health Service State directory from the registry, then checks the size of the HealthServiceStore.edb file and compares against the defined threshold. The script returns a Property Bag to SCOM with the file path, size, threshold, and status (above/below threshold).
  • The Collection Rule uses the same script as the Monitor, and just uses the file size property and maps it to performance counter data.
  • The offline defrag Task and Recovery use a VBScript based on Matt Taylor’s task to restart SCOM Health Service script…all I did is modify it to run the offline defrag before restarting the service.

 

Screen shots from the Management Pack

Monitor

monitor

 

Rule

rule

 

Task

task

task

 

Health Explorer

explorer

 

explorer

 

Alert

alert

 

Performance Collection

perf

HealthServiceStore.Monitoring.zip