Friday, June 22, 2007

Visit myITforum Blog

I'm going to be using myITforum as my main blog.


http://myitforum.com/cs2/blogs/smoss/default.aspx

Thank you!!!!!!

Wednesday, May 16, 2007

Daily Stats Report for MOM 2005

I've created a script that will dump 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 do this.

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 post..

User requirements:
Create an Access Database named: MOMRPT.MDB

Create a table named: MOMDATA

Create field names that correspond with the recordset objects below, Date, ComputerGroups, Monitored, CriticalErrors, etc in the table MOMDATA.

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 Script Modifications (2)
1.) strComputer = "YOURMOMSERVERNAME"
2.) "Data Source = DriveLetter:\FOLDER_NAME_WHERE_DB_IS\MOMRPT.MDB"

Script below (this is my first posting so I dont know if the script will be mangled by the blog)
' =================
' Author: Scott Moss
' date May 15, 2007
' disclaimer use at your own risk.
' mom script 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.
' Run as a scheduled task at 11:59 PM every day 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. It was his vb script to dump this info into an excel
' file that gave me the idea to do this. In this format it will be easy to create' status reports .
'===========================
'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

WOOT first post!