Introduction / Case
There are examples online of how to query the OperationsManager database and find out what computers/servers are in a gray state in SCOM (Not Monitored) but I couldn't find a comprehensive pack that would allow me to alert myself with something of interest stops being monitored.
This pack specifically looks for 'Comtrade Netscaler Appliances' and the availability monitor that is applied to that class. Keep in mind that you can take this example and change it to look at virtually any monitored object.
At the root of this pack is a query to the SCOM database to look for the state to change from 1,2,3 to a 0. The 0 indicates gray, not monitored. It also takes a peek at the maintenance mode table to make it is not in maintenance mode because that will also cause it to go to the value of 0.
The unit monitor uses this query and checks the database every few minutes for each discovered basemanagedentity ID that was found in the discovery process.
A preview of the unit monitor query:
FROM state AS s, BaseManagedEntity AS bme
WHERE s.basemanagedentityid = bme.basemanagedentityid
AND s.monitorid IN (SELECT MonitorId FROM Monitor WHERE MonitorName = 'ComTrade.Citrix.NetScaler.Monitoring.Appliance.Availability')
AND s.Healthstate = '0' AND bme.IsDeleted = '0'
AND bme.BaseManagedEntityId not in (select BaseManagedEntityID from MaintenanceModeView where BaseManagedEntityId = bme.BaseManagedEntityId and IsInMaintenanceMode = 1 and ScheduledEndTime > GETDATE() )
AND bme.BaseManagedEntityId = 'Unique-BMEID-GUID-FromPack'
ORDER BY s.Lastmodified DESC
Discovery
A quick run through of the pack, we have a class that holds our discovered appliance class.
<ClassType ID="NetScaler.Appliance"
Accessibility="Public"
Abstract="false"
Base="System!System.LogicalEntity"
Hosted="false"
Singleton="false"
Extension="false" >
<Property ID="bmeid"
Type="string"
AutoIncrement="false"
Key="true"
CaseSensitive="false"
MaxLength="256"
MinLength="1"
Required="false"
Scale="0" />
</ClassType>
You can see that I have a logical entity class that has a key property, this will hold the unique identifier from the basemanagedentity table because I've noticed the display name on the appliances aren't always unique.
The discovery is also a query from the OperationsManager database to get each of the appliances to be monitored:
SELECT bme.BaseManagedEntityId, DisplayName
FROM state AS s,
BaseManagedEntity AS bme
WHERE s.basemanagedentityid = bme.basemanagedentityid
AND s.monitorid IN (SELECT MonitorId FROM Monitor WHERE MonitorName = 'ComTrade.Citrix.NetScaler.Monitoring.Appliance.Availability')
AND IsDeleted = 0The end result is a list of appliances that has one unit monitor targeted to it.
The discovery itself runs on the SCOM management server and allows you to specify the database server name:
Monitoring
The unit monitor is pretty straight forward and utilizes a 2-state PowerShell property bag monitor that queries the database on an interval.
It's type:
The data source is a powershell monitor (preview)
Full MP in XML (XML Pack Link)
Full VSAE Visual Studio (v12) Solution (VSAE Zip File Link)
No comments:
Post a Comment