Useful Operations Manager 2007 SQL queries


This post has been archived.  Please see the new posting for SQL queries for SCOM at:

https://blogs.technet.microsoft.com/kevinholman/2016/11/11/scom-sql-queries/

Comments (104)

  1. Anonymous says:

    Jonathan Almquist started a blog post about Operations Manager 2007 SQL Queries . “I’m starting a new

  2. Anonymous says:

    I’m starting a new post here, similar to my Command Shell reference .  This will include some useful

  3. Anonymous says:

    This is a continuation of my other post, on general alert grooming: How grooming and auto-resolution

  4. Kevin Holman says:

    Dontchya hate that?  🙂

    I’d much rather write a new query than re-engineer someone elses and trust it.

    But I myself am no Tsql expert.  Most of these above that I have written are pretty basic joins from simple trables/views.  The complex ones are always something I got from someone else and just published it.  I think the most complex one I ever wrote was the Outage and Maintenance report, and I had to get some help on that one.  Dont feel bad.

  5. Anonymous says:

    I’ve been getting a few questions lately about slow performance with the console so I thought a post

  6. Anonymous says:

    Kevin,

    Need little help here. After updating Scom2007 R2 with CU6 hotfix and approving 'pending agents', i ran the sql query "To view all agents missing a specific hotfix " using your article. Now i see that about 100 agents are missing the hotfix, although 'Pending Management' node in SCOM console does not list them. From your CU6 article I understand that manually installed agents need hotfix to be installed manually.

    Now, if I run the sql query that will set all agents back to Remotely Manageable, will it allow me to update agents with the CU6 hotfix? Your feedback is much appreciated.

    Thanks,

    Fahim,

    SQL quesry:

    UPDATE MT_HealthService

    SET IsManuallyInstalled=0

    WHERE IsManuallyInstalled=1

  7. Kevin Holman says:

    Re:  SCE

    I cannot say as I dont support SCE, nor have I even seen the product.  🙂

    However – I believe it should… as the DB’s are very similar.  If you can see dbo.AlertView then the error message you are getting is simply because you dont have enough rights, or you are running it against the wrong database…. make sure you are executing it against "OperationsManager" and not "Master"

  8. Kevin Holman says:

    Ravi – I will answer this here – but I am not sure why you posted this on my SQL query page?

    The problem with your statement is #3 is not a fact.

    The agent *initiates* to communication channel over 5723 TCP, always.  This means the communication BEGINS from the agent, to the management server.  However, once that communication channel is established, the communications is bidirectional.  It is always opened initially by the agent, but from that point forward, the management server can also communicate to the agent.   For the purposes of a firewall, the direction is from the agent to the MS, because the firewall inspects the initial communication channel.

    When the management server/RMS notifies the agent of updated config available – this occurs over 5723 TCP.

  9. Anonymous says:

    Hi Kevin,

    Considering the below facts:

    1. Agent initiates the communication with its reporting Management server.

    2. For Communication we need the TCP 5723 to be opened from Agent to RMS (uni-direction) only.

    3. Agent will pull all the data from its reporting MS. MS never push the data to an Agent.

    My question is:

    Once we do some configuration change, RMS/MS will notify their Agents for this change. On which port this communication happens (considering 5723 is open uni-directional) ?

    I appriciate if you could please shed some light on this.

    regards,

    Ravi

  10. Kevin Holman says:

    You can get space used by type by using the large table query….  which is why I include and use that one all the time.  It could be made prettier… but it works.  There is also a report in SQL 2005 SP2 for reporting on table by size….  which will show you this.  The tables are named to be fairly self explanatory.

  11. Anonymous says:

    Hi Kevin,

    I used "To find all groups for a given computer/object", but it seems couldn't find the computer which is in the subgroup.

    Thanks.

  12. Kevin Holman says:

    Re:  Kent

    Kent – there is no 4GB limit that I am aware of.  To what are you speaking?

    Localizedtext filling up is a known issue – this is documented and there are two scripts to clean this up here:  

    http://blogs.technet.com/kevinholman/archive/2008/10/13/does-your-opsdb-keep-growing-is-your-localizedtext-table-using-all-the-space.aspx

  13. Dominique says:

    Hello,

    I am looking for a List of all Rules and Monitors applied to a group of Computers owning an application… there are file servers, SQL, applications, etc… in the group,

    Also i need the parameters used within each rule/monitor.

    Thanks,

    Dom

  14. Anonymous says:

    Hi Kevin,

    Thanks for your Queries. It helped me a lot and saved my time. Thanks.

    I got a request to pull Memory Utilization (Physical) report for all servers. When I use to pull the report from DW using "% committed bytes in use" counter, I am not getting the expected result. Am I looking correct counter?

    One of my server utilized 99% for 7 hrs but my report shows approximate 55%.

    Please help me if you have any query and correct COUNTER name.

    Thanks,

    Balaji Suresh

  15. Kevin Holman says:

    Great question!

    There are queries you can use against the opsDB, drawing on the assumption that these are collected for both databases.  This is covered here:

    blogs.technet.com/…/management-group-checkup-a-database-perspective.aspx

    and

    blogs.technet.com/…/tuning-tip-turning-off-some-over-collection-of-events.aspx

  16. Kevin Holman says:

    Lot of new updates…

  17. Anonymous says:

    Very helpful queries, Kevin!

    Do you by chance have one that shows all alerts filtered to a specified SCOM group? I can find all alerts, and I can find groups, but can not seem to join them together.

    Thanks,

    Patrick

  18. Anonymous says:

    Hi Nayden,

    more than a great script; thank you. Any chance to add information about the fallback MS in this query?

    Thank your very much for such a support.

    Alex

  19. Anonymous says:

    Could you help with a query to retrieve Dell hardware with critical alert state = New.

    Thanks

  20. Kevin Holman says:

    Re:  Kent

    Kent – you are probably running SQL express – as this is the ONLY version fo SQL with such a limitation.  SQL express is NOT supported.

    http://www.microsoft.com/sqlserver/2008/en/us/editions-compare.aspx

    http://technet.microsoft.com/en-us/library/bb309428.aspx

  21. Kevin Holman says:

    @Pallavi:  Everybody needs that.  Every customer I have worked with to date has asked for that since RTM.  Unfortunately, there is no easy way to get this from a report.  I am confident it could be done, but not with my feeble SQL skills.  We have asked the product teams for this, so I am hoping the next version of SCOM might have something like this built in mind.

  22. Anonymous says:

    How ’bout a query that show space used by type, being alert, event, perf, state for the dw?

  23. Anonymous says:

    Hi Kevin

    Might be a weird question, but why dont i have the EventAllView table in my OpsMgr DW?

    Thanks!

  24. Vishe says:

    How check someone deleted some group ?

  25. sna says:

    Hi – This is a great post.

    I was wondering if you could help me with a question.

    In the view “PerformanceDataAllView” in the “OperationsManager” database, what do the columns “TimeSampled” and “TimeAdded” mean?

    Thanks,

    Sna

  26. Availability Query says:

    Hello,

    Can you post a query one would run to get availability of a server for a certain time period?  

    Thanks,

    MB

  27. paul keely says:

    what another fantastic resourse!!

  28. Orhan says:

    Hello everyone,

    I am trying to create report something like this,

    User Name              Number of Closed Alerts

    operatorname1             245

    Operatorname2             165

    I am querying the OperationManager Database my query is,

    SELECT     LastModifiedBy AS ‘User Name’, COUNT(*) AS ‘Number of Closed Alerts’

    FROM         AlertView

    WHERE     (ResolutionState = ‘255’)

    GROUP BY LastModifiedBy

    ORDER BY ‘Number of Closed Alerts’

    I am confused little in the alert view table which filed should I use for the date and time parameters.

     if I just want to get the closed alert count by specific user and by specific time is that field going to be "TimeResolved" or which one?

    Thank you.

  29. Orhan says:

    Hi Kevin,

    Your report works fine, but I needed to get last 7 days data which not included in your report because you are getting data from Datawarehouse by default we know Opsmgr keeps 7 days alert data in the OperationManager DB so I figured out from your query and modify it against OperationManager DB.

    My issue was I could not figured out which field should I for data and time parameter. I think I found out,

    Here is the final query I believe this is correct  

    SELECT     LastModifiedBy AS ‘User Name’, COUNT(*) AS ‘Number of Closed Alerts’

    FROM         AlertView

    WHERE     (ResolutionState = ‘255’)

    and TimeResolved between @startdate and @enddate

    GROUP BY LastModifiedBy

    ORDER BY ‘Number of Closed Alerts’

    Now I have another issue, SQL server TimeZone

    SQL server time  4 hours ahead than system time when I pull data from Report manager I am not getting accurate data from database.  Do you know how can we fix this issue?

    Thank you.

  30. Pradeesh says:

    This a great topic

    Thanks

    Pradeesh

  31. Olie says:

    Hi Kevin,

    Thanks for the post, will prove very useful.

    Got an issue when I run a few of the queries though. I reveive an error stating that PerformanceDataAllView is an invalid object name.

    Any ideas?

    Thanks,

    Olie

  32. Olie says:

    Hi Kevin,

    Please ignore my last post regarding PerfromanceDataAllView as I have managed to resolve the issue.

    Thanks again for the scripts… very handy!

    Olie

  33. srikanth says:

    How to get InternetInformationServices information from operations manager databse

  34. Nayden says:

    Here is one I found useful (I am sure it can be modified and improved, but this one works for me). It returns the Name, Action Account Identity, Install Date, Version, Health State, Availability (the greyed out icon state when the agent is not reporting back to the MS), and the MS it reports to. Some stuff is commented out, you can include it if you want…

    SELECT

    –[MT_C].[BaseManagedEntityId] AS [Id],

    [MT_C].[PrincipalName] AS [Name],

    –[MT_C].[NetbiosDomainName],

    –[MT_C].[NetbiosComputerName],

    –[MT_C].[NetworkName],

    [MT_H].[ActionAccountIdentity],

    –[MT_H].[InstalledBy],

    [MT_H].[InstallTime],

    –[MT_H].[ProxyingEnabled],

    –[MT_H].[IsManuallyInstalled],

    –[MT_H].[ActiveDirectoryManaged],

    [MT_H].[Version],

    [S].[HealthState],

    CASE

    WHEN MAX(CAST(A.[IsAvailable] AS int)) IS NULL

    THEN CAST(0 AS BIT)

    ELSE CAST(MAX(CAST(A.[IsAvailable] AS int)) AS BIT)

    END

    AS IsAvailable,

    –[BME].[BaseManagedEntityId] AS [HealthServiceId],

    –[TME].[ManagedTypeId] AS [HealthServiceTypeId],

    [BME2].[DisplayName] AS [ReportingTo]

    –[BME2].[TopLevelHostEntityId] AS [TargetHostId],

    –[HSC].[RelationshipTypeId] AS [CommunicationTypeId],

    –[BME].[LastModified]

    FROM dbo.BaseManagedEntity (nolock)

    AS BME  

    INNER JOIN dbo.TypedManagedEntity AS TME       ON BME.[BaseManagedEntityId] = TME.[BaseManagedEntityId]  

    INNER JOIN dbo.Relationship AS HSC       ON HSC.[SourceEntityId] = BME.[BaseManagedEntityId]  

    INNER JOIN dbo.BaseManagedEntity AS BME2       ON BME2.[BaseManagedEntityId] = HSC.[TargetEntityId]  

    INNER JOIN dbo.MT_Computer AS MT_C       ON MT_C.[BaseManagedEntityId] = BME.[TopLevelHostEntityId]  

    INNER JOIN dbo.MT_HealthService AS MT_H       ON MT_H.[BaseManagedEntityId] = BME.[BaseManagedEntityId]  

    LEFT OUTER JOIN dbo.State AS S ON BME.[BaseManagedEntityId] = S.[BaseManagedEntityId]

    AND S.[MonitorId] = dbo.fn_ManagedTypeId_SystemHealthEntityState()

    LEFT OUTER JOIN dbo.Relationship AS R ON BME.[TopLevelHostEntityId] = R.[TargetEntityId]

    AND R.[RelationshipTypeId] = dbo.fn_ManagedTypeId_MicrosoftSystemCenterHealthServiceManagesEntity()

    AND R.[IsDeleted] = 0

    LEFT OUTER JOIN dbo.Availability AS A ON A.[BaseManagedEntityId] = R.[SourceEntityId]  

    WHERE (( BME.[LastModified] >  ‘Jul 1 1999 1:24:55:063PM’ ) )

    AND (((TME.ManagedTypeId = ‘118C0F18-7A70-5F57-3A9B-EEAF1705B3FC’)

    AND (HSC.[RelationshipTypeId] = ‘37848E16-37A2-B81B-DAAF-60A5A626BE93’)

    AND (BME.[IsDeleted] = 0

    AND TME.[IsDeleted] = 0

    AND HSC.[IsDeleted] = 0)))

    GROUP BY BME.[BaseManagedEntityId], MT_C.[BaseManagedEntityId], MT_C.[PrincipalName],

    MT_C.[NetbiosDomainName],

    MT_C.[NetbiosComputerName],

    MT_C.[NetworkName],

    MT_H.[ActionAccountIdentity],

    MT_H.[InstalledBy],

    MT_H.[InstallTime],

    MT_H.[ProxyingEnabled],

    MT_H.[IsManuallyInstalled],

    MT_H.[ActiveDirectoryManaged],

    MT_H.[Version],

    S.[HealthState],

    TME.[ManagedTypeId],

    BME2.[DisplayName],

    BME2.[TopLevelHostEntityId],

    HSC.[RelationshipTypeId],

    BME.[LastModified]

    order by Name asc

  35. Nayden says:

    Well, I am not sure whether it is possible or not – I myself am not a SQL expert… Since I could not find this info anywhere (documentation or via PowerShell) my last resort was to run a trace on the DB and reverse-engineer the query out of the thousands of lines of output. Sorry I couldn’t be of more help.

  36. kldsts says:

    How can i get the total no of alerts raised for a specifically OS related  for a month. ?

    How can i get the total no of notification send from my scom server to the notified groups ?

  37. james says:

    Hi

    Is it possible to have a query that shows the number of alerts per day by a group of servers?

    I have a number of groups, ie DomainA, DomainB, DomainC etc so would like to report the number of alerts generated by group with also the number of days to be a variable

  38. Jasmine says:

    I am trying to write a query to display alert history which users might have update on certain alerts under alert properties / History. I have no idea which table I should call as I could not find a table which stores this data. Any advise?

  39. Steve Tolbert says:

    Is there a query to retrieve all rules and monitors running on a given host including overrides?

    I am trying to do something similar to the effective configuration viewer but I would prefer to do it in sql.

  40. Kent Grundström says:

    Hmm… Something that I need is a way to shrink the LokalizedText table, it contains >2 million records making the SQL-server hit the 4Gb limit

  41. Kent Grundström says:

    Re: kevinhol

    Thanks for the info and the pointer!

    The server itself says there is; "CREATE DATABASE or ALTER DATABASE failed because the resulting cumulative database size would exceed your licensed limit of 4096 MB per database" event ID 1827

  42. Kent Grundström says:

    Re: kevinhol

    Ahh… Yes you are right, it is, that is the version with the EBS, I’ve tried to replace it with a better version some time ago, but then the "normal" version was not runnable on the management server…

    BTW, the scripts worked like a breeze and now everything runs like a kittens purr, so thanks again for the tip…

  43. Amal says:

    some queries need to be updated due to change in the names of the fields

    for example:

    SourceMonitoringObjectDisplayName has been changes to SourceObjectDisplayName

  44. Niel says:

    Hi,

    I ma looking for a query to give me a report as follow:

    Computername|ManagementPack|Rule and/or |Monitor

    Anything will help?

    Thanks

    Niel

  45. Tom Kasmir says:

    Will these work against a System Center 2007 Essentials SQL database?  Some queries do for me, some don’t.

    Example of a non-working one from "Top 20 Alerts in an Operational Database, by Alert Count"

    SELECT TOP 20 SUM(1) AS AlertCount, AlertStringName, AlertStringDescription, MonitoringRuleId, Name

    FROM Alertview WITH (NOLOCK)

    WHERE TimeRaised is not NULL

    GROUP BY AlertStringName, AlertStringDescription, MonitoringRuleId, Name

    ORDER BY AlertCount DESC

    :

    I get – Msg 208, Level 16, State 1, Line 1

    Invalid object name ‘Alertview’.

    I’m doing this in the SQL Mgmt. Studio, and I can see dbo.AlertView table under VIEWS which is under the OPERATIONSMANAGER database.

    – thank you

  46. Tom Kasmir says:

    Thanks. That’s it.

    All I had to do was add USE OperationsManager to the top of the query. Due to my lack of familiarity with SQL querying I assumed wrongly that just highlighting a database on the left would be sufficient.

  47. Wolfgang says:

    Hi Kevin,

    I`m looking for a query to retrieve informations about clusters.

    Nodename + Clustername

    Could you help me?

  48. Hi Kevin,

    How we can find the list of greyed out agents? any SQL query for this?

    Thanks

  49. Pallavi G says:

    Hi Kevin,

    I need a help. I want a report which gives me all the monitors and rules which are associated with one computer.

    Thanks and regards,

    Pallavi

  50. Pallavi G says:

    Yes I tried couple of combinations and there doesn’t seem to be a common thread which will link the tables together. Thanks for your efforts of answering my query.

  51. Sven Wells says:

    I am trying to write a query against the DW db on SCOM 2007 SP1 for listing all the servers that have a CPU Utilization of equal-to-or-less-than 5% for a certain timespan.  I'm also trying to write a query for equal-to-or-greater-than 95%, also for a certain timespan.

    Can anyone help with that?

  52. Ravi says:

    I was little confused about the section where I should post this query. So I choose randomly. Sorry about that.

    Thanks to clarify the doubt.

    regards,

    Ravi

  53. Wilson W. says:

    Hi Kevin, I tried using the SQL query to find out what is causing my Datawarehouse database to be so huge.  I ran the query and got the tables back…..what I'm not clear about is what i do with this information now?  For example, one of the values returns that is apparently taking up a lot of space is:

    EventDetail_B20DD394FCE54972ADC7542596500DF6

    Is this a specific table that I should be looking for?  How to I correlate this information with the actual rule/monitor that is causing the data overhead?

  54. AnExtermist says:

    AnExtermist says:

    Hi Kevin,

    Need your Immediate Assistance with Pulling Out Reports from SCOM Pertaining to User Logon.., I have gone through your blog “Domain User Logon”.., However I am Facing Problems with it as i am not able to see the options in the report builder the ones you have mentioned to be able to pull out reports..,

    My Setup –

    One Dedicated Server for SCOM – ( SCOM 2007 R2 CU 3 running Windows 2008 R2 Ent)

    One Dedicated Server for SQL- ( SCOM Database with ACS Database )

    Monitoring approx 60 Domain Controllers with it.., Basically collecting Security Logs from Every Domain Controller into this ACS Database..!

    Now this is My Requirement as far as Reports are Concerned:

    I have got the following request for a report.

    All workstations for a Region and all users that logged on to them, and the dc at which this was logged.

    Produced in csv/xlsx format with time stamp” as it adds knowledge helping to tie a computer to a user.

    This means all workstation located bellow the following

    ou: “OU=XYZ,OU=Workstations,OU=Resources,DC=Contoso,DC=com”

    They want these sort of reports on a weekly basis sent to them.

    Is this possible to create?

    PLEASE DO REPLY ASAP..!

  55. AnExtermist says:

    Basically I want to Pull Out Reports for One User or For Multiple Users Located anywhere in the domain to Find out:

    1. What All Computers did they Logon on to

    2. Number of times they Logged ON (Interactive, Network, Service, Batch, Unlock, RemoteInteractive, CachedCreds..)

    3. Which Domain Controller Authenticated them.!

    I have used reportbuilder.exe the one that comes with SQL Server 2008 R2 Std. Edition as well as i have installed the latest ReportBuilder 3.0 as well to check if this helps in pulling out the details mentioned above..,

    I have successfully created a Report Model Project to be able to use ReportBuilder.exe.., I have done this for both OperationsManagerAC as well as OperationsManagerDW.., I tried following the steps mentioned in your blog to be able to pull out reports.., but looks like i am novice at this.., seeking spoon feeding at this point in time..! as i was not able to see all the options mentioned there..!

    Hope this info helps you u in understanding my requirement…, if it does..!

    PLEASE HELP ME with this..! DO REPLY SOON.!

  56. narendra says:

    To find a particular agent assinged to which mangement group and mangement server.

    uspgetagentassignment 'agentname'

    in the same way,  can we "find the rules and monitors and other stuff applied on a particular agentserver". do we have any Sql query for this..Please

  57. Dominique says:

    Hello Kevin,

    I change the grooming MaxDataAgeDays and would like to know how to apply it (or when will it be effective and taking in ). As I decrease the number of days i would like to decrease the size of the OperationsManagerDW afterwards.

    Thanks,

    DOm

  58. shaji says:

    Hi kevin,

    I need a help! Can I've a query to find the total downtime in minutes for a particular computer/server for a particular period (for a month or for a year)?

    Thanks,

    Shaji

  59. Brantley Daughtry says:

    Outstanding Collection!

  60. Laurence Vandeyar says:

    Kevin- Do you have an update for SCOM 2012 as the DB Schema has changed? I need a group membership query.

    http://www.systemcentercentral.com/…/Default.aspx

  61. JosephAB says:

    Wonderful article. Could you also help with a query to retrieve all memeber names of the user roles under the security?

  62. SCOM 2007 R2 - SQL Query for Web Application State says:

    Does anyone have the SQL Query to get Web Application state from the Live Database and SQL Query I can execute which will return eaxt same information as the Web Application State under monitoring in the Console.

  63. scom 2007 says:

    Does any one have a query to find all rules that are applied to a particular computer in scom 2007

  64. To pull Alerts within a given time of creation from DWH says:

    I was trying to pull data including alert Name limited to certain time of my choice and came up with below, hope it helps someone else too

    select ars.alertguid,ars.DWCreatedDateTime, alertname, alertdescription, statesetbyuserid, resolutionstate, statesetdatetime, severity, priority, managedentityrowID, repeatcount

    from Alert.vAlertResolutionState ars

    inner join Alert.vAlert alt on ars.alertguid = alt.alertguid

    where ( (ars.DWCreatedDateTime > '2012-10-01 00:00:01.000') and (ars.DWCreatedDateTime < '2012-10-31 23:59:59.999'))

    order by statesetdatetime

  65. Tommy says:

    How to get all alerts from a specified period of time?

    This query works, but does not give me the objects/path and such;

    SELECT *

    FROM Alert WITH (NOLOCK)

    WHERE TimeAdded >= DATEADD(day,-7, GETDATE())

  66. Shashikanth says:

    Please share the script to generate the report for Alerts raised by a specific Managment pack

  67. Anonymous says:

    我一直在与很多用户进行交谈,包括(在 MMS、TechED 和很多其他场合)在线交谈和当面交谈,随着用户计划部署 System Center 2012 – Operations Manager

  68. Dominique says:

    Hello,
    Is it possible to have a view or report which list each SQL Instances on a SQL Cluster with the memory allocated to each instance?

    Thanks,
    Dom

  69. FTZ says:

    Hello,
    I’m trying to create a report about the average of CPU(70%),Disk(60%) and Ram(70%) of network,windows and linux devices ,Do any one have any helpful queries?
    Thanks
    DTZ

  70. DSS says:

    Hi Kevin,

    can anyone help me to get the querie to find the server name for the top SCOM alerts

    Thanks
    DSS

  71. nico says:

    Hi Kevin, I am experiencing an error using a query: SELECT AggregationIntervalDurationMinutes, BuildAggregationStoredProcedureName, GroomStoredProcedureName, MaxDataAgeDays, GroomingIntervalMinutes FROM StandardDatasetAggregation

    It says Msg 208, Level 16, State 1, Line 1
    Invalid object name ‘StandardDatasetAggregation’.

    I see the table dbo.StandardDataSetAggregation.

  72. Gary Barber says:

    Is there a query that will list all of the Monitors and Rules that will generate an alert, along with the Severity and Priority that also takes into account whether or not there are overrides in place that may have changed the Severity or Priority or turn the monitor / rule off entirely?

  73. Vinoth says:

    Hi Kevin,

    I unable to find Mail Latency (Send/ Receive) Data in SCOM 2012 SQL Query.

    need your help to find SQL query that fetches below details

    1. Average Time for Accessing Mailbox.

    2. Average Time to Send and Receive Mail.

    Regards,
    Vinoth Kumar.

  74. Vinoth says:

    Hi Kevin,

    I unable to find Mail Latency (Send/ Receive) Data in SCOM 2012 SQL Query.

    need your help to find SQL query that fetches below details

    1. Average Time for Accessing Mailbox.

    2. Average Time to Send and Receive Mail.

    Regards,
    Vinoth Kumar.

  75. Scott Tiger says:

    I want to get the sql query for
    1>Data Mail Latency (Send/ Receive) … Means we need average time to take for the mail to send and receive. And how frequently mail box has been accessed.
    from scom server, but after numerous tried I am failed to retrieve that. Help me.
    Thanks in Advance.

  76. Nithin KG says:

    We have SCOM 2012 R2 in our envirnment.
    Our clients have shared a list of servers and it’s big list to do by hand.
    I need to write an sql querry which determine which all have SCOM agent installed and which all have not .
    Can anyone help me on this?

    Regards,
    Nithin KG

  77. Pritam says:

    Hi Kevin, could you give a query for giving the total alert data(including alert name + alert description) from SCOM DB/DW for last 3 months ?

  78. Tech SCOM says:

    Hi,
    Do we have any query for all alerts for a specific management pack with severity?

  79. kyleolson says:

    Can someone help me with a query.. I am trying to tie into the groups that I have created.. I have the view for alerts, but I want to tie them back to groups in the Operations Database…

  80. Anonymous says:

    Kevin Holman has already published the SCOM SQL bible –
    http://blogs.technet.com/b/kevinholman/archive

  81. Clifford2 says:

    Hi, would like to know the SQL used to show the time the alert cleared from console
    i have a query to show the alert description, incident number and alert path and raised alert , but how to add so that it shows the time alert cleared as well

  82. Dave says:

    Is there a query for finding out what administrator removed an object from SCOM 2012 r2?

  83. Kevin Holman says:

    @Dave – unfortunately – SCOM does not log administrator actions for auditing.

  84. Anonymous says:

    ~ Scott Walker | Senior Support Escalation Engineer In the first installment in this series, I discussed

  85. Sean says:

    Can you send me query to pull Mp for particular computer

  86. Sergey says:

    If you want to find the Rule ID, just add "RuleId" table, then using Get-SCOMRule -id "ID Number" we can find the problem rule and override it.

    select top 10 Path, ObjectName, CounterName, InstanceName, SampleValue, TimeSampled, RuleId

    from PerformanceDataAllView pdv with (NOLOCK)
    inner join PerformanceCounterView pcv on pdv.performancesourceinternalid = pcv.performancesourceinternalid

    inner join BaseManagedEntity bme on pcv.ManagedEntityId = bme.BaseManagedEntityId

    where objectname = ‘Network Interface’ AND
    countername = ‘Bytes Sent/sec’
    order by timesampled

  87. hi,

    I have a simple query that calculate the number of connection to database i.e

    SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame

    Now how can I run this query in SCOM 2012 R2 .
    Do I have to make new rule or new monitor for it.
    How to convert this query into script and run it.

    Can you show me how to execute this query to get the number of connection,please

    Thanks ,

  88. Naeblis says:

    Kevin,

    you can update all the queries with the following to help with local time, since SCOM records all time in UTC,

    declare @tmz int
    set @tmz = DATEDIFF(HOUR,getutcdate(), getdate())

    then in the body of the query,
    dateadd(hour,@tmz,TimeAdded)

    for example the query ‘Number of console Alerts per Day:’

    declare @tmz int
    set @tmz = DATEDIFF(HOUR,getutcdate(), getdate())

    SELECT CONVERT(VARCHAR(20), dateadd(hour,@tmz,TimeAdded), 102) AS DayAdded, COUNT(*) AS NumAlertsPerDay
    FROM Alert WITH (NOLOCK)
    WHERE TimeRaised is not NULL
    GROUP BY CONVERT(VARCHAR(20), dateadd(hour,@tmz,TimeAdded), 102)
    ORDER BY DayAdded DESC

  89. Dexter says:

    Hi,
    I am looking for a query to pull out the availability and response time of website or webapplication. And is there any way to find the matching sql query for the reports that we pull from Reporting section in SCOM.
    Thanks in advance.

  90. Gregg says:

    We have the PKI MP installed and looking for a SQL query that will list all of the valid certificates (these are found in the Certificates-Valid state view. I need to export the list of all valid certificates that SCOM has discovered and is monitoring.

  91. Marinus Witbraad says:

    Kevin,

    Our OpsDB is growing fast.
    When I run the query ‘Large Table query’ and do a count on all results it’s only 3.5GB.
    But our OpsDB is 40GB wherefrom 55% filled with Data (that’s 22GB).
    This is after some cleanup scripts, etc.
    Is there a way to see or explain what’s taken all the space within the used Data?

    1. Kevin Holman says:

      Shoot me an email with the results of your large table query pasted in excel.

      kevin.holman@microsoft.com

      1. M. Witbraad says:

        I just send you an email.
        Thanks for helping.

  92. Wael Besbes says:

    Hi Kevin,

    I’m looking for performance queries in SCOM 2012. Many views and tables was changed.
    Could you help please ?

    Thanks,

    1. Kevin Holman says:

      The tables and views haven’t changed that I am aware of.

  93. Ayman says:

    Hello ,

    I am facing storm of events which rapidly filling DW , I am trying to find the servers generating this events but this query is not working for SCOM 2012 R2/SQL 2012 , please how to make the same query for SCOM 2012 ?

    Computers generating the most events: (This shows us which computers create the most event traffic and use the most database space)

    SELECT top 20 LoggingComputer as ComputerName, COUNT(*) AS TotalEvents
    FROM EventallView with (NOLOCK)
    GROUP BY LoggingComputer
    ORDER BY TotalEvents DESC

    Computers generating the most events, by event number: (This shows the noisiest computers, group by unique event numbers)

    SELECT top 20 LoggingComputer as ComputerName, COUNT(*) AS TotalEvents, Number as EventID
    FROM EventallView with (NOLOCK)
    GROUP BY LoggingComputer, Number
    ORDER BY TotalEvents DESC

    Computers generating the most events, grouped by identical event number and publishername:

    SELECT top 20 LoggingComputer as ComputerName, COUNT(*) AS TotalEvents, PublisherName as EventSource, Number as EventID
    FROM EventallView with (NOLOCK)
    GROUP BY LoggingComputer, PublisherName, Number
    ORDER BY TotalEvents DESC

    1. Kevin Holman says:

      Those queries work fine in SCOM 2012.

      They are made to target the OperationsManager DB – NOT the DW.

      Most event collection rules – will have dual write actions which means they write to both the DB and the DW – so looking at the DB is a good way to understand what is going haywire.

      I document this here: https://blogs.technet.microsoft.com/kevinholman/2009/11/25/tuning-tip-turning-off-some-over-collection-of-events/

      If you MUST have queries for the DW – you can just scroll down the page to the “Data Warehouse section” where I have the same or similar queries there for the DW.

  94. Jeff says:

    Hey Kevin,

    Any chance I can still access the SCOM 2007 SQL Queries? You’d be surprised how many folks are still on this platform.

    Thanks so much.

    1. Kevin Holman says:

      The new link queries still work on SCOM 2007 for almost all of them. Much of the schema did not change.

  95. Ali M. says:

    Hello Kevin, I am trying to make a dashboard which shows information about servers that are running and are down (heartbeat failure notification) for a day. I have found a script that gives the heartbeat as this, (the comment script is what I am trying to establish). I am a little new to computing.

    SELECT [Id]
    ,[Name]
    ,[Description]
    ,[MonitoringObjectId]
    — ,a.NetworkName
    ,[MonitoringClassId]
    ,[MonitoringObjectDisplayName]
    ,[MonitoringObjectName]
    ,[MonitoringObjectPath]
    ,[MonitoringObjectFullName]
    ,[IsMonitorAlert]
    ,[ProblemId]
    ,[MonitoringRuleId]
    ,[ResolutionState]
    ,[Priority]
    ,[Severity]
    ,[Category]
    ,[Owner]
    ,[ResolvedBy]
    ,[TimeRaised]
    ,[TimeAdded]
    ,[LastModified]
    ,[LastModifiedBy]
    ,[TimeResolved]
    ,[TimeResolutionStateLastModified]
    ,[CustomField1]
    ,[CustomField2]
    ,[CustomField3]
    ,[CustomField4]
    ,[CustomField5]
    ,[CustomField6]
    ,[CustomField7]
    ,[CustomField8]
    ,[CustomField9]
    ,[CustomField10]
    ,[TicketId]
    ,[Context]
    ,[ConnectorId]
    ,[LastModifiedByNonConnector]
    ,[MonitoringObjectInMaintenanceMode]
    ,[MaintenanceModeLastModified]
    ,[MonitoringObjectHealthState]
    ,[StateLastModified]
    ,[ConnectorStatus]
    ,[TopLevelHostEntityId]
    ,[RepeatCount]
    ,[AlertStringId]
    ,[AlertStringName]
    ,[LanguageCode]
    ,[AlertStringDescription]
    ,[AlertParams]
    ,[SiteName]
    ,[TfsWorkItemId]
    ,[TfsWorkItemOwner]
    FROM [OperationsManager].[dbo].[AlertView] av
    –INNER JOIN [OperationsManager].[dbo].[MT_Computer] a ON a.BaseManagedEntityId=av.MonitoringObjectId
    Where Timeadded >= (Getdate()-1)
    And Name = ‘Microsoft.SystemCenter.HealthService.Heartbeat’

    I also want to display another chart on the dashboard that shows the health state for all the connected servers. But I can’t find a master table for all the running servers and their health state. Could you help with this query? And also comment on the one above?

Skip to main content