BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
| |
 |
 |
 |
 |
 |
| Script to capture MOM daily stats to Jet DB |
 |
|
|
By: Scott Moss
Posted On: 5/22/2007
This is an easy way to capture data for reporting on MOM 2005 stats utilizing the MOM WMI Class MSFT_TodayStatistics. I've created a script that will dump the MOM WMI Class MSFT_TodayStatistics (the daily stats) for MOM 2005 into a database. Props to Don Hite, his script to dump the same info into an excel file gave me the idea to dump the info into a jet database.
http://www.myITforum.com/articles/2/view.asp?id=9909
The MOM WMI Class MSFT_TodayStatistics gets zeroed out at 11:59:59 pm each night.
If you manage more than one management group, it would not be hard to modify this script to use a sql db and include the management group name when the data is collected. I'm sure the management group name can be gotten thru WMI... but I'll save that for a later article.
User requirements: Create an Access Database named: MOMRPT.MDB
Create a table named: MOMDATA
Create field names that correspond with the recordset objects below in the table MOMDATA. Date ComputerGroups Monitored CriticalErrors TotalErrors EventsToday NewAlertsToday SecurityBreaches ServiceLevelExceptions ServicesUnavailable UnresolvedAlerts TotalWarnings
Create a scheduled task that runs this script at 11:59 pm (the objects in MSFT_TodayStatistics zero out at 11:59:59 pm)
User Modifications to make script work:
1.) strComputer = "YOURMOMSERVERNAME" Change YOUREMOMSERVERNAME to the name of your MOM Server. 2.) "Data Source = DriveLetter:\FOLDER_NAME_WHERE_DB_IS\MOMRPT.MDB" This should be the drive letter and folder name where the MOMRPT.mdb file is located.
' Script below ' ================= ' Author: Scott Moss ' date May 15, 2007 ' VBScript that will collect daily stats for mom and put them in a ' jet db to run your onw reports against it. Put Script in same folder w/ DB. ' Script should be run from MOM server. ' Requirements ' Create Scheduled Task to run this vb script every night at 11:59 pm. ' *** the objects in MSFT_TodayStatistics zero out at 11:59:59 pm *** ' Create Access Database MOMRPT.MDB ' Create Table called momdata ' Create field names that correspond with the recordset objects below ' Date, ComputerGroups, Monitored, CriticalErrors, etc. ' Must give credit to Don Hite. '=========================== 'mom part strComputer = "YOURMOMSERVERNAME"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MOM") Set colItems = objWMIService.ExecQuery("Select * from MSFT_TodayStatistics") dtmThisDate = (Now)
'database part Const adOpenStatic = 3 Const adLockOptimistic = 3 Set objConnection = CreateObject("ADODB.Connection") Set objRecordSet = CreateObject("ADODB.Recordset") objConnection.Open _ "Provider = Microsoft.Jet.OLEDB.4.0; " & _ "Data Source = DriveLetter:\FOLDER_NAME_WHERE_DB_IS\MOMRPT.MDB"
objRecordSet.Open "SELECT * FROM momdata" , _ objConnection, adOpenStatic, adLockOptimistic
For Each objItem In colItems objRecordSet.AddNew objRecordSet("Date") = dtmThisDate objRecordSet("ComputerGroups") = objItem.TotalComputerGroups objRecordSet("Monitored") = objItem.TotalComputersMonitored objRecordSet("CriticalErrors") = objItem.TotalCriticalErrors objRecordSet("TotalErrors") = objItem.TotalErrors objRecordSet("EventsToday") = objItem.TotalEventsToday objRecordSet("NewAlertsToday") = objItem.TotalNewAlertsToday objRecordSet("SecurityBreaches") = objItem.TotalSecurityBreaches objRecordSet("ServiceLevelExceptions") = objItem.TotalServiceLevelExceptions objRecordSet("ServicesUnavailable") = objItem.TotalServicesUnavailable objRecordSet("UnresolvedAlerts") = objItem.TotalUnresolvedAlerts objRecordSet("TotalWarnings") = objItem.TotalWarningsobjRecordSet.Update objRecordSet.Close objConnection.Close Next 'END CODE
|
 |
 |
 |
|
|