Absent Member.
Absent Member.
1106 views

WMI-Query to get messages for a service

Jump to solution
Is it possible to get the text of a message from a service in the service tree via WMI? I cannot use the service-id of the service which I'm interested in (e.g. to query OV_Message), because the message is generated at a dependent child and the status is propagated to this service.
Labels (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.
Absent Member.
Here is a script. Also in attachment.

'cscript //nologo service_messages.vbs "axiovow" "myservice"

Dim host, sid, namespace, msgQuery
host = WScript.Arguments.item(0)
sid = WScript.Arguments.item(1)
namespace = "\root\hewlettpackard\openview\data"

Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add sid, sid
Set objService = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" + host + namespace)
traverseService sid

IF objDictionary.Count > 0 THEN
msgQuery = "SELECT * FROM OV_Message WHERE State < 4 AND ("
clause = ""
colKeys = objDictionary.Keys
FOR EACH key IN colKeys
msgQuery = msgQuery & clause & "ServiceId = '" & key & "'"
clause = " OR "
NEXT
msgQuery = msgQuery & ")"
WScript.echo "Service count: " & objDictionary.Count
Set msgInst = objService.ExecQuery(msgQuery)
FOR EACH msg IN msgInst
printMessage(msg)
NEXT
END IF

SUB traverseService(sid)
parentName = "OV_Service.Name=""" & sid & """"
asscQuery = "REFERENCES OF {" & parentName & "}"
Set inst = objService.ExecQuery(asscQuery)
FOR EACH obj IN inst
IF obj.Path_.Class = "OV_ServiceComposition" THEN
childName = Split(obj.PartComponent, """")(1)
ELSE
childName = Split(obj.Dependent, """")(1)
END IF
IF NOT objDictionary.Exists(childName) THEN
objDictionary.Add childName, childName
traverseService childName
END IF
NEXT
END SUB

SUB printMessage(obj)
WScript.echo ":::"
WScript.echo " Severity: " & obj.Severity
WScript.echo " Time Received: " & CDate(obj.TimeReceived)
WScript.echo " NodeName: " & obj.NodeName
WScript.echo " ServiceId: " & obj.ServiceId
WScript.echo " Text: " & obj.Text
END SUB

View solution in original post

7 Replies
Absent Member.
Absent Member.
Are you talking about something similar to the svchost processes where a service has multiple processes under it? If so you might want to look at;

http://support.microsoft.com/?kbid=314056

Steve
0 Likes
Absent Member.
Absent Member.
Thomas,

You need to query WMI recursively for a list of nested services relative to the target service first (OV_Service, OV_ServiceComposition, OV_ServiceDependency). Then, having obtained the list of child service_ids, you would need to query OV_Message for messages that match these service_ids. Warning: there are restrictions on the maximum length of the predicate expression and the number of predicates in an WQL query. These restrictions are specific to your OS and OVO version.

Sergei
Absent Member.
Absent Member.
Sergei,

thanks for your answer.
Can you show me an example?

Can you tell me the limitations?
I have OVOW 7.5 on Windows2003 and OVOW 7.21 on Windows2000.
0 Likes
Absent Member.
Absent Member.
Use the tools on ovinternals to do just this... "FederatedMOM" gets the messages for a service - including dependencies and subcomponents.

D
I do "Windows"
Absent Member.
Absent Member.
Here is a script. Also in attachment.

'cscript //nologo service_messages.vbs "axiovow" "myservice"

Dim host, sid, namespace, msgQuery
host = WScript.Arguments.item(0)
sid = WScript.Arguments.item(1)
namespace = "\root\hewlettpackard\openview\data"

Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add sid, sid
Set objService = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" + host + namespace)
traverseService sid

IF objDictionary.Count > 0 THEN
msgQuery = "SELECT * FROM OV_Message WHERE State < 4 AND ("
clause = ""
colKeys = objDictionary.Keys
FOR EACH key IN colKeys
msgQuery = msgQuery & clause & "ServiceId = '" & key & "'"
clause = " OR "
NEXT
msgQuery = msgQuery & ")"
WScript.echo "Service count: " & objDictionary.Count
Set msgInst = objService.ExecQuery(msgQuery)
FOR EACH msg IN msgInst
printMessage(msg)
NEXT
END IF

SUB traverseService(sid)
parentName = "OV_Service.Name=""" & sid & """"
asscQuery = "REFERENCES OF {" & parentName & "}"
Set inst = objService.ExecQuery(asscQuery)
FOR EACH obj IN inst
IF obj.Path_.Class = "OV_ServiceComposition" THEN
childName = Split(obj.PartComponent, """")(1)
ELSE
childName = Split(obj.Dependent, """")(1)
END IF
IF NOT objDictionary.Exists(childName) THEN
objDictionary.Add childName, childName
traverseService childName
END IF
NEXT
END SUB

SUB printMessage(obj)
WScript.echo ":::"
WScript.echo " Severity: " & obj.Severity
WScript.echo " Time Received: " & CDate(obj.TimeReceived)
WScript.echo " NodeName: " & obj.NodeName
WScript.echo " ServiceId: " & obj.ServiceId
WScript.echo " Text: " & obj.Text
END SUB

View solution in original post

Absent Member.
Absent Member.
Sergei,
thanks for the script, it helped me a lot.

Drew,
the tool is not flexible enough for my requirements.
0 Likes

Hi,

 

I am using this script provided below to obtain the underlying messages for the impacted service.When I had OMW 8.16 it always worked, but now I see that since I migrated to OMW 9.x it only works for certain services.(At least I think that this may have been when it started to give problems.)

When it does fail for certain service entities it gives the folowing run time error:

 

D:\OMW_Scripts\GetMessagesforService.vbs(36, 4) Microsoft VBScript runtime error
: Object doesn't support this property or method: 'obj.Dependent'

 

Any ideas as to why it would fail like this?

 

Kind Regards

Graham

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.