CMDB Query Builder: how to get Computers associated to at least one Network Adapter

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2022 10:27 AM
Hi -
Using CMDB Query Builder, I am trying to achieve something as simple as listing the Computers that do NOT have at least one Network Adapter (and as a stretch, those latter should have at least one IP Address attached).
I can see how to make this happen between CIs that are related via a CMDB relationship (cmdb_rel_ci) but I don't see how to do this using references. It happens that cmdb_ci_network_adapter has a standard reference to cmdb_ci.
Is this actually something that is supported by CMDB Query Builder? If not is there any other ways of achieving the same?
If this worked, I would like to use the query in Performance Analytics. In indicator sources, I could get this work but only for CI -> Network Adapter, but not for the whole chain: CI -> Network Adapter -> IP Address (i.e. 2 levels of references):
Any thoughts?
Thanks,
JC
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2022 11:17 PM
Hi
please have a look on page https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/product/configuration-managemen...
You will find there a good explanation on the relationships and references.
It seems that you have to use the class cmdb_ci_server instead of cmdb_ci_computer.
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 02:12 AM
Thanks, the drawing is really cool.
I think the issue is with the fact that cmdb_ci_network_adapter is associated to the computer (or the server for that matter) via a reference, and not via a CMDB relationship (the drawing you shared documents both actually).
Then the IP address is associated to the network adapter via a reference too.
CMDB Query Builder is not good at modeling something like:
List all the Servers that do NOT have a Network Adapter referencing them AND that do not have an IP Address referencing the Network Adapter.
Simple to script (see below) but not so simple to do with just the condition builder and/or CMDB Query Builder. This is how I eventually scripted it in a Performance Analytics script, but my preferred option would be to go for a CMDB Query Builder query:
hasServerNicAndIp: function(serverSysId) {
var grIp = new GlideRecord('cmdb_ci_ip_address');
grIp.addQuery('nic.cmdb_ci', serverSysId);
grIp.setLimit(1);
grIp.query();
return grIp.hasNext();
}