[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

WMI - Getting access to the Event Details?

New to WMI.  Have googled a while today, but no luck.

I am generating an error with MySQL (see screenshot attached).

I can get access to a lot of the event info using:
Select * from Win32_NTLogEvent where Type ='Error' and SourceName = 'MySQL'

But I can't seem to get my hands on what I really care about, which is shown in the log viewer in the "box" in the General tag.

I want to get that message "Plugin 'InnoDB' registration as a STORAGE ENGINE failed."

How can I using a WMI query?
0
trippy1976
Asked:
trippy1976
  • 6
  • 5
  • 2
2 Solutions
 
EDDYKTCommented:
0
 
trippy1976Author Commented:
I forgot to attach the screenshot of the event log viewer.  Also attaching the saved results of my WMI query.  

No, it's sadly not in the Message field... that would be trivial.  I think this is more involved.

Screenshot of the event viewerresult.htm
0
 
Bob LearnedCommented:
Did you look at the other properties for the Win32_NTLogEvent?

Win32_NTLogEvent Class
http://msdn.microsoft.com/en-us/library/aa394226(v=vs.85).aspx

Is that information in the Data property?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
trippy1976Author Commented:
Yes.  The data is in "InsertionStrings"

I need the information from that object in a WQL query.  

The html doc I attached shows all the properties and their resulting values.  If it were avaialble in a top-level property I wouldn't be posting here :)  Thanks for the help, but I fear the answer to this is "it can't be done"
0
 
Bob LearnedCommented:
InsertionStrings is a string array, so you should be able to get that information from the Win32_NTLogEvent object.
0
 
EDDYKTCommented:
don't think it supports on WMI, you may want to use API instead
0
 
trippy1976Author Commented:
@TheLearnedOne - you can, if you are scripting.  If you are simply doing a WQL query I am not sure if it's possible.

I googled forever, then I turned here.  What I really need is the WMI query that will get the pieces of InsertionString info.
0
 
Bob LearnedCommented:
Can you show me what you are working with, please?
0
 
trippy1976Author Commented:
As suspected, you can't query directly to the elements in something like Insertion Strings.  I had to write a VB script to do the query, get the results, and grab that deeper data.  Appears to be the only way to do this.  Thanks everyone.
0
 
Bob LearnedCommented:
Did you come up with the VB script?
0
 
trippy1976Author Commented:
Yes.  I found the JoinStringsArray function somewhere on google.
strComputer = "."
Set objWMIService = GetObject _
    ( "winmgmts:\\" & strComputer & "\root\cimv2")
	
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent where Type ='Error' and Logfile ='Application' and SourceName='MySQL'")


For Each objItem in colItems     
	strLogString = objItem.TimeGenerated & "," & JoinStringsArray(objItem.InsertionStrings)
Next



Function JoinStringsArray(ByRef aArray)
    If VarType(aArray) = vbNull Then
        JoinStringsArray = ""
        Exit Function
    Else
        JoinStringsArray = Join(aArray)
        JoinStringsArray = Replace(JoinStringsArray, "(NULL)", "")
    End If
End Function

Open in new window

0
 
Bob LearnedCommented:
You don't need VBScript to do what you have shown.  I don't see anything that it overly complicated, and not achievable with VB.NET/C#.
0
 
trippy1976Author Commented:
I'm certain you can do it a number of ways.  I really can't go into the specifics of why I needed a VBScript in this case, but it was my choice for workaround.

There was an existing component that could do direct WMI queries, but since you can't get at the info I need via WMI directly I had to go this route.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now