December 2007 - Posts

Well this week was a hoot, its always fun the week before you take a week off. Stick out tongue Anyway I got a chance to spend a few hours with a Microsoft SQL Guru, trying to brush up on my TSQL. One of the many things I learned is that I use the GUI too much, and it only slows me down. Besides that one other thing that he showed me was some of the diverse information that is in sysindexed and other system tables, not something I look into on a daily basis. At any rate he had showed me how to convert numbers to strings and use them to do calculations and soon had this nice example of several things he had showed me. In my opinion there was too much out put I was only really interested in getting table names and their sizes in MB, I really don't use the plethora of information that was generated by his script. So this weekend I tamed it down to only display the results that I wanted, Table Name and Size of the tables in MB. I'm not putting my name on this one b/c the SQL Guy did all the real work I just trimmed down the output and told it to use the Onepoint database, but this could be used on any Database.

Note that the table sizes are approximates not the exact size but a good approimate is always helpful. Wink

-- 12/16/2007
-- Any DB will show the table size in MegaBytes
-- worked with a SQL Guru at M$ for a few hours last week, here are some fruits of mostly his labor
Use OnePoint
Go

select object_name(id) [Table Name],
[Table Size] = convert (varchar, dpages * 8 / 1024) + 'MB'

from sysindexes where indid in (0,1)
order by dpages desc

-- Have A great Week!

The following query will find all clients whose configuration or data package is being rejected by the MOM Management Server in the past day.

-- Scott Moss
-- 12/16/2007
-- MOM 2005 OnePoint DB Query
-- to find all clients whose configuration or data package is being rejected
-- for the past one day
--
Select Distinct
ComputerName [Management Server],
Message

From SDKEventView
Where Source = 'Microsoft Operations Manager'
And Message Like '%rejected%'
And (DateDiff(d, TimeGenerated, GetDate()) <= 1)

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

Posted by smoss | with no comments
Filed under: ,

Yeah I know eight months later with the picture, what can I say but..... Anyways that's me down in front with the red hair & beard. I'm with-holding the names of my accomplices in this picture to protect the innocent, I mean the guilt. Much fun was had that night.

 

Posted by smoss | with no comments
Filed under:

I was adding a new unit performance monitor last week and noticed the Object button when I was suppose to be selecting which Performance monitor object I wanted to monitor. To save yourself some time don't bother clicking on it as it really has no function (that I can think of).

 

In order to add a performance counter click the browse button to get to the Select Performance Counter options. I'm not sure why the Object button is there but it is. If you can expain why this is here feel free to let me know.

Posted by smoss | with no comments

Just in time for the holiday season, a new and improved version of MOM_Report_to_Database.vbs
This script takes in two arguments, the MOM Server name and the Management Group Name, collects the mom daily statistics and puts them into a database D:\MOMMGT\MOMRPT.MDB.
This will allow for reporting on multiple Management Groups.

For full details please see my prior article http://myitforum.com/articles/2/view.asp?id=10257

If your already using the original script and database only a few modifications will have to be made.
The database will have to have a row called MGName added, and the scheduled task will have to have the parameters added for the /MOMServer:ServerName /MGName:ManagementGroupName
There is error checking to make sure that there are 2 parameters, if the two parameters are not there, the script will quit with the parameters that are required.


Usage:
cscript mom_report_to_database.vbs /MOMServer:MOMServerName /MGName:MOMManagementGroupName


'Start Of Code
'========================================================
' Author: Scott Moss
' date DEC 4, 2007
' Mom_report_to_Database2.vbs This one uses Named Arguments
' usage cscript mom_report_to_database.vbs /MOMServer:MOMServerName /MGName:MOMManagementGroupName
' 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, MGName, ComputerGroups, Monitored, CriticalErrors, etc.
' Must give credit to Don Hite. His idea to dump to excel gave me the idea to dump it to a db.
'=======================================================
'cscript mom_report_to_database.vbs /MOMServer:MOMServerName /MGName:MOMManagementGroupName

' Verify that 2 arguments were passed
iNumberOfArguments = WScript.Arguments.Count
If iNumberOfArguments = 2 Then
    '
Else
    Wscript.Echo "Error: invalid number of arguments entered. " & _
        "cscript mom_stats_to_JetDB_Argument.vbs /MOMServer:MOMServerName /MGName:MOMManagementGroupName"
    Wscript.Quit
End If

Set colNamedArguments = WScript.Arguments.Named
strMOMServer = colNamedArguments.Item("MOMServer")
strMGName = colNamedArguments.Item("MGName")

'mom part
strComputer = strMOMServer

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 = D:\MOMMGT\momrpt.mdb"

objRecordSet.Open "SELECT * FROM momdata" , _
    objConnection, adOpenStatic, adLockOptimistic

For Each objItem In colItems
objRecordSet.AddNew
objRecordSet("Date") = dtmThisDate
objRecordSet("MGName") = strMGName
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.TotalWarnings
objRecordSet.Update

objRecordSet.Close
objConnection.Close
Next
'End Of Code

Posted by smoss | with no comments
Filed under: ,