I'd like to create a query to list all nodes that are members of a group. Any help would be greatly appreciated.
Groups can contain different objects (Nodes, Volumes, more groups, etc.) therefore it is not always straightforward how to navigate through them. Try the following and see if it works, note that it will only output the nodes in the specific group and will ignore sub-groups if any.
SELECT CM.Name FROM Orion.ContainerMembers CMWHERE CM.EntityDisplayName='Node'AND CM.Container.Name = 'group name'
Indeed they can but in this case I know the groups I'm targeting only contain nodes. Thanks for the steer!
SIDE NOTE: If you are doing much with groups, you will discover they just suck. Alternatively setup custom properties and use those instead. Then to maintain compatibly with your existing groups you add a dynamic query to the group to add all of the nodes with that custom property value.
Something like this
SELECT DISTINCT(n.caption)FROM orion.containermembers cmLEFT JOIN Orion.nodes n on n.NodeID = cm.MemberPrimaryIDWHERE cm.MemberEntityType like '%Node%'
Or if you want the group name swap in the group name property instead of n.caption
Great shout @brscott
from performance perspective and especially if you going to be running the query many times, try not to use leading % in your where clause especially when you have lots of nodes 10X because you do not want to be reading all the table into the memory every time. you can use = 'Orion.Nodes' see the highlighted query below and check against you environment to make decision.
It's working, but showing only node name. Want to add IP address of each node of the group and group member name and one Custom properties like Node Category.
Is it possible to achieve using query?
Sure, you will need to add in the missing properties that you want to see in the SWQL statement. I am not sure of your custom property name but this may get you close to want you want.
SELECT DISTINCT c.Name, n.Caption, n.IPAddress, n.CustomProperties.node_category, FROM Orion.ContainerMembers cmLEFT JOIN Orion.Nodes n ON n.NodeID = cm.MemberPrimaryIDLEFT JOIN Orion.Container c ON c.ContainerID = cm.ContainerIDWHERE cm.MemberEntityType LIKE '%Node%'